From 0e6c10b325d11518bdfceffa39239bf474b7de6d Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Thu, 28 May 2020 11:10:14 +0300 Subject: [PATCH] Add packet to list of default providers Signed-off-by: Avi Deitcher --- cmd/clusterctl/client/config/providers_client.go | 6 ++++++ cmd/clusterctl/client/config_test.go | 4 ++++ cmd/clusterctl/client/repository/metadata_client.go | 12 ++++++++++++ cmd/clusterctl/cmd/config_repositories_test.go | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/cmd/clusterctl/client/config/providers_client.go b/cmd/clusterctl/client/config/providers_client.go index c64425686f73..d5fd2c6fd137 100644 --- a/cmd/clusterctl/client/config/providers_client.go +++ b/cmd/clusterctl/client/config/providers_client.go @@ -35,6 +35,7 @@ const ( Metal3ProviderName = "metal3" OpenStackProviderName = "openstack" VSphereProviderName = "vsphere" + PacketProviderName = "packet" ProvidersConfigKey = "providers" ) @@ -89,6 +90,11 @@ func (p *providersClient) defaults() []Provider { url: "https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases/latest/infrastructure-components.yaml", providerType: clusterctlv1.InfrastructureProviderType, }, + &provider{ + name: PacketProviderName, + url: "https://github.com/packethost/cluster-api-provider-packet/releases/latest/infrastructure-components.yaml", + providerType: clusterctlv1.InfrastructureProviderType, + }, &provider{ name: Metal3ProviderName, url: "https://github.com/metal3-io/cluster-api-provider-metal3/releases/latest/infrastructure-components.yaml", diff --git a/cmd/clusterctl/client/config_test.go b/cmd/clusterctl/client/config_test.go index 5462267af987..977dedb740c2 100644 --- a/cmd/clusterctl/client/config_test.go +++ b/cmd/clusterctl/client/config_test.go @@ -50,6 +50,7 @@ func Test_clusterctlClient_GetProvidersConfig(t *testing.T) { field: field{ client: newFakeClient(newFakeConfig()), }, + // note: these will be sorted by name by the Providers() call, so be sure they are in alphabetical order here too wantProviders: []string{ config.ClusterAPIProviderName, config.KubeadmBootstrapProviderName, @@ -58,6 +59,7 @@ func Test_clusterctlClient_GetProvidersConfig(t *testing.T) { config.AzureProviderName, config.Metal3ProviderName, config.OpenStackProviderName, + config.PacketProviderName, config.VSphereProviderName, }, wantErr: false, @@ -67,6 +69,7 @@ func Test_clusterctlClient_GetProvidersConfig(t *testing.T) { field: field{ client: newFakeClient(newFakeConfig().WithProvider(customProviderConfig)), }, + // note: these will be sorted by name by the Providers() call, so be sure they are in alphabetical order here too wantProviders: []string{ config.ClusterAPIProviderName, customProviderConfig.Name(), @@ -76,6 +79,7 @@ func Test_clusterctlClient_GetProvidersConfig(t *testing.T) { config.AzureProviderName, config.Metal3ProviderName, config.OpenStackProviderName, + config.PacketProviderName, config.VSphereProviderName, }, wantErr: false, diff --git a/cmd/clusterctl/client/repository/metadata_client.go b/cmd/clusterctl/client/repository/metadata_client.go index 58ee53395fde..b5fa84046388 100644 --- a/cmd/clusterctl/client/repository/metadata_client.go +++ b/cmd/clusterctl/client/repository/metadata_client.go @@ -206,6 +206,18 @@ func (f *metadataClient) getEmbeddedMetadata() *clusterctlv1.Metadata { // older version are not supported by clusterctl }, } + case config.PacketProviderName: + return &clusterctlv1.Metadata{ + TypeMeta: metav1.TypeMeta{ + APIVersion: clusterctlv1.GroupVersion.String(), + Kind: "Metadata", + }, + ReleaseSeries: []clusterctlv1.ReleaseSeries{ + // v1alpha3 release series + {Major: 0, Minor: 3, Contract: "v1alpha3"}, + // older version are not supported by clusterctl + }, + } case config.OpenStackProviderName: return &clusterctlv1.Metadata{ TypeMeta: metav1.TypeMeta{ diff --git a/cmd/clusterctl/cmd/config_repositories_test.go b/cmd/clusterctl/cmd/config_repositories_test.go index be2125d38734..08605dce5148 100644 --- a/cmd/clusterctl/cmd/config_repositories_test.go +++ b/cmd/clusterctl/cmd/config_repositories_test.go @@ -108,6 +108,7 @@ azure InfrastructureProvider https://github.com/kubernetes-sigs/ metal3 InfrastructureProvider https://github.com/metal3-io/cluster-api-provider-metal3/releases/latest/ infrastructure-components.yaml my-infra-provider InfrastructureProvider /home/.cluster-api/overrides/infrastructure-docker/latest/ infrastructure-components.yaml openstack InfrastructureProvider https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/latest/ infrastructure-components.yaml +packet InfrastructureProvider https://github.com/packethost/cluster-api-provider-packet/releases/latest/ infrastructure-components.yaml vsphere InfrastructureProvider https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/latest/ infrastructure-components.yaml ` @@ -147,6 +148,10 @@ var expectedOutputYaml = `- File: core_components.yaml Name: openstack ProviderType: InfrastructureProvider URL: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/latest/ +- File: infrastructure-components.yaml + Name: packet + ProviderType: InfrastructureProvider + URL: https://github.com/packethost/cluster-api-provider-packet/releases/latest/ - File: infrastructure-components.yaml Name: vsphere ProviderType: InfrastructureProvider