Skip to content

Commit

Permalink
Remove clusterctl --watching-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed May 25, 2021
1 parent d2813d0 commit d3a2e94
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 520 deletions.
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Client interface {
// GetProvidersConfig returns the list of providers configured for this instance of clusterctl.
GetProvidersConfig() ([]Provider, error)

// GetProviderComponents returns the provider components for a given provider with options including targetNamespace, watchingNamespace.
// GetProviderComponents returns the provider components for a given provider with options including targetNamespace.
GetProviderComponents(provider string, providerType clusterctlv1.ProviderType, options ComponentsOptions) (Components, error)

// Init initializes a management cluster by adding the requested list of providers.
Expand Down
5 changes: 2 additions & 3 deletions cmd/clusterctl/client/cluster/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,8 @@ func (u *providerUpgrader) getUpgradeComponents(provider UpgradeItem) (repositor
}

options := repository.ComponentsOptions{
Version: provider.NextVersion,
TargetNamespace: provider.Namespace,
WatchingNamespace: provider.WatchedNamespace,
Version: provider.NextVersion,
TargetNamespace: provider.Namespace,
}
components, err := providerRepository.Components().Get(options)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// getComponentsByName is a utility method that returns components
// for a given provider with options including targetNamespace, and watchingNamespace.
// for a given provider with options including targetNamespace.
func (c *clusterctlClient) getComponentsByName(provider string, providerType clusterctlv1.ProviderType, options repository.ComponentsOptions) (repository.Components, error) {
// Parse the abbreviated syntax for name[:version]
name, version, err := parseProviderName(provider)
Expand All @@ -43,7 +43,7 @@ func (c *clusterctlClient) getComponentsByName(provider string, providerType clu

// Get a client for the provider repository and read the provider components;
// during the process, provider components will be processed performing variable substitution, customization of target
// and watching namespace etc.
// namespace etc.
// Currently we are not supporting custom yaml processors for the provider
// components. So we revert to using the default SimpleYamlProcessor.
repositoryClientFactory, err := c.repositoryClientFactory(RepositoryClientFactoryInput{Provider: providerConfig})
Expand Down
7 changes: 3 additions & 4 deletions cmd/clusterctl/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ func (c *clusterctlClient) GetProvidersConfig() ([]Provider, error) {
func (c *clusterctlClient) GetProviderComponents(provider string, providerType clusterctlv1.ProviderType, options ComponentsOptions) (Components, error) {
// ComponentsOptions is an alias for repository.ComponentsOptions; this makes the conversion
inputOptions := repository.ComponentsOptions{
Version: options.Version,
TargetNamespace: options.TargetNamespace,
WatchingNamespace: options.WatchingNamespace,
SkipVariables: options.SkipVariables,
Version: options.Version,
TargetNamespace: options.TargetNamespace,
SkipVariables: options.SkipVariables,
}
components, err := c.getComponentsByName(provider, providerType, inputOptions)
if err != nil {
Expand Down
23 changes: 9 additions & 14 deletions cmd/clusterctl/client/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ func Test_clusterctlClient_GetProviderComponents(t *testing.T) {
WithRepository(repository1)

type args struct {
provider string
targetNameSpace string
watchingNamespace string
provider string
targetNameSpace string
}
type want struct {
provider config.Provider
Expand All @@ -154,9 +153,8 @@ func Test_clusterctlClient_GetProviderComponents(t *testing.T) {
{
name: "Pass",
args: args{
provider: capiProviderConfig.Name(),
targetNameSpace: "ns2",
watchingNamespace: "",
provider: capiProviderConfig.Name(),
targetNameSpace: "ns2",
},
want: want{
provider: capiProviderConfig,
Expand All @@ -167,9 +165,8 @@ func Test_clusterctlClient_GetProviderComponents(t *testing.T) {
{
name: "Fail",
args: args{
provider: fmt.Sprintf("%s:v0.2.0", capiProviderConfig.Name()),
targetNameSpace: "ns2",
watchingNamespace: "",
provider: fmt.Sprintf("%s:v0.2.0", capiProviderConfig.Name()),
targetNameSpace: "ns2",
},
wantErr: true,
},
Expand All @@ -179,8 +176,7 @@ func Test_clusterctlClient_GetProviderComponents(t *testing.T) {
g := NewWithT(t)

options := ComponentsOptions{
TargetNamespace: tt.args.targetNameSpace,
WatchingNamespace: tt.args.watchingNamespace,
TargetNamespace: tt.args.targetNameSpace,
}
got, err := client.GetProviderComponents(tt.args.provider, capiProviderConfig.Type(), options)
if tt.wantErr {
Expand Down Expand Up @@ -224,9 +220,8 @@ func Test_getComponentsByName_withEmptyVariables(t *testing.T) {
WithCluster(cluster1)

options := ComponentsOptions{
TargetNamespace: "ns1",
WatchingNamespace: "",
SkipVariables: true,
TargetNamespace: "ns1",
SkipVariables: true,
}
components, err := client.GetProviderComponents(repository1Config.Name(), repository1Config.Type(), options)
g.Expect(err).NotTo(HaveOccurred())
Expand Down
23 changes: 8 additions & 15 deletions cmd/clusterctl/client/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ type InitOptions struct {
// will be installed in a provider's default namespace.
TargetNamespace string

// WatchingNamespace defines the namespace the providers should watch to reconcile Cluster API objects.
// If unspecified, the providers watches for Cluster API objects across all namespaces.
WatchingNamespace string

// LogUsageInstructions instructs the init command to print the usage instructions in case of first run.
LogUsageInstructions bool

Expand Down Expand Up @@ -193,10 +189,9 @@ func (c *clusterctlClient) setupInstaller(cluster cluster.Client, options InitOp
installer := cluster.ProviderInstaller()

addOptions := addToInstallerOptions{
installer: installer,
targetNamespace: options.TargetNamespace,
watchingNamespace: options.WatchingNamespace,
skipVariables: options.skipVariables,
installer: installer,
targetNamespace: options.TargetNamespace,
skipVariables: options.skipVariables,
}

if options.CoreProvider != "" {
Expand Down Expand Up @@ -245,10 +240,9 @@ func (c *clusterctlClient) addDefaultProviders(cluster cluster.Client, options *
}

type addToInstallerOptions struct {
installer cluster.ProviderInstaller
targetNamespace string
watchingNamespace string
skipVariables bool
installer cluster.ProviderInstaller
targetNamespace string
skipVariables bool
}

// addToInstaller adds the components to the install queue and checks that the actual provider type match the target group.
Expand All @@ -262,9 +256,8 @@ func (c *clusterctlClient) addToInstaller(options addToInstallerOptions, provide
continue
}
componentsOptions := repository.ComponentsOptions{
TargetNamespace: options.targetNamespace,
WatchingNamespace: options.watchingNamespace,
SkipVariables: options.skipVariables,
TargetNamespace: options.targetNamespace,
SkipVariables: options.skipVariables,
}
components, err := c.getComponentsByName(provider, providerType, componentsOptions)
if err != nil {
Expand Down
Loading

0 comments on commit d3a2e94

Please sign in to comment.