Skip to content

Commit

Permalink
remove deprecated v1 provider id format
Browse files Browse the repository at this point in the history
Signed-off-by: Prajyot Parab <[email protected]>
  • Loading branch information
Prajyot-Parab committed Jan 8, 2025
1 parent ea51a9c commit 7daeda0
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 364 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ generate-go-conversions: $(CONVERSION_GEN) ## Generate conversions go code
.PHONY: generate-templates
generate-templates: $(KUSTOMIZE) ## Generate cluster templates
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass.yaml
$(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass.yaml
Expand Down
2 changes: 0 additions & 2 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,6 @@ func (m *MachineScope) SetProviderID(id *string) error {
return err
}
m.IBMVPCMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("ibm://%s///%s/%s", accountID, m.Machine.Spec.ClusterName, *id))
} else {
m.IBMVPCMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("ibmvpc://%s/%s", m.Machine.Spec.ClusterName, m.IBMVPCMachine.Name))
}
return nil
}
Expand Down
5 changes: 0 additions & 5 deletions cloud/scope/powervs_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import (
"sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/cloud/services/vpc"
"sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/endpoints"
ignV2Types "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/ignition"
"sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/options"
"sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/record"
)

Expand Down Expand Up @@ -954,10 +953,6 @@ func (m *PowerVSMachineScope) GetServiceInstanceID() (string, error) {
// SetProviderID will set the provider id for the machine.
func (m *PowerVSMachineScope) SetProviderID(instanceID string) error {
// Based on the ProviderIDFormat version the providerID format will be decided.
if options.ProviderIDFormatType(options.ProviderIDFormat) == options.ProviderIDFormatV1 {
m.IBMPowerVSMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("ibmpowervs://%s/%s", m.Machine.Spec.ClusterName, m.IBMPowerVSMachine.Name))
return nil
}
m.V(3).Info("setting provider id in v2 format")

serviceInstanceID, err := m.GetServiceInstanceID()
Expand Down
10 changes: 0 additions & 10 deletions cloud/scope/powervs_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,16 +912,6 @@ func TestGetMachineInternalIP(t *testing.T) {
func TestSetProviderID(t *testing.T) {
providerID := "foo-provider-id"

t.Run("Set Provider ID in v1 format", func(t *testing.T) {
g := NewWithT(t)
scope := setupPowerVSMachineScope(clusterName, machineName, ptr.To(pvsImage), ptr.To(pvsNetwork), true, nil)
options.ProviderIDFormat = string(options.ProviderIDFormatV1)
err := scope.SetProviderID("foo-providerID")
expectedProviderID := ptr.To(fmt.Sprintf("ibmpowervs://%s/%s", scope.Machine.Spec.ClusterName, scope.IBMPowerVSMachine.Name))
g.Expect(*scope.IBMPowerVSMachine.Spec.ProviderID).To(Equal(*expectedProviderID))
g.Expect(err).To(BeNil())
})

t.Run("failed to get service instance ID", func(t *testing.T) {
g := NewWithT(t)
scope := PowerVSMachineScope{
Expand Down
10 changes: 3 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,10 @@ func initFlags(fs *pflag.FlagSet) {
}

func validateFlags() error {
switch options.ProviderIDFormatType(options.ProviderIDFormat) {
// Deprecated: ProviderIDFormatV1 is deprecated and will be removed in a future release.
case options.ProviderIDFormatV1:
setupLog.Info("Using v1 version of ProviderID format.V1 is deprecated and will be removed in a future release.Instead use V2.")
case options.ProviderIDFormatV2:
if options.ProviderIDFormatType(options.ProviderIDFormat) == options.ProviderIDFormatV2 {
setupLog.Info("Using v2 version of ProviderID format")
default:
return fmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s, %s ", options.ProviderIDFormat, options.ProviderIDFormatV1, options.ProviderIDFormatV2)
} else {
return fmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s ", options.ProviderIDFormat, options.ProviderIDFormatV2)
}

if err := logsv1.ValidateAndApply(logOptions, nil); err != nil {
Expand Down
7 changes: 0 additions & 7 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ package options
type ProviderIDFormatType string

const (
// ProviderIDFormatV1 will set provider id to machine as follows
// For VPC machines: ibmvpc://<cluster_name>/<vm_hostname>
// For Power VS machines: ibmpowervs://<cluster_name>/<vm_hostname>
// Deprecated: ProviderIDFormatV1 is deprecated and will be removed in a future release. see https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/1868 for more details.
// use ProviderIDFormatV2 instead ProviderIDFormatV1.
ProviderIDFormatV1 ProviderIDFormatType = "v1"

// ProviderIDFormatV2 will set provider id to machine as follows
// For VPC machines: ibm://<account_id>///<cluster_id>/<vpc_machine_id>
// For Power VS machines: ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
Expand Down
296 changes: 0 additions & 296 deletions templates/cluster-template-powervs.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions templates/cluster-template-powervs/kcp.yaml

This file was deleted.

Loading

0 comments on commit 7daeda0

Please sign in to comment.