Skip to content

Commit 2d37109

Browse files
authored
Changes to deprecate powervs-provider-id-fmt flat (#1032)
* Proposal for capibmadm cli tool * Deprecate powervs-provider-id-fmt to use provider-id-fmt
1 parent d6d5a94 commit 2d37109

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

cloud/scope/powervs_machine.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ func (m *PowerVSMachineScope) GetZone() string {
573573
// SetProviderID will set the provider id for the machine.
574574
func (m *PowerVSMachineScope) SetProviderID(id *string) {
575575
// Based on the ProviderIDFormat version the providerID format will be decided.
576-
if options.ProviderIDFormatType(options.PowerVSProviderIDFormat) == options.PowerVSProviderIDFormatV2 {
576+
if options.ProviderIDFormatType(options.PowerVSProviderIDFormat) == options.PowerVSProviderIDFormatV2 ||
577+
options.ProviderIDFormatType(options.ProviderIDFormat) == options.ProviderIDFormatV2 {
577578
if id != nil {
578579
m.IBMPowerVSMachine.Spec.ProviderID = pointer.String(fmt.Sprintf("ibmpowervs://%s/%s/%s/%s", m.GetRegion(), m.GetZone(), m.IBMPowerVSMachine.Spec.ServiceInstanceID, *id))
579580
}

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,20 @@ func initFlags(fs *pflag.FlagSet) {
165165
"The minimum interval at which watched resources are reconciled.",
166166
)
167167

168-
// TODO: Deprecate it to use provider-id-fmt for both vpc and power vs
168+
// Deprecated: Use provider-id-fmt flag go set provider id format for Power VS.
169169
fs.StringVar(
170170
&options.PowerVSProviderIDFormat,
171171
"powervs-provider-id-fmt",
172172
string(options.PowerVSProviderIDFormatV1),
173173
"ProviderID format is used set the Provider ID format for Machine",
174174
)
175+
_ = fs.MarkDeprecated("powervs-provider-id-fmt", "please use provider-id-fmt flag")
175176

176177
fs.StringVar(
177178
&options.ProviderIDFormat,
178179
"provider-id-fmt",
179180
string(options.ProviderIDFormatV1),
180-
"ProviderID format is used set the Provider ID format for Machine (Currently for VPC machines only)",
181+
"ProviderID format is used set the Provider ID format for Machine",
181182
)
182183

183184
fs.StringVar(
@@ -191,17 +192,17 @@ func initFlags(fs *pflag.FlagSet) {
191192
func validateFlags() error {
192193
switch options.ProviderIDFormatType(options.PowerVSProviderIDFormat) {
193194
case options.PowerVSProviderIDFormatV1:
194-
setupLog.Info("Using v1 version of Power VS ProviderID format")
195+
setupLog.Info("Power VS ProviderID format is set to v1 version")
195196
case options.PowerVSProviderIDFormatV2:
196-
setupLog.Info("Using v2 version of Power VS ProviderID format")
197+
setupLog.Info("Power VS ProviderID format is set to v2 version")
197198
default:
198199
return fmt.Errorf("invalid value for flag powervs-provider-id-fmt: %s, Supported values: v1, v2 ", options.PowerVSProviderIDFormat)
199200
}
200201
switch options.ProviderIDFormatType(options.ProviderIDFormat) {
201202
case options.ProviderIDFormatV1:
202-
setupLog.Info("Using v1 version of VPC ProviderID format")
203+
setupLog.Info("Using v1 version of ProviderID format")
203204
case options.ProviderIDFormatV2:
204-
setupLog.Info("Using v2 version of VPC ProviderID format")
205+
setupLog.Info("Using v2 version of ProviderID format")
205206
default:
206207
return fmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s, %s ", options.ProviderIDFormat, options.ProviderIDFormatV1, options.ProviderIDFormatV2)
207208
}

pkg/options/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,27 @@ type ProviderIDFormatType string
2121

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

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

2931
// ProviderIDFormatV1 will set provider id to machine as follows
3032
// For VPC machines: ibmvpc://<cluster_name>/<vm_hostname>
33+
// For Power VS machines: ibmpowervs://<cluster_name>/<vm_hostname>
3134
ProviderIDFormatV1 ProviderIDFormatType = "v1"
3235

3336
// ProviderIDFormatV2 will set provider id to machine as follows
3437
// For VPC machines: ibm://<account_id>///<cluster_id>/<vpc_machine_id>
38+
// For Power VS machines: ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
3539
ProviderIDFormatV2 ProviderIDFormatType = "v2"
3640
)
3741

3842
var (
3943
// PowerVSProviderIDFormat is used to identify the Provider ID format for Power VS Machine.
44+
// Deprecated: Instead use ProviderIDFormat.
4045
PowerVSProviderIDFormat string
4146
// ProviderIDFormat is used to identify the Provider ID format for Machine.
4247
ProviderIDFormat string

0 commit comments

Comments
 (0)