Skip to content

Commit

Permalink
Deprecate powervs-provider-id-fmt to use provider-id-fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Jan 16, 2023
1 parent e65e79b commit acc871c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cloud/scope/powervs_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand All @@ -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)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@ type ProviderIDFormatType string

const (
// PowerVSProviderIDFormatV1 will set provider id to machine as ibmpowervs://<cluster_name>/<vm_hostname>
// Deprecated: Use ProviderIDFormatV1.
PowerVSProviderIDFormatV1 ProviderIDFormatType = "v1"

// PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
// Deprecated: Use ProviderIDFormatV2.
PowerVSProviderIDFormatV2 ProviderIDFormatType = "v2"

// 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>
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>
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
Expand Down

0 comments on commit acc871c

Please sign in to comment.