Skip to content

Commit 4791e00

Browse files
authored
Merge pull request #2071 from fabriziopandini/clusterctl-remove-force-flag
🐛clusterctl: remove --force flag from init
2 parents fb39702 + 830be17 commit 4791e00

File tree

6 files changed

+4
-35
lines changed

6 files changed

+4
-35
lines changed

cmd/clusterctl/cmd/init.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type initOptions struct {
3030
infrastructureProviders []string
3131
targetNamespace string
3232
watchingNamespace string
33-
force bool
3433
}
3534

3635
var io = &initOptions{}
@@ -89,7 +88,6 @@ func init() {
8988
initCmd.Flags().StringSliceVarP(&io.bootstrapProviders, "bootstrap", "b", nil, "Bootstrap providers to add to the management cluster. By default (empty), the kubeadm bootstrap provider is installed on the first init")
9089
initCmd.Flags().StringVarP(&io.targetNamespace, "target-namespace", "", "", "The target namespace where the providers should be deployed. If not specified, each provider will be installed in a provider's default namespace")
9190
initCmd.Flags().StringVarP(&io.watchingNamespace, "watching-namespace", "", "", "Namespace that the providers should watch to reconcile Cluster API objects. If unspecified, the providers watches for Cluster API objects across all namespaces")
92-
initCmd.Flags().BoolVarP(&io.force, "force", "f", false, "Force clusterctl to skip preflight checks about supported configurations for a management cluster")
9391

9492
RootCmd.AddCommand(initCmd)
9593
}
@@ -109,7 +107,6 @@ func runInit() error {
109107
InfrastructureProviders: io.infrastructureProviders,
110108
TargetNameSpace: io.targetNamespace,
111109
WatchingNamespace: io.watchingNamespace,
112-
Force: io.force,
113110
})
114111
if err != nil {
115112
return err

cmd/clusterctl/pkg/client/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type InitOptions struct {
3030
InfrastructureProviders []string
3131
TargetNameSpace string
3232
WatchingNamespace string
33-
Force bool
3433
}
3534

3635
// GetClusterTemplateOptions carries the options supported by GetClusterTemplate

cmd/clusterctl/pkg/client/cluster/installer.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type ProviderInstaller interface {
2727
// Add adds a provider to the install queue.
2828
// NB. By deferring the installation, the installer service can perform validation of the target state of the management cluster
2929
// before actually starting the installation of new providers.
30-
Add(repository.Components, bool) error
30+
Add(repository.Components) error
3131

3232
// Install performs the installation of the providers ready in the install queue.
3333
Install() ([]repository.Components, error)
@@ -43,11 +43,9 @@ type providerInstaller struct {
4343

4444
var _ ProviderInstaller = &providerInstaller{}
4545

46-
func (i *providerInstaller) Add(components repository.Components, force bool) error {
46+
func (i *providerInstaller) Add(components repository.Components) error {
4747
if err := i.providerInventory.Validate(components.Metadata()); err != nil {
48-
if !force {
49-
return errors.Wrapf(err, "Installing provider %q can lead to a non functioning management cluster (you can use --force to ignore this error).", components.Name())
50-
}
48+
return errors.Wrapf(err, "Installing provider %q can lead to a non functioning management cluster.", components.Name())
5149
}
5250

5351
i.installQueue = append(i.installQueue, components)

cmd/clusterctl/pkg/client/cluster/inventory.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,6 @@ func (p *inventoryClient) Validate(m clusterctlv1.Provider) error {
133133
}
134134
}
135135

136-
// Version check:
137-
// If we are going to install an instance of a provider with version X, and there are already other instances of the same provider with
138-
// different versions there is the risk of creating problems to all the version different than X because we are going to override
139-
// all the existing non-namespaced objects (e.g. CRDs) with the ones from version X
140-
sameVersion := false
141-
for _, i := range instances {
142-
if i.Version == m.Version {
143-
sameVersion = true
144-
}
145-
}
146-
if !sameVersion {
147-
return errors.Errorf("The new instance of the %q provider has a version different than other instances of the same provider", m.Name)
148-
}
149-
150136
// Watching Namespace check:
151137
// If we are going to install an instance of a provider watching objects in namespaces already controlled by other providers
152138
// then there will be providers fighting for objects...

cmd/clusterctl/pkg/client/init.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func (c *clusterctlClient) Init(options InitOptions) ([]Components, bool, error)
6666
installer: installer,
6767
targetNameSpace: options.TargetNameSpace,
6868
watchingNamespace: options.WatchingNamespace,
69-
force: options.Force,
7069
}
7170

7271
if options.CoreProvider != "" {
@@ -100,7 +99,6 @@ type addToInstallerOptions struct {
10099
installer cluster.ProviderInstaller
101100
targetNameSpace string
102101
watchingNamespace string
103-
force bool
104102
}
105103

106104
// addToInstaller adds the components to the install queue and checks that the actual provider type match the target group
@@ -115,7 +113,7 @@ func (c *clusterctlClient) addToInstaller(options addToInstallerOptions, targetG
115113
return errors.Errorf("can't use %q provider as an %q, it is a %q", provider, targetGroup, components.Type())
116114
}
117115

118-
if err := options.installer.Add(components, options.force); err != nil {
116+
if err := options.installer.Add(components); err != nil {
119117
return err
120118
}
121119
}

cmd/clusterctl/pkg/client/init_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
3838
infrastructureProvider []string
3939
targetNameSpace string
4040
watchingNamespace string
41-
force bool
4241
}
4342
type want struct {
4443
provider Provider
@@ -66,7 +65,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
6665
infrastructureProvider: []string{"infra"},
6766
targetNameSpace: "",
6867
watchingNamespace: "",
69-
force: false,
7068
},
7169
want: []want{
7270
{
@@ -102,7 +100,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
102100
infrastructureProvider: []string{"infra:v3.1.0"},
103101
targetNameSpace: "",
104102
watchingNamespace: "",
105-
force: false,
106103
},
107104
want: []want{
108105
{
@@ -138,7 +135,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
138135
infrastructureProvider: []string{"infra"},
139136
targetNameSpace: "nsx",
140137
watchingNamespace: "",
141-
force: false,
142138
},
143139
want: []want{
144140
{
@@ -174,7 +170,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
174170
infrastructureProvider: []string{"infra"},
175171
targetNameSpace: "",
176172
watchingNamespace: "",
177-
force: false,
178173
},
179174
want: []want{
180175
{
@@ -203,7 +198,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
203198
infrastructureProvider: []string{"infra"},
204199
targetNameSpace: "",
205200
watchingNamespace: "",
206-
force: false,
207201
},
208202
want: nil,
209203
wantErr: true,
@@ -219,7 +213,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
219213
infrastructureProvider: []string{"infra"},
220214
targetNameSpace: "",
221215
watchingNamespace: "",
222-
force: false,
223216
},
224217
want: nil,
225218
wantErr: true,
@@ -235,7 +228,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
235228
infrastructureProvider: []string{config.KubeadmBootstrapProviderName},
236229
targetNameSpace: "",
237230
watchingNamespace: "",
238-
force: false,
239231
},
240232
want: nil,
241233
wantErr: true,
@@ -257,7 +249,6 @@ func Test_clusterctlClient_Init(t *testing.T) {
257249
InfrastructureProviders: tt.args.infrastructureProvider,
258250
TargetNameSpace: tt.args.targetNameSpace,
259251
WatchingNamespace: tt.args.watchingNamespace,
260-
Force: tt.args.force,
261252
})
262253

263254
if (err != nil) != tt.wantErr {

0 commit comments

Comments
 (0)