Skip to content

Commit

Permalink
Merge pull request #442 from Mirantis/skip-templates
Browse files Browse the repository at this point in the history
Add a separate flag to skip Templates creation in Release controller
  • Loading branch information
Kshatrix authored Oct 7, 2024
2 parents 330b9bd + e3655aa commit fe8ca1b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func main() {
createManagement bool
createTemplateManagement bool
createRelease bool
createTemplates bool
hmcTemplatesChartName string
enableTelemetry bool
enableWebhook bool
Expand All @@ -95,6 +96,7 @@ func main() {
flag.BoolVar(&createTemplateManagement, "create-template-management", true,
"Create a TemplateManagement object upon initial installation.")
flag.BoolVar(&createRelease, "create-release", true, "Create an HMC Release upon initial installation.")
flag.BoolVar(&createTemplates, "create-templates", true, "Create HMC Templates based on Release objects.")
flag.StringVar(&hmcTemplatesChartName, "hmc-templates-chart-name", "hmc-templates",
"The name of the helm chart with HMC Templates.")
flag.BoolVar(&enableTelemetry, "enable-telemetry", true, "Collect and send telemetry data.")
Expand Down Expand Up @@ -262,6 +264,7 @@ func main() {
Config: mgr.GetConfig(),
CreateManagement: createManagement,
CreateRelease: createRelease,
CreateTemplates: createTemplates,
HMCTemplatesChartName: hmcTemplatesChartName,
SystemNamespace: currentNamespace,
DefaultRegistryConfig: helm.DefaultRegistryConfig{
Expand Down
1 change: 1 addition & 0 deletions config/dev/hmc_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ controller:
defaultRegistryURL: oci://hmc-local-registry:5000/charts
insecureRegistry: true
createRelease: false
createTemplates: false
5 changes: 5 additions & 0 deletions internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type ReleaseReconciler struct {

CreateManagement bool
CreateRelease bool
CreateTemplates bool

HMCTemplatesChartName string
SystemNamespace string
Expand Down Expand Up @@ -152,6 +153,10 @@ func (r *ReleaseReconciler) ensureManagement(ctx context.Context) error {

func (r *ReleaseReconciler) reconcileHMCTemplates(ctx context.Context, req ctrl.Request) error {
l := ctrl.LoggerFrom(ctx)
if !r.CreateTemplates {
l.Info("Templates creation is disabled")
return nil
}
if initialReconcile(req) && !r.CreateRelease {
l.Info("Initial creation of HMC Release is skipped")
return nil
Expand Down
1 change: 1 addition & 0 deletions templates/provider/hmc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
- --create-management={{ .Values.controller.createManagement }}
- --create-template-management={{ .Values.controller.createTemplateManagement }}
- --create-release={{ .Values.controller.createRelease }}
- --create-templates={{ .Values.controller.createTemplates }}
- --enable-telemetry={{ .Values.controller.enableTelemetry }}
- --enable-webhook={{ .Values.admissionWebhook.enabled }}
- --webhook-port={{ .Values.admissionWebhook.port }}
Expand Down
1 change: 1 addition & 0 deletions templates/provider/hmc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ controller:
createManagement: true
createTemplateManagement: true
createRelease: true
createTemplates: true
enableTelemetry: true

containerSecurityContext:
Expand Down

0 comments on commit fe8ca1b

Please sign in to comment.