Skip to content

Commit 36f9aea

Browse files
committed
Make command-line arguments consistent with environment variables.
1 parent d28f8fe commit 36f9aea

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

CHANGES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changes
22

3+
## v0.8
4+
5+
Breaking changes:
6+
7+
* New features:
8+
9+
* The driver can now use the new `--ddcloud-mcp-endpoint` command-line argument (environment: `MCP_ENDPOINT`) to designate a custom end-point URI for the CloudControl API.
10+
11+
* The following command-line arguments have changed to be consistent with their corresponding environment variables:
12+
* `--ddcloud-user` is now `--ddcloud-mcp-user`
13+
* `--ddcloud-password` is now `--ddcloud-mcp-password`
14+
* `--ddcloud-region` is now `--ddcloud-mcp-region`
15+
316
## v0.7
417

518
New features:

client.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ func (driver *Driver) getCloudControlClient() (client *compute.Client, err error
6060
return
6161
}
6262

63-
if driver.CloudControlRegion == "" {
64-
err = errors.New("Cannot connect to CloudControl API (region not been configured)")
63+
if driver.CloudControlRegion != "" {
64+
client = compute.NewClient(driver.CloudControlRegion, driver.CloudControlUser, driver.CloudControlPassword)
65+
} else if driver.CloudControlEndPointURI != "" {
66+
client = compute.NewClientWithBaseAddress(driver.CloudControlEndPointURI, driver.CloudControlUser, driver.CloudControlPassword)
67+
} else {
68+
err = errors.New("Cannot connect to CloudControl API (neither region nor custom end-point URI have been configured)")
6569

6670
return
6771
}
68-
69-
client = compute.NewClient(driver.CloudControlRegion, driver.CloudControlUser, driver.CloudControlPassword)
7072
client.ConfigureRetry(clientMaxRetry, clientRetryPeriod)
7173

7274
driver.client = client

driver.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ type Driver struct {
3030
// The CloudControl password
3131
CloudControlPassword string
3232

33-
// The CloudControl region code
33+
// The CloudControl region name
3434
CloudControlRegion string
3535

36+
// A custom CloudControl API end-point URI
37+
CloudControlEndPointURI string
38+
3639
// The name of the target network domain.
3740
NetworkDomainName string
3841

@@ -96,22 +99,28 @@ func (driver *Driver) GetCreateFlags() []mcnflag.Flag {
9699
return []mcnflag.Flag{
97100
mcnflag.StringFlag{
98101
EnvVar: "MCP_USER",
99-
Name: "ddcloud-user",
102+
Name: "ddcloud-mcp-user",
100103
Usage: "The CloudControl user name",
101104
Value: "",
102105
},
103106
mcnflag.StringFlag{
104107
EnvVar: "MCP_PASSWORD",
105-
Name: "ddcloud-password",
108+
Name: "ddcloud-mcp-password",
106109
Usage: "The CloudControl password",
107110
Value: "",
108111
},
109112
mcnflag.StringFlag{
110113
EnvVar: "MCP_REGION",
111-
Name: "ddcloud-region",
114+
Name: "ddcloud-mcp-region",
112115
Usage: "The CloudControl region name",
113116
Value: "",
114117
},
118+
mcnflag.StringFlag{
119+
EnvVar: "MCP_ENDPOINT",
120+
Name: "ddcloud-mcp-endpoint",
121+
Usage: "A custom end-point URI for the CloudControl API",
122+
Value: "",
123+
},
115124
mcnflag.StringFlag{
116125
Name: "ddcloud-networkdomain",
117126
Usage: "The name of the target CloudControl network domain",
@@ -180,9 +189,11 @@ func (driver *Driver) DriverName() string {
180189

181190
// SetConfigFromFlags assigns and verifies the command-line arguments presented to the driver.
182191
func (driver *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
183-
driver.CloudControlUser = flags.String("ddcloud-user")
184-
driver.CloudControlPassword = flags.String("ddcloud-password")
185-
driver.CloudControlRegion = flags.String("ddcloud-region")
192+
driver.CloudControlRegion = flags.String("ddcloud-mcp-region")
193+
driver.CloudControlEndPointURI = flags.String("ddcloud-mcp-endpoint")
194+
195+
driver.CloudControlUser = flags.String("ddcloud-mcp-user")
196+
driver.CloudControlPassword = flags.String("ddcloud-mcp-password")
186197

187198
driver.NetworkDomainName = flags.String("ddcloud-networkdomain")
188199
driver.DataCenterID = flags.String("ddcloud-datacenter")
@@ -192,7 +203,6 @@ func (driver *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
192203
driver.SSHPort = flags.Int("ddcloud-ssh-port")
193204
driver.SSHUser = flags.String("ddcloud-ssh-user")
194205
driver.SSHKey = flags.String("ddcloud-ssh-key")
195-
196206
driver.SSHBootstrapPassword = flags.String("ddcloud-ssh-bootstrap-password")
197207

198208
driver.CreateSSHFirewallRule = flags.Bool("ddcloud-create-ssh-firewall-rule")

0 commit comments

Comments
 (0)