Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to deprecate powervs-provider-id-fmt flag #1032

Merged
merged 2 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,20 @@ 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",
string(options.PowerVSProviderIDFormatV1),
"ProviderID format is used set the Provider ID format for Machine",
)
_ = fs.MarkDeprecated("powervs-provider-id-fmt", "please use provider-id-fmt flag")

fs.StringVar(
&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",
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add following code to deprecate it

	fs.MarkDeprecated("powervs-provider-id-fmt", "please use provider-id-fmt flag")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it accordingly.


fs.StringVar(
Expand All @@ -191,17 +192,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")
case options.PowerVSProviderIDFormatV2:
setupLog.Info("Using v2 version of Power VS ProviderID format")
setupLog.Info("Power VS ProviderID format is set to v2 version")
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