Skip to content

Commit 55be936

Browse files
authored
refactor: Rename cluster flag to aos-cluster (#49)
Retained but marked as deprecated for backwards compatibility.
1 parent 3359b74 commit 55be936

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ curl -fsSL https://github.com/nutanix-cloud-native/cluster-api-ipam-provider-nut
5959
#### Reserving an IP
6060

6161
```shell
62-
$ Reserve IP addresses in a subnet
62+
$ caipamx reserve --help
63+
Reserve IP addresses in a subnet
6364

6465
Usage:
6566
caipamx reserve [flags]
@@ -68,7 +69,7 @@ Flags:
6869
-h, --help help for reserve
6970

7071
Global Flags:
71-
--cluster string Cluster to reserve IPs in, either UUID or name
72+
--aos-cluster string Nutanix AOS cluster to reserve IPs in, either UUID or name
7273
--password string Password for Nutanix Prism Central (also configurable via NUTANIX_PASSWORD environment variable)
7374
--prism-endpoint string Address of Nutanix Prism Central
7475
--subnet string Subnet to reserve IPs in, either UUID or name
@@ -98,7 +99,8 @@ caipamx reserve <FLAGS> <IP_FROM>-<IP-TO>
9899
#### Unreserve an IP
99100

100101
```shell
101-
$ Unreserve IP addresses in a subnet
102+
$ caipamx unreserve --help
103+
Unreserve IP addresses in a subnet
102104

103105
Usage:
104106
caipamx unreserve [flags]
@@ -107,7 +109,7 @@ Flags:
107109
-h, --help help for unreserve
108110

109111
Global Flags:
110-
--cluster string Cluster to reserve IPs in, either UUID or name
112+
--aos-cluster string Nutanix AOS cluster to reserve IPs in, either UUID or name
111113
--password string Password for Nutanix Prism Central (also configurable via NUTANIX_PASSWORD environment variable)
112114
--prism-endpoint string Address of Nutanix Prism Central
113115
--subnet string Subnet to reserve IPs in, either UUID or name

cmd/caipamx/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,20 @@ func main() {
6666
)
6767
must(rootCmd.MarkPersistentFlagRequired("subnet"))
6868

69+
persistentFlags.String(
70+
"aos-cluster",
71+
"",
72+
"Nutanix AOS cluster to reserve IPs in, either UUID or name",
73+
)
74+
75+
// Deprecated flag
6976
persistentFlags.String(
7077
"cluster",
7178
"",
72-
"Cluster to reserve IPs in, either UUID or name",
79+
"Nutanix AOS cluster to reserve IPs in, either UUID or name",
7380
)
81+
must(persistentFlags.MarkDeprecated("cluster", "use --aos-cluster instead"))
82+
rootCmd.MarkFlagsMutuallyExclusive("cluster", "aos-cluster")
7483

7584
persistentFlags.Bool(
7685
"insecure",

cmd/caipamx/reserve.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ func reserveCmd() *cobra.Command {
6565
}
6666

6767
subnet := viper.GetString("subnet")
68-
cluster := viper.GetString("cluster")
68+
aosCluster := viper.GetString("aos-cluster")
69+
if aosCluster == "" {
70+
aosCluster = viper.GetString("cluster")
71+
}
6972

7073
var ips []netip.Addr
7174

@@ -83,7 +86,7 @@ func reserveCmd() *cobra.Command {
8386
AsyncTaskOpts: client.AsyncTaskOpts{
8487
RequestID: requestID.String(),
8588
},
86-
Cluster: cluster,
89+
Cluster: aosCluster,
8790
},
8891
)
8992
if err != nil {

cmd/caipamx/unreserve.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func unreserveCmd() *cobra.Command {
5757
return fmt.Errorf("failed to generate request ID: %w", err)
5858
}
5959

60+
aosCluster := viper.GetString("aos-cluster")
61+
if aosCluster == "" {
62+
aosCluster = viper.GetString("cluster")
63+
}
64+
6065
err = wait.PollUntilContextTimeout(
6166
context.Background(),
6267
time.Second,
@@ -70,7 +75,7 @@ func unreserveCmd() *cobra.Command {
7075
AsyncTaskOpts: client.AsyncTaskOpts{
7176
RequestID: requestID.String(),
7277
},
73-
Cluster: viper.GetString("cluster"),
78+
Cluster: aosCluster,
7479
},
7580
)
7681
if err != nil {

0 commit comments

Comments
 (0)