Skip to content

Commit 6d34eaf

Browse files
authored
Merge pull request #534 from ulucinar/fix-monolith
Do not duplicate base package controllers in the monolithic provider
2 parents c2b9821 + 9f818b5 commit 6d34eaf

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

pkg/config/provider.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ func (cc ResourceConfiguratorChain) Configure(r *Resource) {
5252
type BasePackages struct {
5353
APIVersion []string
5454
// Deprecated: Use ControllerMap instead.
55-
Controller []string
55+
Controller []string
56+
// ControllerMap is a map from:
57+
// <API group name>/<resource name> to <provider package name>.
58+
// An example is "azure/resourcegroup: config", where "config" represents
59+
// the config package (provider family package).
5660
ControllerMap map[string]string
5761
}
5862

pkg/pipeline/run.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ func (r *PipelineRunner) Run(pc *config.Provider) []string { //nolint:gocyclo
207207
panic(errors.Wrapf(err, "cannot generate controller for resource %s", name))
208208
}
209209
controllerPkgMap[shortGroup] = append(controllerPkgMap[shortGroup], ctrlPkgPath)
210-
controllerPkgMap[config.PackageNameMonolith] = append(controllerPkgMap[config.PackageNameMonolith], ctrlPkgPath)
210+
// if the controller is not already added as a base package controller
211+
// to the monolith provider.
212+
if len(pc.BasePackages.ControllerMap[strings.TrimPrefix(ctrlPkgPath, strings.TrimSuffix(r.ModulePathControllers, "/")+"/")]) == 0 {
213+
controllerPkgMap[config.PackageNameMonolith] = append(controllerPkgMap[config.PackageNameMonolith], ctrlPkgPath)
214+
}
211215
if err := exampleGen.Generate(group, version, resources[name]); err != nil {
212216
panic(errors.Wrapf(err, "cannot generate example manifest for resource %s", name))
213217
}

0 commit comments

Comments
 (0)