From acc871ca48d7d6bb59a5ba6cf62763d2141b96e0 Mon Sep 17 00:00:00 2001 From: Karthik K N Date: Mon, 16 Jan 2023 08:47:34 +0530 Subject: [PATCH] Deprecate powervs-provider-id-fmt to use provider-id-fmt --- cloud/scope/powervs_machine.go | 3 ++- main.go | 12 ++++++------ pkg/options/options.go | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cloud/scope/powervs_machine.go b/cloud/scope/powervs_machine.go index fa73df747..ff17fa324 100644 --- a/cloud/scope/powervs_machine.go +++ b/cloud/scope/powervs_machine.go @@ -573,7 +573,8 @@ func (m *PowerVSMachineScope) GetZone() string { // SetProviderID will set the provider id for the machine. func (m *PowerVSMachineScope) SetProviderID(id *string) { // Based on the ProviderIDFormat version the providerID format will be decided. - if options.ProviderIDFormatType(options.PowerVSProviderIDFormat) == options.PowerVSProviderIDFormatV2 { + if options.ProviderIDFormatType(options.PowerVSProviderIDFormat) == options.PowerVSProviderIDFormatV2 || + options.ProviderIDFormatType(options.ProviderIDFormat) == options.ProviderIDFormatV2 { if id != nil { m.IBMPowerVSMachine.Spec.ProviderID = pointer.String(fmt.Sprintf("ibmpowervs://%s/%s/%s/%s", m.GetRegion(), m.GetZone(), m.IBMPowerVSMachine.Spec.ServiceInstanceID, *id)) } diff --git a/main.go b/main.go index 338598a93..2d03fa148 100644 --- a/main.go +++ b/main.go @@ -165,7 +165,7 @@ func initFlags(fs *pflag.FlagSet) { "The minimum interval at which watched resources are reconciled.", ) - // TODO: Deprecate it to use provider-id-fmt for both vpc and power vs + // Deprecated: Use provider-id-fmt flag go set provider id format for Power VS. fs.StringVar( &options.PowerVSProviderIDFormat, "powervs-provider-id-fmt", @@ -177,7 +177,7 @@ func initFlags(fs *pflag.FlagSet) { &options.ProviderIDFormat, "provider-id-fmt", string(options.ProviderIDFormatV1), - "ProviderID format is used set the Provider ID format for Machine (Currently for VPC machines only)", + "ProviderID format is used set the Provider ID format for Machine", ) fs.StringVar( @@ -191,17 +191,17 @@ func initFlags(fs *pflag.FlagSet) { func validateFlags() error { switch options.ProviderIDFormatType(options.PowerVSProviderIDFormat) { case options.PowerVSProviderIDFormatV1: - setupLog.Info("Using v1 version of Power VS ProviderID format") + setupLog.Info("Power VS ProviderID format is set to v1 version, Note: its deprecated use provider-id-fmt to provider id format") case options.PowerVSProviderIDFormatV2: - setupLog.Info("Using v2 version of Power VS ProviderID format") + setupLog.Info("Power VS ProviderID format is set to v2 version, Note: its deprecated use provider-id-fmt to provider id format") default: return fmt.Errorf("invalid value for flag powervs-provider-id-fmt: %s, Supported values: v1, v2 ", options.PowerVSProviderIDFormat) } switch options.ProviderIDFormatType(options.ProviderIDFormat) { case options.ProviderIDFormatV1: - setupLog.Info("Using v1 version of VPC ProviderID format") + setupLog.Info("Using v1 version of ProviderID format") case options.ProviderIDFormatV2: - setupLog.Info("Using v2 version of VPC ProviderID format") + 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) } diff --git a/pkg/options/options.go b/pkg/options/options.go index dd86111f4..f91bb1a4d 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -21,22 +21,27 @@ type ProviderIDFormatType string const ( // PowerVSProviderIDFormatV1 will set provider id to machine as ibmpowervs:/// + // Deprecated: Use ProviderIDFormatV1. PowerVSProviderIDFormatV1 ProviderIDFormatType = "v1" // PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs:///// + // Deprecated: Use ProviderIDFormatV2. PowerVSProviderIDFormatV2 ProviderIDFormatType = "v2" // ProviderIDFormatV1 will set provider id to machine as follows // For VPC machines: ibmvpc:/// + // For Power VS machines: ibmpowervs:/// ProviderIDFormatV1 ProviderIDFormatType = "v1" // ProviderIDFormatV2 will set provider id to machine as follows // For VPC machines: ibm:////// + // For Power VS machines: ibmpowervs:///// ProviderIDFormatV2 ProviderIDFormatType = "v2" ) var ( // PowerVSProviderIDFormat is used to identify the Provider ID format for Power VS Machine. + // Deprecated: Instead use ProviderIDFormat. PowerVSProviderIDFormat string // ProviderIDFormat is used to identify the Provider ID format for Machine. ProviderIDFormat string