Skip to content

Commit

Permalink
feat: support multiple instances (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma authored Feb 1, 2024
1 parent fc81609 commit 888eeb0
Show file tree
Hide file tree
Showing 44 changed files with 418 additions and 98 deletions.
1 change: 1 addition & 0 deletions docs/data-sources/armada_armada.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Armada.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armada. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/armada_armada_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Armada.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armada. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/armada_armadaset.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing ArmadaSet.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armadas in this set. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/armada_armadaset_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing ArmadaSet.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armadas in this set. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/container_branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Branch.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired branch. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/container_branch_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Branch.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired branch. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/core_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Environment.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec configures the environment. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/core_environment_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Environment.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec configures the environment. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/core_region.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Region.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired region configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/core_region_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Region.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired region configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/core_site.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Site.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired site configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/core_site_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this data source to access information about an existing Site.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired site configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
42 changes: 40 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ terraform {
}
provider "ec" {
host = "<your armada host url>"
host = "<your enterprise console host url>"
instances {
name = "my-other-instance"
host = "<your enterprise console host url>"
}
}
resource "ec_core_site" "test" {
Expand All @@ -41,6 +45,23 @@ resource "ec_core_site" "test" {
}
}
}
resource "ec_core_site" "test2" {
instance = "my-other-instance"
metadata {
name = "test"
}
spec {
description = "My other test"
credentials {
endpoint = "<your endpoint>"
certificate = "<your cert>"
namespace = "<your ns>"
token = "<your token>"
}
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -50,7 +71,24 @@ resource "ec_core_site" "test" {

- `client_id` (String) The oAuth2 client id to authenticate against.
- `client_secret` (String) The oAuth2 client secret to authenticate against.
- `host` (String) The hostname (in form of URI) of Armada API.
- `host` (String) The hostname (in form of URI) of the Enterprise Console API.
- `instances` (Block List) Named Enterprise Console instances. (see [below for nested schema](#nestedblock--instances))
- `password` (String) The password to authenticate with.
- `token_endpoint` (String) The URI to the token authentication endpoint.
- `username` (String) The user to authenticate with.

<a id="nestedblock--instances"></a>
### Nested Schema for `instances`

Required:

- `client_id` (String) The oAuth2 client id to authenticate against.
- `host` (String) The hostname (in form of URI) of the Enterprise Console API.
- `name` (String) The instance name.

Optional:

- `client_secret` (String) The oAuth2 client secret to authenticate against.
- `password` (String) The password to authenticate with.
- `token_endpoint` (String) The URI to the token authentication endpoint.
- `username` (String) The user to authenticate with.
1 change: 1 addition & 0 deletions docs/resources/armada_armada.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ An Armada distributes a specified number of Game Servers across a Region.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armada. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/armada_armada_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ An Armada distributes a specified number of Game Servers across a Region.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armada. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/armada_armadaset.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ An ArmadaSet manages Armadas across multiple Regions, while sharing a common spe

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armadas in this set. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/armada_armadaset_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ An ArmadaSet manages Armadas across multiple Regions, while sharing a common spe

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired armadas in this set. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/container_branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ resource "ec_container_branch" "test" {

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired branch. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/container_branch_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ resource "ec_container_branch_v1" "test" {

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired branch. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/core_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ An Environment provides a mechanism to isolate groups of resources.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec configures the environment. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/core_environment_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ An Environment provides a mechanism to isolate groups of resources.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec configures the environment. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/core_region.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A Region determines how Armadas are distributed across Sites.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired region configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/core_region_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A Region determines how Armadas are distributed across Sites.

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired region configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/core_site.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ resource "ec_core_site" "test" {

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired site configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
1 change: 1 addition & 0 deletions docs/resources/core_site_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ resource "ec_core_site" "test" {

### Optional

- `instance` (String) Name is an instance name configured in the provider.
- `metadata` (Block List, Max: 1) Standard object's metadata. (see [below for nested schema](#nestedblock--metadata))
- `spec` (Block List, Max: 1) Spec defines the desired site configuration. (see [below for nested schema](#nestedblock--spec))

Expand Down
12 changes: 8 additions & 4 deletions ec/armada/resource_armada.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func ResourceArmada() *schema.Resource {
}

func resourceArmadaRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -58,7 +59,8 @@ func resourceArmadaRead(ctx context.Context, d *schema.ResourceData, m any) diag
}

func resourceArmadaCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -83,7 +85,8 @@ func resourceArmadaCreate(ctx context.Context, d *schema.ResourceData, m any) di
}

func resourceArmadaUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -108,7 +111,8 @@ func resourceArmadaUpdate(ctx context.Context, d *schema.ResourceData, m any) di
}

func resourceArmadaDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand Down
12 changes: 8 additions & 4 deletions ec/armada/resource_armadaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func ResourceArmadaSet() *schema.Resource {
}

func resourceArmadaSetRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -58,7 +59,8 @@ func resourceArmadaSetRead(ctx context.Context, d *schema.ResourceData, m any) d
}

func resourceArmadaSetCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -83,7 +85,8 @@ func resourceArmadaSetCreate(ctx context.Context, d *schema.ResourceData, m any)
}

func resourceArmadaSetUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -108,7 +111,8 @@ func resourceArmadaSetUpdate(ctx context.Context, d *schema.ResourceData, m any)
}

func resourceArmadaSetDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand Down
5 changes: 5 additions & 0 deletions ec/armada/schema_armada.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ec/armada/schema_armadaset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions ec/container/resource_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func ResourceBranch() *schema.Resource {
}

func resourceBranchRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -58,7 +59,8 @@ func resourceBranchRead(ctx context.Context, d *schema.ResourceData, m any) diag
}

func resourceBranchCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -83,7 +85,8 @@ func resourceBranchCreate(ctx context.Context, d *schema.ResourceData, m any) di
}

func resourceBranchUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -108,7 +111,8 @@ func resourceBranchUpdate(ctx context.Context, d *schema.ResourceData, m any) di
}

func resourceBranchDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
clientSet, err := ec.ResolveClientSet(m)
inst, _ := d.Get("instance").(string)
clientSet, err := ec.ResolveClientSet(m, inst)
if err != nil {
return diag.FromErr(err)
}
Expand Down
Loading

0 comments on commit 888eeb0

Please sign in to comment.