Skip to content

Commit 3e5e468

Browse files
authored
Merge pull request #7065 from randomvariable/clusterctl-ignore-validation-errors-option
🌱 clusterctl: Add --validate option to init
2 parents 81527d5 + 60c9a8c commit 3e5e468

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cmd/clusterctl/client/init.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ type InitOptions struct {
6969
// SkipTemplateProcess allows for skipping the call to the template processor, including also variable replacement in the component YAML.
7070
// NOTE this works only if the rawYaml is a valid yaml by itself, like e.g when using envsubst/the simple processor.
7171
skipTemplateProcess bool
72+
73+
// IgnoreValidationErrors allows for skipping the validation of provider installs.
74+
// NOTE this should only be used for development
75+
IgnoreValidationErrors bool
7276
}
7377

7478
// Init initializes a management cluster by adding the requested list of providers.
@@ -108,7 +112,10 @@ func (c *clusterctlClient) Init(options InitOptions) ([]Components, error) {
108112
// - There should be only one instance of the same provider.
109113
// - All the providers must support the same API Version of Cluster API (contract)
110114
if err := installer.Validate(); err != nil {
111-
return nil, err
115+
if !options.IgnoreValidationErrors {
116+
return nil, err
117+
}
118+
log.Error(err, "Ignoring validation errors")
112119
}
113120

114121
// Before installing the providers, ensure the cert-manager Webhook is in place.

cmd/clusterctl/cmd/init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type initOptions struct {
3434
infrastructureProviders []string
3535
targetNamespace string
3636
listImages bool
37+
validate bool
3738
waitProviders bool
3839
waitProviderTimeout int
3940
}
@@ -108,6 +109,8 @@ func init() {
108109
"Wait for providers to be installed.")
109110
initCmd.Flags().IntVar(&initOpts.waitProviderTimeout, "wait-provider-timeout", 5*60,
110111
"Wait timeout per provider installation in seconds. This value is ignored if --wait-providers is false")
112+
initCmd.Flags().BoolVar(&initOpts.validate, "validate", true,
113+
"If true, clusterctl will validate that the deployments will succeed on the management cluster.")
111114

112115
// TODO: Move this to a sub-command or similar, it shouldn't really be a flag.
113116
initCmd.Flags().BoolVar(&initOpts.listImages, "list-images", false,
@@ -132,6 +135,7 @@ func runInit() error {
132135
LogUsageInstructions: true,
133136
WaitProviders: initOpts.waitProviders,
134137
WaitProviderTimeout: time.Duration(initOpts.waitProviderTimeout) * time.Second,
138+
IgnoreValidationErrors: !initOpts.validate,
135139
}
136140

137141
if initOpts.listImages {

0 commit comments

Comments
 (0)