Skip to content

Commit 790bdbd

Browse files
authored
Adds region selection to baremetal provider (#106)
1 parent 8388355 commit 790bdbd

15 files changed

+124
-79
lines changed

docs/Writing Terraform configurations for OBMCS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ provider "baremetal" {
4141
private_key_path = "${var.private_key_path}"
4242
}
4343
```
44+
45+
To specify a different region, include the region parameter in your provider definition. Not specifying a value will use the default `us-phoenix-1` region.
46+
```
47+
provider "baremetal" {
48+
...
49+
region = "us-ashburn-1"
50+
}
51+
```
52+
4453
## CamelCase
4554
The OBMCS API uses CamelCase in multiple places. Terraform doesn't support CamelCase in configuration files so we've replaced it with underscores. For example -
4655

docs/resources/core/instance.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ The following attributes are exported:
4848
* `region` - The region that contains the Availability Domain the instance is running in.
4949
* `shape` - The shape of the instance. The shape determines the number of CPUs and the amount of memory allocated to the instance.
5050
* `time_created` - The date and time the instance was created.
51+
52+
* `public_ip` - The public ip of instance vnic (if enabled).
53+
* `private_ip` - The private ip of instance vnic (if enabled).

provider.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func init() {
2424
"private_key_path": "(Optional) The path to the user's PEM formatted private key.\n" +
2525
"A private_key or a private_key_path must be provided.",
2626
"private_key_password": "(Optional) The password used to secure the private key.",
27+
"region": "(Optional) The region for API connections.",
2728
}
2829
}
2930

@@ -80,6 +81,13 @@ func schemaMap() map[string]*schema.Schema {
8081
Description: descriptions["private_key_password"],
8182
DefaultFunc: schema.EnvDefaultFunc("OBMCS_PRIVATE_KEY_PASSWORD", nil),
8283
},
84+
"region": {
85+
Type: schema.TypeString,
86+
Optional: true,
87+
Default: "us-phoenix-1",
88+
Description: descriptions["region"],
89+
DefaultFunc: schema.EnvDefaultFunc("OBMCS_REGION", nil),
90+
},
8391
}
8492
}
8593

@@ -183,6 +191,7 @@ func providerConfig(d *schema.ResourceData) (client interface{}, err error) {
183191
privateKeyBuffer, hasKey := d.Get("private_key").(string)
184192
privateKeyPath, hasKeyPath := d.Get("private_key_path").(string)
185193
privateKeyPassword, hasKeyPass := d.Get("private_key_password").(string)
194+
region, hasRegion := d.Get("region").(string)
186195

187196
clientOpts := []baremetal.NewClientOptionsFunc{
188197
func(o *baremetal.NewClientOptions) {
@@ -206,6 +215,10 @@ func providerConfig(d *schema.ResourceData) (client interface{}, err error) {
206215
clientOpts = append(clientOpts, baremetal.PrivateKeyPassword(privateKeyPassword))
207216
}
208217

218+
if hasRegion && region != "" {
219+
clientOpts = append(clientOpts, baremetal.Region(region))
220+
}
221+
209222
client, err = baremetal.NewClient(userOCID, tenancyOCID, fingerprint, clientOpts...)
210223
return
211224
}

vendor/github.com/MustWin/baremetal-sdk-go/README.md

Lines changed: 22 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/MustWin/baremetal-sdk-go/client.go

Lines changed: 11 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/MustWin/baremetal-sdk-go/constants.go

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/MustWin/baremetal-sdk-go/object_storage_objects.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/MustWin/baremetal-sdk-go/request.go

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/MustWin/baremetal-sdk-go/request_options.go

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/MustWin/baremetal-sdk-go/requestor.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)