Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Jun 5, 2024
1 parent 67ad06e commit 9015c1d
Show file tree
Hide file tree
Showing 2 changed files with 14,539 additions and 4,768 deletions.
32 changes: 19 additions & 13 deletions internal/controller/component_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,30 @@ func customizeObjectsFn(provider operatorv1.GenericProvider) func(objs []unstruc
return nil, err
}

providerDeployment := provider.GetSpec().Deployment
providerManager := provider.GetSpec().Manager

// If there are multiple deployments, check if we specify customizations for those deployments.
if isMultipleDeployments && !isProviderManagerDeploymentName(o.GetName()) {
if provider.GetSpec().AdditionalDeployments != nil {
if additionalProviderCustomization, ok := provider.GetSpec().AdditionalDeployments[o.GetName()]; ok {
if err := customizeDeployment(additionalProviderCustomization.Deployment, additionalProviderCustomization.Manager, d); err != nil {
return nil, err
}
} else {
results = append(results, o)
continue
}
} else {
additionalDeployments := provider.GetSpec().AdditionalDeployments
// Skip the deployment if there are no additional deployments specified.
if additionalDeployments == nil {
results = append(results, o)
continue
}
} else {
if err := customizeDeployment(provider.GetSpec().Deployment, provider.GetSpec().Manager, d); err != nil {
return nil, err

additionalProviderCustomization, ok := additionalDeployments[o.GetName()]
if !ok {
results = append(results, o)
continue
}

providerDeployment = additionalProviderCustomization.Deployment
providerManager = additionalProviderCustomization.Manager
}

if err := customizeDeployment(providerDeployment, providerManager, d); err != nil {
return nil, err
}

if err := scheme.Scheme.Convert(d, &o, nil); err != nil {
Expand Down
Loading

0 comments on commit 9015c1d

Please sign in to comment.