Skip to content

Commit c9e08a6

Browse files
authored
Merge pull request #4696 from fabriziopandini/rename-inventory.GetDefault-methods
⚠️ Rename clusterctl client/inventory.GetDefaultProvider<> to GetProvider<>
2 parents 12c7339 + fd9a33c commit c9e08a6

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

cmd/clusterctl/client/cluster/inventory.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,11 @@ type InventoryClient interface {
9393
// this as the default provider; In case there are more provider of the same type, there is no default provider.
9494
GetDefaultProviderName(providerType clusterctlv1.ProviderType) (string, error)
9595

96-
// GetDefaultProviderVersion returns the default version for a given provider.
97-
// In case there is only a single version installed for a given provider, e.g. only the v0.4.1 version for the AWS provider, it returns
98-
// this as the default version; In case there are more version installed for the same provider, there is no default provider version.
99-
GetDefaultProviderVersion(provider string, providerType clusterctlv1.ProviderType) (string, error)
96+
// GetProviderVersion returns the version for a given provider.
97+
GetProviderVersion(provider string, providerType clusterctlv1.ProviderType) (string, error)
10098

101-
// GetDefaultProviderNamespace returns the default namespace for a given provider.
102-
// In case there is only a single instance for a given provider, e.g. only the AWS provider in the capa-system namespace, it returns
103-
// this as the default namespace; In case there are more instances for the same provider installed in different namespaces, there is no default provider namespace.
104-
GetDefaultProviderNamespace(provider string, providerType clusterctlv1.ProviderType) (string, error)
99+
// GetProviderNamespace returns the namespace for a given provider.
100+
GetProviderNamespace(provider string, providerType clusterctlv1.ProviderType) (string, error)
105101

106102
// CheckCAPIContract checks the Cluster API version installed in the management cluster, and fails if this version
107103
// does not match the current one supported by clusterctl.
@@ -340,7 +336,7 @@ func (p *inventoryClient) GetDefaultProviderName(providerType clusterctlv1.Provi
340336
return "", nil
341337
}
342338

343-
func (p *inventoryClient) GetDefaultProviderVersion(provider string, providerType clusterctlv1.ProviderType) (string, error) {
339+
func (p *inventoryClient) GetProviderVersion(provider string, providerType clusterctlv1.ProviderType) (string, error) {
344340
providerList, err := p.List()
345341
if err != nil {
346342
return "", err
@@ -356,11 +352,11 @@ func (p *inventoryClient) GetDefaultProviderVersion(provider string, providerTyp
356352
return versions.List()[0], nil
357353
}
358354

359-
// There is no version installed or more than one version installed for this provider; in both cases, a default version for this provider cannot be decided.
355+
// The default version for this provider cannot be decided.
360356
return "", nil
361357
}
362358

363-
func (p *inventoryClient) GetDefaultProviderNamespace(provider string, providerType clusterctlv1.ProviderType) (string, error) {
359+
func (p *inventoryClient) GetProviderNamespace(provider string, providerType clusterctlv1.ProviderType) (string, error) {
364360
providerList, err := p.List()
365361
if err != nil {
366362
return "", err
@@ -376,7 +372,7 @@ func (p *inventoryClient) GetDefaultProviderNamespace(provider string, providerT
376372
return namespaces.List()[0], nil
377373
}
378374

379-
// There is no provider or more than one namespace for this provider; in both cases, a default provider namespace cannot be decided.
375+
// The default provider namespace cannot be decided.
380376
return "", nil
381377
}
382378

cmd/clusterctl/client/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,15 @@ func (c *clusterctlClient) getTemplateFromRepository(cluster cluster.Client, opt
310310
}
311311
}
312312

313-
defaultProviderVersion, err := cluster.ProviderInventory().GetDefaultProviderVersion(name, clusterctlv1.InfrastructureProviderType)
313+
inventoryVersion, err := cluster.ProviderInventory().GetProviderVersion(name, clusterctlv1.InfrastructureProviderType)
314314
if err != nil {
315315
return nil, err
316316
}
317317

318-
if defaultProviderVersion == "" {
319-
return nil, errors.Errorf("failed to identify the default version for the provider %q. Please specify a version", name)
318+
if inventoryVersion == "" {
319+
return nil, errors.Errorf("Unable to identify version for the provider %q automatically. Please specify a version", name)
320320
}
321-
version = defaultProviderVersion
321+
version = inventoryVersion
322322
}
323323

324324
// Get the template from the template repository.

cmd/clusterctl/client/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ func (c *clusterctlClient) Delete(options DeleteOptions) error {
9999
}
100100

101101
// Try to detect the namespace where the provider lives
102-
provider.Namespace, err = clusterClient.ProviderInventory().GetDefaultProviderNamespace(provider.ProviderName, provider.GetProviderType())
102+
provider.Namespace, err = clusterClient.ProviderInventory().GetProviderNamespace(provider.ProviderName, provider.GetProviderType())
103103
if err != nil {
104104
return err
105105
}
106106
if provider.Namespace == "" {
107-
return errors.Errorf("Unable to find default namespace for the %q provider.", name)
107+
return errors.Errorf("Failed to identify the namespace for the %q provider.", name)
108108
}
109109

110110
providersToDelete = append(providersToDelete, provider)

0 commit comments

Comments
 (0)