diff --git a/docs/data-sources/armada_armada.md b/docs/data-sources/armada_armada.md
index 033ddda..0b5a743 100644
--- a/docs/data-sources/armada_armada.md
+++ b/docs/data-sources/armada_armada.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Armada.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -50,6 +51,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada.
@@ -77,6 +79,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -397,3 +400,22 @@ Optional:
- `int_val` (Number)
- `str_val` (String)
- `type` (Number)
+
+
+
+
+
+
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
diff --git a/docs/data-sources/armada_armada_v1.md b/docs/data-sources/armada_armada_v1.md
index dbabc53..c89c8fd 100644
--- a/docs/data-sources/armada_armada_v1.md
+++ b/docs/data-sources/armada_armada_v1.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Armada.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -50,6 +51,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada.
@@ -77,6 +79,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -397,3 +400,22 @@ Optional:
- `int_val` (Number)
- `str_val` (String)
- `type` (Number)
+
+
+
+
+
+
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
diff --git a/docs/data-sources/armada_armadaset.md b/docs/data-sources/armada_armadaset.md
index a7f21fc..c897747 100644
--- a/docs/data-sources/armada_armadaset.md
+++ b/docs/data-sources/armada_armadaset.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing ArmadaSet.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -49,6 +50,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy for all armadas. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada set.
- `override` (Block List) Override overrides configuration for named armadas. (see [below for nested schema](#nestedblock--spec--override))
@@ -91,6 +93,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -417,6 +420,22 @@ Optional:
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
+
+
+
### Nested Schema for `spec.override`
diff --git a/docs/data-sources/armada_armadaset_v1.md b/docs/data-sources/armada_armadaset_v1.md
index 83726d4..3c395a7 100644
--- a/docs/data-sources/armada_armadaset_v1.md
+++ b/docs/data-sources/armada_armadaset_v1.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing ArmadaSet.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -49,6 +50,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy for all armadas. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada set.
- `override` (Block List) Override overrides configuration for named armadas. (see [below for nested schema](#nestedblock--spec--override))
@@ -91,6 +93,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -417,6 +420,22 @@ Optional:
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
+
+
+
### Nested Schema for `spec.override`
diff --git a/docs/data-sources/armada_region.md b/docs/data-sources/armada_region.md
index dcbf19e..7b198a7 100644
--- a/docs/data-sources/armada_region.md
+++ b/docs/data-sources/armada_region.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Region.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/data-sources/armada_region_v1.md b/docs/data-sources/armada_region_v1.md
index 64fbe0f..e3b9c41 100644
--- a/docs/data-sources/armada_region_v1.md
+++ b/docs/data-sources/armada_region_v1.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Region.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/data-sources/armada_site.md b/docs/data-sources/armada_site.md
index 82f0b3f..1cd5cd6 100644
--- a/docs/data-sources/armada_site.md
+++ b/docs/data-sources/armada_site.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Site.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/data-sources/armada_site_v1.md b/docs/data-sources/armada_site_v1.md
index 44093bf..4171e80 100644
--- a/docs/data-sources/armada_site_v1.md
+++ b/docs/data-sources/armada_site_v1.md
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Site.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/data-sources/armada_branch_v1.md b/docs/data-sources/container_branch.md
similarity index 88%
rename from docs/data-sources/armada_branch_v1.md
rename to docs/data-sources/container_branch.md
index 9f80f8b..abe6a9c 100644
--- a/docs/data-sources/armada_branch_v1.md
+++ b/docs/data-sources/container_branch.md
@@ -1,12 +1,12 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "ec_armada_branch_v1 Data Source - terraform-provider-ec"
+page_title: "ec_container_branch Data Source - terraform-provider-ec"
subcategory: ""
description: |-
Use this data source to access information about an existing Branch.
---
-# ec_armada_branch_v1 (Data Source)
+# ec_container_branch (Data Source)
Use this data source to access information about an existing Branch.
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Branch.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/data-sources/armada_branch.md b/docs/data-sources/container_branch_v1.md
similarity index 87%
rename from docs/data-sources/armada_branch.md
rename to docs/data-sources/container_branch_v1.md
index 414d8a4..7886680 100644
--- a/docs/data-sources/armada_branch.md
+++ b/docs/data-sources/container_branch_v1.md
@@ -1,12 +1,12 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "ec_armada_branch Data Source - terraform-provider-ec"
+page_title: "ec_container_branch_v1 Data Source - terraform-provider-ec"
subcategory: ""
description: |-
Use this data source to access information about an existing Branch.
---
-# ec_armada_branch (Data Source)
+# ec_container_branch_v1 (Data Source)
Use this data source to access information about an existing Branch.
@@ -30,6 +30,7 @@ Use this data source to access information about an existing Branch.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/data-sources/core_environment.md b/docs/data-sources/core_environment.md
new file mode 100644
index 0000000..a5c117c
--- /dev/null
+++ b/docs/data-sources/core_environment.md
@@ -0,0 +1,49 @@
+---
+# generated by https://github.com/hashicorp/terraform-plugin-docs
+page_title: "ec_core_environment Data Source - terraform-provider-ec"
+subcategory: ""
+description: |-
+ Use this data source to access information about an existing Environment.
+---
+
+# ec_core_environment (Data Source)
+
+Use this data source to access information about an existing Environment.
+
+
+
+
+## Schema
+
+### Optional
+
+- `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))
+
+### Read-Only
+
+- `id` (String) The ID of this resource.
+
+
+### Nested Schema for `metadata`
+
+Optional:
+
+- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
+- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
+- `name` (String) The unique object name within its scope.
+
+Read-Only:
+
+- `revision` (String) An opaque resource revision.
+- `uid` (String) A unique identifier for each an object.
+
+
+
+### Nested Schema for `spec`
+
+Optional:
+
+- `description` (String) Description is the description of the environment.
+- `display_name` (String) DisplayName is friendly name of the environment.
diff --git a/docs/data-sources/core_environment_v1.md b/docs/data-sources/core_environment_v1.md
new file mode 100644
index 0000000..4cc2062
--- /dev/null
+++ b/docs/data-sources/core_environment_v1.md
@@ -0,0 +1,49 @@
+---
+# generated by https://github.com/hashicorp/terraform-plugin-docs
+page_title: "ec_core_environment_v1 Data Source - terraform-provider-ec"
+subcategory: ""
+description: |-
+ Use this data source to access information about an existing Environment.
+---
+
+# ec_core_environment_v1 (Data Source)
+
+Use this data source to access information about an existing Environment.
+
+
+
+
+## Schema
+
+### Optional
+
+- `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))
+
+### Read-Only
+
+- `id` (String) The ID of this resource.
+
+
+### Nested Schema for `metadata`
+
+Optional:
+
+- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
+- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
+- `name` (String) The unique object name within its scope.
+
+Read-Only:
+
+- `revision` (String) An opaque resource revision.
+- `uid` (String) A unique identifier for each an object.
+
+
+
+### Nested Schema for `spec`
+
+Optional:
+
+- `description` (String) Description is the description of the environment.
+- `display_name` (String) DisplayName is friendly name of the environment.
diff --git a/docs/resources/armada_armada.md b/docs/resources/armada_armada.md
index 53da9e8..d900752 100644
--- a/docs/resources/armada_armada.md
+++ b/docs/resources/armada_armada.md
@@ -30,6 +30,7 @@ An Armada distributes a specified number of Game Servers across a Region.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -50,6 +51,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada.
@@ -77,6 +79,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -397,3 +400,22 @@ Optional:
- `int_val` (Number)
- `str_val` (String)
- `type` (Number)
+
+
+
+
+
+
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
diff --git a/docs/resources/armada_armada_v1.md b/docs/resources/armada_armada_v1.md
index e60d9d0..9b06387 100644
--- a/docs/resources/armada_armada_v1.md
+++ b/docs/resources/armada_armada_v1.md
@@ -30,6 +30,7 @@ An Armada distributes a specified number of Game Servers across a Region.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -50,6 +51,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada.
@@ -77,6 +79,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -397,3 +400,22 @@ Optional:
- `int_val` (Number)
- `str_val` (String)
- `type` (Number)
+
+
+
+
+
+
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
diff --git a/docs/resources/armada_armadaset.md b/docs/resources/armada_armadaset.md
index 48f2a00..c82f94d 100644
--- a/docs/resources/armada_armadaset.md
+++ b/docs/resources/armada_armadaset.md
@@ -30,6 +30,7 @@ An ArmadaSet manages Armadas across multiple Regions, while sharing a common spe
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -49,6 +50,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy for all armadas. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada set.
- `override` (Block List) Override overrides configuration for named armadas. (see [below for nested schema](#nestedblock--spec--override))
@@ -91,6 +93,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -417,6 +420,22 @@ Optional:
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
+
+
+
### Nested Schema for `spec.override`
diff --git a/docs/resources/armada_armadaset_v1.md b/docs/resources/armada_armadaset_v1.md
index 1b007e7..e79618d 100644
--- a/docs/resources/armada_armadaset_v1.md
+++ b/docs/resources/armada_armadaset_v1.md
@@ -30,6 +30,7 @@ An ArmadaSet manages Armadas across multiple Regions, while sharing a common spe
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -49,6 +50,7 @@ Required:
Optional:
+- `autoscaling` (Block List, Max: 1) AutoscalingInterval defines the autoscaling strategy for all armadas. (see [below for nested schema](#nestedblock--spec--autoscaling))
- `description` (String) Description is the optional description of the armada set.
- `override` (Block List) Override overrides configuration for named armadas. (see [below for nested schema](#nestedblock--spec--override))
@@ -91,6 +93,7 @@ Optional:
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
@@ -417,6 +420,22 @@ Optional:
+
+### Nested Schema for `spec.autoscaling`
+
+Optional:
+
+- `fixed_interval` (Block List, Max: 1) FixedInterval defines a fixed interval autoscaling strategy. (see [below for nested schema](#nestedblock--spec--autoscaling--fixed_interval))
+
+
+### Nested Schema for `spec.autoscaling.fixed_interval`
+
+Optional:
+
+- `seconds` (Number) Seconds defines how often the auto-scaler will re-evaluate the number of game servers.
+
+
+
### Nested Schema for `spec.override`
diff --git a/docs/resources/armada_region.md b/docs/resources/armada_region.md
index 7130b3f..2c5ebbf 100644
--- a/docs/resources/armada_region.md
+++ b/docs/resources/armada_region.md
@@ -30,6 +30,7 @@ A Region determines how Armadas are distributed across Sites.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/resources/armada_region_v1.md b/docs/resources/armada_region_v1.md
index 40122f3..31fd899 100644
--- a/docs/resources/armada_region_v1.md
+++ b/docs/resources/armada_region_v1.md
@@ -30,6 +30,7 @@ A Region determines how Armadas are distributed across Sites.
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/resources/armada_site.md b/docs/resources/armada_site.md
index 046dbed..525b915 100644
--- a/docs/resources/armada_site.md
+++ b/docs/resources/armada_site.md
@@ -48,6 +48,7 @@ resource "ec_armada_site" "test" {
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/resources/armada_site_v1.md b/docs/resources/armada_site_v1.md
index 730dd3f..87add9c 100644
--- a/docs/resources/armada_site_v1.md
+++ b/docs/resources/armada_site_v1.md
@@ -48,6 +48,7 @@ resource "ec_armada_site_v1" "test" {
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/resources/armada_branch_v1.md b/docs/resources/container_branch.md
similarity index 86%
rename from docs/resources/armada_branch_v1.md
rename to docs/resources/container_branch.md
index 83240f2..a64be7e 100644
--- a/docs/resources/armada_branch_v1.md
+++ b/docs/resources/container_branch.md
@@ -1,19 +1,19 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "ec_armada_branch_v1 Resource - terraform-provider-ec"
+page_title: "ec_container_branch Resource - terraform-provider-ec"
subcategory: ""
description: |-
A Branch groups container Images.
---
-# ec_armada_branch_v1 (Resource)
+# ec_container_branch (Resource)
A Branch groups container Images.
## Example Usage
```terraform
-resource "ec_armada_branch_v1" "test" {
+resource "ec_container_branch" "test" {
metadata {
name = "test"
}
@@ -43,6 +43,7 @@ resource "ec_armada_branch_v1" "test" {
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/resources/armada_branch.md b/docs/resources/container_branch_v1.md
similarity index 85%
rename from docs/resources/armada_branch.md
rename to docs/resources/container_branch_v1.md
index 3831b03..75e3c7e 100644
--- a/docs/resources/armada_branch.md
+++ b/docs/resources/container_branch_v1.md
@@ -1,19 +1,19 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
-page_title: "ec_armada_branch Resource - terraform-provider-ec"
+page_title: "ec_container_branch_v1 Resource - terraform-provider-ec"
subcategory: ""
description: |-
A Branch groups container Images.
---
-# ec_armada_branch (Resource)
+# ec_container_branch_v1 (Resource)
A Branch groups container Images.
## Example Usage
```terraform
-resource "ec_armada_branch" "test" {
+resource "ec_container_branch_v1" "test" {
metadata {
name = "test"
}
@@ -43,6 +43,7 @@ resource "ec_armada_branch" "test" {
Optional:
- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
- `name` (String) The unique object name within its scope.
diff --git a/docs/resources/core_environment.md b/docs/resources/core_environment.md
new file mode 100644
index 0000000..c6dc9b0
--- /dev/null
+++ b/docs/resources/core_environment.md
@@ -0,0 +1,49 @@
+---
+# generated by https://github.com/hashicorp/terraform-plugin-docs
+page_title: "ec_core_environment Resource - terraform-provider-ec"
+subcategory: ""
+description: |-
+ An Environment provides a connection to deployment capacity.
+---
+
+# ec_core_environment (Resource)
+
+An Environment provides a connection to deployment capacity.
+
+
+
+
+## Schema
+
+### Optional
+
+- `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))
+
+### Read-Only
+
+- `id` (String) The ID of this resource.
+
+
+### Nested Schema for `metadata`
+
+Optional:
+
+- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
+- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
+- `name` (String) The unique object name within its scope.
+
+Read-Only:
+
+- `revision` (String) An opaque resource revision.
+- `uid` (String) A unique identifier for each an object.
+
+
+
+### Nested Schema for `spec`
+
+Optional:
+
+- `description` (String) Description is the description of the environment.
+- `display_name` (String) DisplayName is friendly name of the environment.
diff --git a/docs/resources/core_environment_v1.md b/docs/resources/core_environment_v1.md
new file mode 100644
index 0000000..1bed10b
--- /dev/null
+++ b/docs/resources/core_environment_v1.md
@@ -0,0 +1,49 @@
+---
+# generated by https://github.com/hashicorp/terraform-plugin-docs
+page_title: "ec_core_environment_v1 Resource - terraform-provider-ec"
+subcategory: ""
+description: |-
+ An Environment provides a connection to deployment capacity.
+---
+
+# ec_core_environment_v1 (Resource)
+
+An Environment provides a connection to deployment capacity.
+
+
+
+
+## Schema
+
+### Optional
+
+- `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))
+
+### Read-Only
+
+- `id` (String) The ID of this resource.
+
+
+### Nested Schema for `metadata`
+
+Optional:
+
+- `annotations` (Map of String) An unstructured map of keys and values stored on an object.
+- `environment` (String) The name of the environment the object belongs to.
+- `labels` (Map of String) A map of keys and values that can be used to organize and categorize objects.
+- `name` (String) The unique object name within its scope.
+
+Read-Only:
+
+- `revision` (String) An opaque resource revision.
+- `uid` (String) A unique identifier for each an object.
+
+
+
+### Nested Schema for `spec`
+
+Optional:
+
+- `description` (String) Description is the description of the environment.
+- `display_name` (String) DisplayName is friendly name of the environment.
diff --git a/ec/armada/armada.go b/ec/armada/armada.go
deleted file mode 100644
index 2c06171..0000000
--- a/ec/armada/armada.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package armada
-
-import (
- "errors"
-
- "gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
-)
-
-func resolveClientSet(m any) (clientset.Interface, error) {
- clientSet, ok := m.(clientset.Interface)
- if !ok {
- return nil, errors.New("invalid clientset")
- }
- return clientSet, nil
-}
diff --git a/ec/armada/converter.go b/ec/armada/converter.go
deleted file mode 100644
index 05f9258..0000000
--- a/ec/armada/converter.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package armada
-
-import (
- "github.com/nitrado/tfconv"
- "k8s.io/apimachinery/pkg/api/resource"
-)
-
-func converter() *tfconv.Converter {
- c := tfconv.New("json")
- c.Register(resource.Quantity{}, expandQuantity, flattenQuantity)
- return c
-}
-
-func expandQuantity(v any) (any, error) {
- return resource.ParseQuantity(v.(string))
-}
-
-func flattenQuantity(v any) (any, error) {
- q := v.(resource.Quantity)
- return (&q).String(), nil
-}
diff --git a/ec/armada/data_source_armada_branch_test.go b/ec/armada/data_source_armada_branch_test.go
deleted file mode 100644
index 8db1ec9..0000000
--- a/ec/armada/data_source_armada_branch_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package armada_test
-
-import (
- "fmt"
- "testing"
-
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
-)
-
-func TestArmadaDataSourceBranches(t *testing.T) {
- name := "my-branch"
- pf, _ := providertest.SetupProviderFactories(t)
-
- resource.Test(t, resource.TestCase{
- IsUnitTest: true,
- ProviderFactories: pf,
- Steps: []resource.TestStep{
- {
- Config: testArmadasDataSourceBranchesConfigBasic(name),
- Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("ec_armada_branch.test", "metadata.0.name", name),
- resource.TestCheckResourceAttr("ec_armada_branch.test", "spec.#", "1"),
- resource.TestCheckResourceAttr("ec_armada_branch.test", "spec.0.description", "My Branch"),
- ),
- },
- {
- Config: testArmadasDataSourceBranchesConfigBasic(name) +
- testArmadaDataSourceBranchConfigRead(),
- Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("data.ec_armada_branch.test", "metadata.0.name", name),
- resource.TestCheckResourceAttr("data.ec_armada_branch.test", "spec.#", "1"),
- resource.TestCheckResourceAttr("data.ec_armada_branch.test", "spec.0.description", "My Branch"),
- ),
- },
- },
- })
-}
-
-func testArmadasDataSourceBranchesConfigBasic(name string) string {
- return fmt.Sprintf(`resource "ec_armada_branch" "test" {
- metadata {
- name = "%s"
- }
- spec {
- description = "My Branch"
- }
-}
-`, name)
-}
-
-func testArmadaDataSourceBranchConfigRead() string {
- return `data "ec_armada_branch" "test" {
- metadata {
- name = "${ec_armada_branch.test.metadata.0.name}"
- }
-}
-`
-}
diff --git a/ec/armada/resource_armada_armada.go b/ec/armada/resource_armada_armada.go
index 8b53fff..77114e2 100644
--- a/ec/armada/resource_armada_armada.go
+++ b/ec/armada/resource_armada_armada.go
@@ -5,10 +5,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec"
"github.com/nitrado/terraform-provider-ec/pkg/resource"
- armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/armada/v1"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
- "gitlab.com/nitrado/b2b/ec/armada/pkg/api/errors"
+ "gitlab.com/nitrado/b2b/ec/apicore/api/errors"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/armada/v1"
)
// ResourceArmadaArmada returns the resource for an Armada.
@@ -27,14 +28,14 @@ func ResourceArmadaArmada() *schema.Resource {
}
func resourceArmadaArmadaRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
- name := d.Id()
+ env, name := ec.SplitName(d.Id())
- obj, err := clientSet.ArmadaV1().Armadas().Get(ctx, name, metav1.GetOptions{})
+ obj, err := clientSet.ArmadaV1().Armadas(env).Get(ctx, name, metav1.GetOptions{})
if err != nil {
switch {
case errors.IsNotFound(err):
@@ -45,7 +46,7 @@ func resourceArmadaArmadaRead(ctx context.Context, d *schema.ResourceData, m any
}
}
- data, err := converter().Flatten(obj, armadaSchema())
+ data, err := ec.Converter().Flatten(obj, armadaSchema())
if err != nil {
return diag.FromErr(err)
}
@@ -57,7 +58,7 @@ func resourceArmadaArmadaRead(ctx context.Context, d *schema.ResourceData, m any
}
func resourceArmadaArmadaCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -65,24 +66,24 @@ func resourceArmadaArmadaCreate(ctx context.Context, d *schema.ResourceData, m a
obj := &armadav1.Armada{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "Armada"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
- out, err := clientSet.ArmadaV1().Armadas().Create(ctx, obj, metav1.CreateOptions{})
+ out, err := clientSet.ArmadaV1().Armadas(obj.Environment).Create(ctx, obj, metav1.CreateOptions{})
if err != nil {
return diag.FromErr(err)
}
- d.SetId(out.Name)
+ d.SetId(ec.ScopedName(out.Environment, out.Name))
return resourceArmadaArmadaRead(ctx, d, m)
}
func resourceArmadaArmadaUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -90,31 +91,31 @@ func resourceArmadaArmadaUpdate(ctx context.Context, d *schema.ResourceData, m a
obj := &armadav1.Armada{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "Armada"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
- out, err := clientSet.ArmadaV1().Armadas().Update(ctx, obj, metav1.UpdateOptions{})
+ out, err := clientSet.ArmadaV1().Armadas(obj.Environment).Update(ctx, obj, metav1.UpdateOptions{})
if err != nil {
return diag.FromErr(err)
}
- d.SetId(out.Name)
+ d.SetId(ec.ScopedName(out.Environment, out.Name))
return resourceArmadaArmadaRead(ctx, d, m)
}
func resourceArmadaArmadaDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
- name := d.Id()
+ env, name := ec.SplitName(d.Id())
- if err = clientSet.ArmadaV1().Armadas().Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
+ if err = clientSet.ArmadaV1().Armadas(env).Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
switch {
case errors.IsNotFound(err):
// We will consider this a successful delete.
diff --git a/ec/armada/resource_armada_armada_test.go b/ec/armada/resource_armada_armada_test.go
index 7f2e4e2..bb13f00 100644
--- a/ec/armada/resource_armada_armada_test.go
+++ b/ec/armada/resource_armada_armada_test.go
@@ -3,17 +3,19 @@ package armada_test
import (
"context"
"fmt"
+ "strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
)
func TestArmadaResourceArmadas(t *testing.T) {
name := "my-armada"
+ env := "dflt"
pf, cs := providertest.SetupProviderFactories(t)
resource.Test(t, resource.TestCase{
@@ -22,9 +24,10 @@ func TestArmadaResourceArmadas(t *testing.T) {
CheckDestroy: testCheckArmadaArmadasDestroy(cs),
Steps: []resource.TestStep{
{
- Config: testArmadasResourceArmadasConfigBasic(name),
+ Config: testArmadasResourceArmadasConfigBasic(env, name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ec_armada_armada.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_armada_armada.test", "metadata.0.environment", env),
resource.TestCheckResourceAttr("ec_armada_armada.test", "spec.#", "1"),
resource.TestCheckResourceAttr("ec_armada_armada.test", "spec.0.description", "My Armada"),
resource.TestCheckResourceAttr("ec_armada_armada.test", "spec.0.region", "eu"),
@@ -40,9 +43,10 @@ func TestArmadaResourceArmadas(t *testing.T) {
),
},
{
- Config: testArmadasResourceArmadasConfigBasicWithEnv(name),
+ Config: testArmadasResourceArmadasConfigBasicWithEnv(env, name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ec_armada_armada.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_armada_armada.test", "metadata.0.environment", env),
resource.TestCheckResourceAttr("ec_armada_armada.test", "spec.#", "1"),
resource.TestCheckResourceAttr("ec_armada_armada.test", "spec.0.description", "My Armada"),
resource.TestCheckResourceAttr("ec_armada_armada.test", "spec.0.region", "eu"),
@@ -71,10 +75,11 @@ func TestArmadaResourceArmadas(t *testing.T) {
})
}
-func testArmadasResourceArmadasConfigBasic(name string) string {
+func testArmadasResourceArmadasConfigBasic(env, name string) string {
return fmt.Sprintf(`resource "ec_armada_armada" "test" {
metadata {
name = "%s"
+ environment = "%s"
}
spec {
description = "My Armada"
@@ -100,13 +105,14 @@ func testArmadasResourceArmadasConfigBasic(name string) string {
}
}
}
-}`, name)
+}`, name, env)
}
-func testArmadasResourceArmadasConfigBasicWithEnv(name string) string {
+func testArmadasResourceArmadasConfigBasicWithEnv(env, name string) string {
return fmt.Sprintf(`resource "ec_armada_armada" "test" {
metadata {
name = "%s"
+ environment = "%s"
}
spec {
description = "My Armada"
@@ -144,7 +150,7 @@ func testArmadasResourceArmadasConfigBasicWithEnv(name string) string {
}
}
}
-}`, name)
+}`, name, env)
}
func testCheckArmadaArmadasDestroy(cs clientset.Interface) func(s *terraform.State) error {
@@ -154,8 +160,8 @@ func testCheckArmadaArmadasDestroy(cs clientset.Interface) func(s *terraform.Sta
continue
}
- name := rs.Primary.ID
- resp, err := cs.ArmadaV1().Armadas().Get(context.Background(), name, metav1.GetOptions{})
+ env, name, _ := strings.Cut(rs.Primary.ID, "/")
+ resp, err := cs.ArmadaV1().Armadas(env).Get(context.Background(), name, metav1.GetOptions{})
if err == nil {
if resp.Name == rs.Primary.ID {
return fmt.Errorf("armada still exists: %s", rs.Primary.ID)
diff --git a/ec/armada/resource_armada_armadaset.go b/ec/armada/resource_armada_armadaset.go
index 5d14a7c..12186e4 100644
--- a/ec/armada/resource_armada_armadaset.go
+++ b/ec/armada/resource_armada_armadaset.go
@@ -5,10 +5,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec"
"github.com/nitrado/terraform-provider-ec/pkg/resource"
- armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/armada/v1"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
- "gitlab.com/nitrado/b2b/ec/armada/pkg/api/errors"
+ "gitlab.com/nitrado/b2b/ec/apicore/api/errors"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/armada/v1"
)
// ResourceArmadaArmadaSet returns the resource for an ArmadaSet.
@@ -27,14 +28,14 @@ func ResourceArmadaArmadaSet() *schema.Resource {
}
func resourceArmadaArmadaSetRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
- name := d.Id()
+ env, name := ec.SplitName(d.Id())
- obj, err := clientSet.ArmadaV1().ArmadaSets().Get(ctx, name, metav1.GetOptions{})
+ obj, err := clientSet.ArmadaV1().ArmadaSets(env).Get(ctx, name, metav1.GetOptions{})
if err != nil {
switch {
case errors.IsNotFound(err):
@@ -45,7 +46,7 @@ func resourceArmadaArmadaSetRead(ctx context.Context, d *schema.ResourceData, m
}
}
- data, err := converter().Flatten(obj, armadaSetSchema())
+ data, err := ec.Converter().Flatten(obj, armadaSetSchema())
if err != nil {
return diag.FromErr(err)
}
@@ -57,7 +58,7 @@ func resourceArmadaArmadaSetRead(ctx context.Context, d *schema.ResourceData, m
}
func resourceArmadaArmadaSetCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -65,24 +66,24 @@ func resourceArmadaArmadaSetCreate(ctx context.Context, d *schema.ResourceData,
obj := &armadav1.ArmadaSet{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "ArmadaSet"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
- out, err := clientSet.ArmadaV1().ArmadaSets().Create(ctx, obj, metav1.CreateOptions{})
+ out, err := clientSet.ArmadaV1().ArmadaSets(obj.Environment).Create(ctx, obj, metav1.CreateOptions{})
if err != nil {
return diag.FromErr(err)
}
- d.SetId(out.Name)
+ d.SetId(ec.ScopedName(out.Environment, out.Name))
return resourceArmadaArmadaSetRead(ctx, d, m)
}
func resourceArmadaArmadaSetUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -90,31 +91,31 @@ func resourceArmadaArmadaSetUpdate(ctx context.Context, d *schema.ResourceData,
obj := &armadav1.ArmadaSet{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "ArmadaSet"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
- out, err := clientSet.ArmadaV1().ArmadaSets().Update(ctx, obj, metav1.UpdateOptions{})
+ out, err := clientSet.ArmadaV1().ArmadaSets(obj.Environment).Update(ctx, obj, metav1.UpdateOptions{})
if err != nil {
return diag.FromErr(err)
}
- d.SetId(out.Name)
+ d.SetId(ec.ScopedName(out.Environment, out.Name))
return resourceArmadaArmadaSetRead(ctx, d, m)
}
func resourceArmadaArmadaSetDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
- name := d.Id()
+ env, name := ec.SplitName(d.Id())
- if err = clientSet.ArmadaV1().ArmadaSets().Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
+ if err = clientSet.ArmadaV1().ArmadaSets(env).Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
switch {
case errors.IsNotFound(err):
// We will consider this a successful delete.
diff --git a/ec/armada/resource_armada_armadaset_test.go b/ec/armada/resource_armada_armadaset_test.go
index 2fb1dfe..3eb1a43 100644
--- a/ec/armada/resource_armada_armadaset_test.go
+++ b/ec/armada/resource_armada_armadaset_test.go
@@ -3,17 +3,19 @@ package armada_test
import (
"context"
"fmt"
+ "strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
)
func TestArmadaResourceArmadaSets(t *testing.T) {
name := "my-armadaset"
+ env := "dflt"
pf, cs := providertest.SetupProviderFactories(t)
resource.Test(t, resource.TestCase{
@@ -22,9 +24,10 @@ func TestArmadaResourceArmadaSets(t *testing.T) {
CheckDestroy: testCheckArmadaArmadaSetsDestroy(cs),
Steps: []resource.TestStep{
{
- Config: testArmadasResourceArmadaSetsConfigBasic(name),
+ Config: testArmadasResourceArmadaSetsConfigBasic(env, name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_armada_armadaset.test", "metadata.0.environment", env),
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "spec.#", "1"),
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "spec.0.description", "My ArmadaSet"),
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "spec.0.armadas.0.region", "eu"),
@@ -40,9 +43,10 @@ func TestArmadaResourceArmadaSets(t *testing.T) {
),
},
{
- Config: testArmadasResourceArmadaSetsConfigBasicWithEnv(name),
+ Config: testArmadasResourceArmadaSetsConfigBasicWithEnv(env, name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_armada_armadaset.test", "metadata.0.environment", env),
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "spec.#", "1"),
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "spec.0.description", "My ArmadaSet"),
resource.TestCheckResourceAttr("ec_armada_armadaset.test", "spec.0.armadas.0.region", "eu"),
@@ -71,10 +75,11 @@ func TestArmadaResourceArmadaSets(t *testing.T) {
})
}
-func testArmadasResourceArmadaSetsConfigBasic(name string) string {
+func testArmadasResourceArmadaSetsConfigBasic(env, name string) string {
return fmt.Sprintf(`resource "ec_armada_armadaset" "test" {
metadata {
name = "%s"
+ environment = "%s"
}
spec {
description = "My ArmadaSet"
@@ -103,13 +108,14 @@ func testArmadasResourceArmadaSetsConfigBasic(name string) string {
}
}
}
-}`, name)
+}`, name, env)
}
-func testArmadasResourceArmadaSetsConfigBasicWithEnv(name string) string {
+func testArmadasResourceArmadaSetsConfigBasicWithEnv(env, name string) string {
return fmt.Sprintf(`resource "ec_armada_armadaset" "test" {
metadata {
name = "%s"
+ environment = "%s"
}
spec {
description = "My ArmadaSet"
@@ -150,7 +156,7 @@ func testArmadasResourceArmadaSetsConfigBasicWithEnv(name string) string {
}
}
}
-}`, name)
+}`, name, env)
}
func testCheckArmadaArmadaSetsDestroy(cs clientset.Interface) func(s *terraform.State) error {
@@ -160,8 +166,8 @@ func testCheckArmadaArmadaSetsDestroy(cs clientset.Interface) func(s *terraform.
continue
}
- name := rs.Primary.ID
- resp, err := cs.ArmadaV1().ArmadaSets().Get(context.Background(), name, metav1.GetOptions{})
+ env, name, _ := strings.Cut(rs.Primary.ID, "/")
+ resp, err := cs.ArmadaV1().ArmadaSets(env).Get(context.Background(), name, metav1.GetOptions{})
if err == nil {
if resp.Name == rs.Primary.ID {
return fmt.Errorf("armada set still exists: %s", rs.Primary.ID)
diff --git a/ec/armada/resource_armada_region.go b/ec/armada/resource_armada_region.go
index 118fa18..b9937de 100644
--- a/ec/armada/resource_armada_region.go
+++ b/ec/armada/resource_armada_region.go
@@ -5,10 +5,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec"
"github.com/nitrado/terraform-provider-ec/pkg/resource"
- armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/armada/v1"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
- "gitlab.com/nitrado/b2b/ec/armada/pkg/api/errors"
+ "gitlab.com/nitrado/b2b/ec/apicore/api/errors"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/armada/v1"
)
// ResourceArmadaRegion returns the resource for a Region.
@@ -27,14 +28,14 @@ func ResourceArmadaRegion() *schema.Resource {
}
func resourceArmadaRegionRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
- name := d.Id()
+ env, name := ec.SplitName(d.Id())
- obj, err := clientSet.ArmadaV1().Regions().Get(ctx, name, metav1.GetOptions{})
+ obj, err := clientSet.ArmadaV1().Regions(env).Get(ctx, name, metav1.GetOptions{})
if err != nil {
switch {
case errors.IsNotFound(err):
@@ -45,7 +46,7 @@ func resourceArmadaRegionRead(ctx context.Context, d *schema.ResourceData, m any
}
}
- data, err := converter().Flatten(obj, regionSchema())
+ data, err := ec.Converter().Flatten(obj, regionSchema())
if err != nil {
return diag.FromErr(err)
}
@@ -57,7 +58,7 @@ func resourceArmadaRegionRead(ctx context.Context, d *schema.ResourceData, m any
}
func resourceArmadaRegionCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -65,24 +66,24 @@ func resourceArmadaRegionCreate(ctx context.Context, d *schema.ResourceData, m a
obj := &armadav1.Region{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "Region"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
- out, err := clientSet.ArmadaV1().Regions().Create(ctx, obj, metav1.CreateOptions{})
+ out, err := clientSet.ArmadaV1().Regions(obj.Environment).Create(ctx, obj, metav1.CreateOptions{})
if err != nil {
return diag.FromErr(err)
}
- d.SetId(out.Name)
+ d.SetId(ec.ScopedName(out.Environment, out.Name))
return resourceArmadaRegionRead(ctx, d, m)
}
func resourceArmadaRegionUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -90,31 +91,31 @@ func resourceArmadaRegionUpdate(ctx context.Context, d *schema.ResourceData, m a
obj := &armadav1.Region{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "Region"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
- out, err := clientSet.ArmadaV1().Regions().Update(ctx, obj, metav1.UpdateOptions{})
+ out, err := clientSet.ArmadaV1().Regions(obj.Environment).Update(ctx, obj, metav1.UpdateOptions{})
if err != nil {
return diag.FromErr(err)
}
- d.SetId(out.Name)
+ d.SetId(ec.ScopedName(out.Environment, out.Name))
return resourceArmadaRegionRead(ctx, d, m)
}
func resourceArmadaRegionDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
- name := d.Id()
+ env, name := ec.SplitName(d.Id())
- if err = clientSet.ArmadaV1().Regions().Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
+ if err = clientSet.ArmadaV1().Regions(env).Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
switch {
case errors.IsNotFound(err):
// We will consider this a successful delete.
diff --git a/ec/armada/resource_armada_region_test.go b/ec/armada/resource_armada_region_test.go
index 18bd01c..afc0b64 100644
--- a/ec/armada/resource_armada_region_test.go
+++ b/ec/armada/resource_armada_region_test.go
@@ -3,17 +3,19 @@ package armada_test
import (
"context"
"fmt"
+ "strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
)
func TestArmadaResourceRegions(t *testing.T) {
name := "my-region"
+ env := "dflt"
pf, cs := providertest.SetupProviderFactories(t)
resource.Test(t, resource.TestCase{
@@ -22,9 +24,10 @@ func TestArmadaResourceRegions(t *testing.T) {
CheckDestroy: testCheckArmadaRegionDestroy(cs),
Steps: []resource.TestStep{
{
- Config: testArmadasResourceRegionsConfigBasic(name),
+ Config: testArmadasResourceRegionsConfigBasic(env, name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ec_armada_region.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_armada_region.test", "metadata.0.environment", env),
resource.TestCheckResourceAttr("ec_armada_region.test", "spec.#", "1"),
resource.TestCheckResourceAttr("ec_armada_region.test", "spec.0.description", "My Region"),
resource.TestCheckResourceAttr("ec_armada_region.test", "spec.0.types.#", "1"),
@@ -35,9 +38,10 @@ func TestArmadaResourceRegions(t *testing.T) {
),
},
{
- Config: testArmadasResourceRegionsConfigBasicWithEnv(name),
+ Config: testArmadasResourceRegionsConfigBasicWithEnv(env, name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("ec_armada_region.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_armada_region.test", "metadata.0.environment", env),
resource.TestCheckResourceAttr("ec_armada_region.test", "spec.#", "1"),
resource.TestCheckResourceAttr("ec_armada_region.test", "spec.0.description", "My Region"),
resource.TestCheckResourceAttr("ec_armada_region.test", "spec.0.types.#", "1"),
@@ -61,10 +65,11 @@ func TestArmadaResourceRegions(t *testing.T) {
})
}
-func testArmadasResourceRegionsConfigBasic(name string) string {
+func testArmadasResourceRegionsConfigBasic(env, name string) string {
return fmt.Sprintf(`resource "ec_armada_region" "test" {
metadata {
name = "%s"
+ environment = "%s"
}
spec {
description = "My Region"
@@ -73,13 +78,14 @@ func testArmadasResourceRegionsConfigBasic(name string) string {
sites = ["test-site-1", "test-site-2"]
}
}
-}`, name)
+}`, name, env)
}
-func testArmadasResourceRegionsConfigBasicWithEnv(name string) string {
+func testArmadasResourceRegionsConfigBasicWithEnv(env, name string) string {
return fmt.Sprintf(`resource "ec_armada_region" "test" {
metadata {
name = "%s"
+ environment = "%s"
}
spec {
description = "My Region"
@@ -102,7 +108,7 @@ func testArmadasResourceRegionsConfigBasicWithEnv(name string) string {
}
}
}
-}`, name)
+}`, name, env)
}
func testCheckArmadaRegionDestroy(cs clientset.Interface) func(s *terraform.State) error {
@@ -112,8 +118,8 @@ func testCheckArmadaRegionDestroy(cs clientset.Interface) func(s *terraform.Stat
continue
}
- name := rs.Primary.ID
- resp, err := cs.ArmadaV1().Regions().Get(context.Background(), name, metav1.GetOptions{})
+ env, name, _ := strings.Cut(rs.Primary.ID, "/")
+ resp, err := cs.ArmadaV1().Regions(env).Get(context.Background(), name, metav1.GetOptions{})
if err == nil {
if resp.Name == rs.Primary.ID {
return fmt.Errorf("region still exists: %s", rs.Primary.ID)
diff --git a/ec/armada/resource_armada_site.go b/ec/armada/resource_armada_site.go
index 8033997..d7e4b2b 100644
--- a/ec/armada/resource_armada_site.go
+++ b/ec/armada/resource_armada_site.go
@@ -5,10 +5,11 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec"
"github.com/nitrado/terraform-provider-ec/pkg/resource"
- armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/armada/v1"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
- "gitlab.com/nitrado/b2b/ec/armada/pkg/api/errors"
+ "gitlab.com/nitrado/b2b/ec/apicore/api/errors"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/armada/v1"
)
// ResourceArmadaSite returns the resource for a Site.
@@ -27,7 +28,7 @@ func ResourceArmadaSite() *schema.Resource {
}
func resourceArmadaSiteRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -45,7 +46,7 @@ func resourceArmadaSiteRead(ctx context.Context, d *schema.ResourceData, m any)
}
}
- data, err := converter().Flatten(obj, siteSchema())
+ data, err := ec.Converter().Flatten(obj, siteSchema())
if err != nil {
return diag.FromErr(err)
}
@@ -57,7 +58,7 @@ func resourceArmadaSiteRead(ctx context.Context, d *schema.ResourceData, m any)
}
func resourceArmadaSiteCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -65,10 +66,10 @@ func resourceArmadaSiteCreate(ctx context.Context, d *schema.ResourceData, m any
obj := &armadav1.Site{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "Site"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
@@ -82,7 +83,7 @@ func resourceArmadaSiteCreate(ctx context.Context, d *schema.ResourceData, m any
}
func resourceArmadaSiteUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -90,10 +91,10 @@ func resourceArmadaSiteUpdate(ctx context.Context, d *schema.ResourceData, m any
obj := &armadav1.Site{
TypeMeta: metav1.TypeMeta{APIVersion: armadav1.GroupVersion.String(), Kind: "Site"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
@@ -107,7 +108,7 @@ func resourceArmadaSiteUpdate(ctx context.Context, d *schema.ResourceData, m any
}
func resourceArmadaSiteDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
diff --git a/ec/armada/resource_armada_site_test.go b/ec/armada/resource_armada_site_test.go
index 0969d40..a957f5c 100644
--- a/ec/armada/resource_armada_site_test.go
+++ b/ec/armada/resource_armada_site_test.go
@@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
)
diff --git a/ec/armada/schema_armada.go b/ec/armada/schema_armada.go
index 6f81a65..09e5d69 100644
--- a/ec/armada/schema_armada.go
+++ b/ec/armada/schema_armada.go
@@ -2,7 +2,10 @@ package armada
// Code generated by schema-gen. DO NOT EDIT.
-import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
func armadaSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -11,7 +14,7 @@ func armadaSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
@@ -20,6 +23,31 @@ func armadaSchema() map[string]*schema.Schema {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
+ "autoscaling": {
+ Type: schema.TypeList,
+ Description: "AutoscalingInterval defines the autoscaling strategy.",
+ Optional: true,
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "fixed_interval": {
+ Type: schema.TypeList,
+ Description: "FixedInterval defines a fixed interval autoscaling strategy.",
+ Optional: true,
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "seconds": {
+ Type: schema.TypeInt,
+ Description: "Seconds defines how often the auto-scaler will re-evaluate the number of game servers.",
+ Optional: true,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
"description": {
Type: schema.TypeString,
Description: "Description is the optional description of the armada.",
@@ -71,7 +99,7 @@ func armadaSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
diff --git a/ec/armada/schema_armadaset.go b/ec/armada/schema_armadaset.go
index d307b42..d5d2bc4 100644
--- a/ec/armada/schema_armadaset.go
+++ b/ec/armada/schema_armadaset.go
@@ -2,7 +2,10 @@ package armada
// Code generated by schema-gen. DO NOT EDIT.
-import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
func armadaSetSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -11,7 +14,7 @@ func armadaSetSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
@@ -73,6 +76,31 @@ func armadaSetSchema() map[string]*schema.Schema {
},
},
},
+ "autoscaling": {
+ Type: schema.TypeList,
+ Description: "AutoscalingInterval defines the autoscaling strategy for all armadas.",
+ Optional: true,
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "fixed_interval": {
+ Type: schema.TypeList,
+ Description: "FixedInterval defines a fixed interval autoscaling strategy.",
+ Optional: true,
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "seconds": {
+ Type: schema.TypeInt,
+ Description: "Seconds defines how often the auto-scaler will re-evaluate the number of game servers.",
+ Optional: true,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
"description": {
Type: schema.TypeString,
Description: "Description is the optional description of the armada set.",
@@ -116,7 +144,7 @@ func armadaSetSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
diff --git a/ec/armada/schema_region.go b/ec/armada/schema_region.go
index 862b6d8..8511283 100644
--- a/ec/armada/schema_region.go
+++ b/ec/armada/schema_region.go
@@ -2,7 +2,10 @@ package armada
// Code generated by schema-gen. DO NOT EDIT.
-import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
func regionSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -11,7 +14,7 @@ func regionSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
diff --git a/ec/armada/schema_site.go b/ec/armada/schema_site.go
index 43ec767..e426414 100644
--- a/ec/armada/schema_site.go
+++ b/ec/armada/schema_site.go
@@ -2,7 +2,10 @@ package armada
// Code generated by schema-gen. DO NOT EDIT.
-import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
func siteSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -11,7 +14,7 @@ func siteSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
diff --git a/ec/armada/validators.go b/ec/armada/validators.go
deleted file mode 100644
index b335a23..0000000
--- a/ec/armada/validators.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package armada
-
-import (
- "fmt"
- "regexp"
-
- "github.com/hashicorp/go-cty/cty"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
-)
-
-const maxNameLength = 63
-
-var nameRegexp = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
-
-func validateName(value any, path cty.Path) (diags diag.Diagnostics) {
- v := value.(string)
-
- if !nameRegexp.MatchString(v) {
- diags = append(diags, diag.Diagnostic{
- Severity: diag.Error,
- Summary: `"` + v + `" is not a valid name`,
- AttributePath: path,
- },
- )
- }
- if len(v) > maxNameLength {
- diags = append(diags, diag.Diagnostic{
- Severity: diag.Error,
- Summary: fmt.Sprintf("%q must be no more than %d characters", v, maxNameLength),
- AttributePath: path,
- },
- )
- }
- return diags
-}
diff --git a/ec/armada/data_source_armada_branch.go b/ec/container/data_source_container_branch.go
similarity index 50%
rename from ec/armada/data_source_armada_branch.go
rename to ec/container/data_source_container_branch.go
index abe9b1f..6b21ffd 100644
--- a/ec/armada/data_source_armada_branch.go
+++ b/ec/container/data_source_container_branch.go
@@ -1,4 +1,4 @@
-package armada
+package container
import (
"context"
@@ -7,18 +7,18 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
-// DataSourceArmadaBranch returns the data source resource for a Branch.
-func DataSourceArmadaBranch() *schema.Resource {
+// DataSourceContainerBranch returns the data source resource for a Branch.
+func DataSourceContainerBranch() *schema.Resource {
return &schema.Resource{
Description: "Use this data source to access information about an existing Branch.",
- ReadContext: dataSourceArmadaBranchRead,
+ ReadContext: dataSourceContainerBranchRead,
Schema: branchSchema(),
}
}
-func dataSourceArmadaBranchRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+func dataSourceContainerBranchRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
name := d.Get("metadata.0.name").(string)
d.SetId(name)
- return resourceArmadaBranchRead(ctx, d, m)
+ return resourceContainerBranchRead(ctx, d, m)
}
diff --git a/ec/container/data_source_container_branch_test.go b/ec/container/data_source_container_branch_test.go
new file mode 100644
index 0000000..95717ee
--- /dev/null
+++ b/ec/container/data_source_container_branch_test.go
@@ -0,0 +1,59 @@
+package container_test
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
+)
+
+func TestArmadaDataSourceBranches(t *testing.T) {
+ name := "my-branch"
+ pf, _ := providertest.SetupProviderFactories(t)
+
+ resource.Test(t, resource.TestCase{
+ IsUnitTest: true,
+ ProviderFactories: pf,
+ Steps: []resource.TestStep{
+ {
+ Config: testContainerDataSourceBranchesConfigBasic(name),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr("ec_container_branch.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_container_branch.test", "spec.#", "1"),
+ resource.TestCheckResourceAttr("ec_container_branch.test", "spec.0.description", "My Branch"),
+ ),
+ },
+ {
+ Config: testContainerDataSourceBranchesConfigBasic(name) +
+ testContainerDataSourceBranchConfigRead(),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ec_container_branch.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("data.ec_container_branch.test", "spec.#", "1"),
+ resource.TestCheckResourceAttr("data.ec_container_branch.test", "spec.0.description", "My Branch"),
+ ),
+ },
+ },
+ })
+}
+
+func testContainerDataSourceBranchesConfigBasic(name string) string {
+ return fmt.Sprintf(`resource "ec_container_branch" "test" {
+ metadata {
+ name = "%s"
+ }
+ spec {
+ description = "My Branch"
+ }
+}
+`, name)
+}
+
+func testContainerDataSourceBranchConfigRead() string {
+ return `data "ec_container_branch" "test" {
+ metadata {
+ name = "${ec_container_branch.test.metadata.0.name}"
+ }
+}
+`
+}
diff --git a/ec/armada/resource_armada_branch.go b/ec/container/resource_container_branch.go
similarity index 54%
rename from ec/armada/resource_armada_branch.go
rename to ec/container/resource_container_branch.go
index 43630b0..8b336d8 100644
--- a/ec/armada/resource_armada_branch.go
+++ b/ec/container/resource_container_branch.go
@@ -1,24 +1,25 @@
-package armada
+package container
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec"
"github.com/nitrado/terraform-provider-ec/pkg/resource"
- containerv1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/container/v1"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
- "gitlab.com/nitrado/b2b/ec/armada/pkg/api/errors"
+ "gitlab.com/nitrado/b2b/ec/apicore/api/errors"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ containerv1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/container/v1"
)
-// ResourceArmadaBranch returns the resource for a Branch.
-func ResourceArmadaBranch() *schema.Resource {
+// ResourceContainerBranch returns the resource for a Branch.
+func ResourceContainerBranch() *schema.Resource {
return &schema.Resource{
Description: "A Branch groups container Images.",
- ReadContext: resourceArmadaBranchRead,
- CreateContext: resourceArmadaBranchCreate,
- UpdateContext: resourceArmadaBranchUpdate,
- DeleteContext: resourceArmadaBranchDelete,
+ ReadContext: resourceContainerBranchRead,
+ CreateContext: resourceContainerBranchCreate,
+ UpdateContext: resourceContainerBranchUpdate,
+ DeleteContext: resourceContainerBranchDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
@@ -26,8 +27,8 @@ func ResourceArmadaBranch() *schema.Resource {
}
}
-func resourceArmadaBranchRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+func resourceContainerBranchRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -45,7 +46,7 @@ func resourceArmadaBranchRead(ctx context.Context, d *schema.ResourceData, m any
}
}
- data, err := converter().Flatten(obj, branchSchema())
+ data, err := ec.Converter().Flatten(obj, branchSchema())
if err != nil {
return diag.FromErr(err)
}
@@ -56,8 +57,8 @@ func resourceArmadaBranchRead(ctx context.Context, d *schema.ResourceData, m any
return nil
}
-func resourceArmadaBranchCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+func resourceContainerBranchCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -65,10 +66,10 @@ func resourceArmadaBranchCreate(ctx context.Context, d *schema.ResourceData, m a
obj := &containerv1.Branch{
TypeMeta: metav1.TypeMeta{APIVersion: containerv1.GroupVersion.String(), Kind: "Branch"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
@@ -78,11 +79,11 @@ func resourceArmadaBranchCreate(ctx context.Context, d *schema.ResourceData, m a
}
d.SetId(out.Name)
- return resourceArmadaBranchRead(ctx, d, m)
+ return resourceContainerBranchRead(ctx, d, m)
}
-func resourceArmadaBranchUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+func resourceContainerBranchUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
@@ -90,10 +91,10 @@ func resourceArmadaBranchUpdate(ctx context.Context, d *schema.ResourceData, m a
obj := &containerv1.Branch{
TypeMeta: metav1.TypeMeta{APIVersion: containerv1.GroupVersion.String(), Kind: "Branch"},
}
- if err = converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
return diag.FromErr(err)
}
- if err = converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
return diag.FromErr(err)
}
@@ -103,11 +104,11 @@ func resourceArmadaBranchUpdate(ctx context.Context, d *schema.ResourceData, m a
}
d.SetId(out.Name)
- return resourceArmadaBranchRead(ctx, d, m)
+ return resourceContainerBranchRead(ctx, d, m)
}
-func resourceArmadaBranchDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
- clientSet, err := resolveClientSet(m)
+func resourceContainerBranchDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
if err != nil {
return diag.FromErr(err)
}
diff --git a/ec/armada/resource_armada_branch_test.go b/ec/container/resource_container_branch_test.go
similarity index 52%
rename from ec/armada/resource_armada_branch_test.go
rename to ec/container/resource_container_branch_test.go
index f02572a..f56809d 100644
--- a/ec/armada/resource_armada_branch_test.go
+++ b/ec/container/resource_container_branch_test.go
@@ -1,4 +1,4 @@
-package armada_test
+package container_test
import (
"context"
@@ -8,29 +8,29 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
)
-func TestArmadaResourceBranch(t *testing.T) {
+func TestContainerResourceBranch(t *testing.T) {
name := "my-branch"
pf, cs := providertest.SetupProviderFactories(t)
resource.Test(t, resource.TestCase{
IsUnitTest: true,
ProviderFactories: pf,
- CheckDestroy: testCheckArmadaBranchDestroy(cs),
+ CheckDestroy: testCheckContainerBranchDestroy(cs),
Steps: []resource.TestStep{
{
- Config: testArmadasResourceBranchesConfigBasic(name),
+ Config: testContainerResourceBranchesConfigBasic(name),
Check: resource.ComposeAggregateTestCheckFunc(
- resource.TestCheckResourceAttr("ec_armada_branch.test", "metadata.0.name", name),
- resource.TestCheckResourceAttr("ec_armada_branch.test", "spec.#", "1"),
- resource.TestCheckResourceAttr("ec_armada_branch.test", "spec.0.description", "My Branch"),
+ resource.TestCheckResourceAttr("ec_container_branch.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_container_branch.test", "spec.#", "1"),
+ resource.TestCheckResourceAttr("ec_container_branch.test", "spec.0.description", "My Branch"),
),
},
{
- ResourceName: "ec_armada_branch.test",
+ ResourceName: "ec_container_branch.test",
ImportState: true,
ImportStateVerify: true,
},
@@ -38,8 +38,8 @@ func TestArmadaResourceBranch(t *testing.T) {
})
}
-func testArmadasResourceBranchesConfigBasic(name string) string {
- return fmt.Sprintf(`resource "ec_armada_branch" "test" {
+func testContainerResourceBranchesConfigBasic(name string) string {
+ return fmt.Sprintf(`resource "ec_container_branch" "test" {
metadata {
name = "%s"
}
@@ -49,15 +49,15 @@ func testArmadasResourceBranchesConfigBasic(name string) string {
}`, name)
}
-func testCheckArmadaBranchDestroy(cs clientset.Interface) func(s *terraform.State) error {
+func testCheckContainerBranchDestroy(cs clientset.Interface) func(s *terraform.State) error {
return func(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
- if rs.Type != "ec_armada_branch" {
+ if rs.Type != "ec_container_branch" {
continue
}
name := rs.Primary.ID
- resp, err := cs.ArmadaV1().Regions().Get(context.Background(), name, metav1.GetOptions{})
+ resp, err := cs.ContainerV1().Branches().Get(context.Background(), name, metav1.GetOptions{})
if err == nil {
if resp.Name == rs.Primary.ID {
return fmt.Errorf("region still exists: %s", rs.Primary.ID)
diff --git a/ec/armada/schema_branch.go b/ec/container/schema_branch.go
similarity index 80%
rename from ec/armada/schema_branch.go
rename to ec/container/schema_branch.go
index 72f5349..ed0c062 100644
--- a/ec/armada/schema_branch.go
+++ b/ec/container/schema_branch.go
@@ -1,8 +1,11 @@
-package armada
+package container
// Code generated by schema-gen. DO NOT EDIT.
-import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
func branchSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -11,7 +14,7 @@ func branchSchema() map[string]*schema.Schema {
Description: "Standard object's metadata.",
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"spec": {
Type: schema.TypeList,
diff --git a/ec/core/data_source_core_environment.go b/ec/core/data_source_core_environment.go
new file mode 100644
index 0000000..92c709f
--- /dev/null
+++ b/ec/core/data_source_core_environment.go
@@ -0,0 +1,24 @@
+package core
+
+import (
+ "context"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+)
+
+// DataSourceCoreEnvironment returns the data source resource for an Environment.
+func DataSourceCoreEnvironment() *schema.Resource {
+ return &schema.Resource{
+ Description: "Use this data source to access information about an existing Environment.",
+ ReadContext: dataSourceCoreEnvironmentRead,
+ Schema: environmentSchema(),
+ }
+}
+
+func dataSourceCoreEnvironmentRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ name := d.Get("metadata.0.name").(string)
+ d.SetId(name)
+
+ return resourceCoreEnvironmentRead(ctx, d, m)
+}
diff --git a/ec/core/data_source_core_environment_test.go b/ec/core/data_source_core_environment_test.go
new file mode 100644
index 0000000..d2b08ec
--- /dev/null
+++ b/ec/core/data_source_core_environment_test.go
@@ -0,0 +1,62 @@
+package core_test
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
+)
+
+func TestCoreDataSourceEnvironments(t *testing.T) {
+ name := "dflt"
+ pf, _ := providertest.SetupProviderFactories(t)
+
+ resource.Test(t, resource.TestCase{
+ IsUnitTest: true,
+ ProviderFactories: pf,
+ Steps: []resource.TestStep{
+ {
+ Config: testCoreRDataSourceEnvironmentConfigBasic(name),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr("ec_core_environment.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_core_environment.test", "spec.#", "1"),
+ resource.TestCheckResourceAttr("ec_core_environment.test", "spec.0.display_name", "My Env"),
+ resource.TestCheckResourceAttr("ec_core_environment.test", "spec.0.description", "My Env Description"),
+ ),
+ },
+ {
+ Config: testCoreRDataSourceEnvironmentConfigBasic(name) +
+ testArmadaDataSourceSiteConfigRead(),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ec_core_environment.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("data.ec_core_environment.test", "spec.#", "1"),
+ resource.TestCheckResourceAttr("data.ec_core_environment.test", "spec.0.display_name", "My Env"),
+ resource.TestCheckResourceAttr("data.ec_core_environment.test", "spec.0.description", "My Env Description"),
+ ),
+ },
+ },
+ })
+}
+
+func testCoreRDataSourceEnvironmentConfigBasic(name string) string {
+ return fmt.Sprintf(`resource "ec_core_environment" "test" {
+ metadata {
+ name = "%s"
+ }
+ spec {
+ display_name = "My Env"
+ description = "My Env Description"
+ }
+}
+`, name)
+}
+
+func testArmadaDataSourceSiteConfigRead() string {
+ return `data "ec_core_environment" "test" {
+ metadata {
+ name = "${ec_core_environment.test.metadata.0.name}"
+ }
+}
+`
+}
diff --git a/ec/core/resource_core_environment.go b/ec/core/resource_core_environment.go
new file mode 100644
index 0000000..a897d0d
--- /dev/null
+++ b/ec/core/resource_core_environment.go
@@ -0,0 +1,125 @@
+package core
+
+import (
+ "context"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec"
+ "github.com/nitrado/terraform-provider-ec/pkg/resource"
+ "gitlab.com/nitrado/b2b/ec/apicore/api/errors"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ corev1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/core/v1"
+)
+
+// ResourceCoreEnvironment returns the resource for an Environment.
+func ResourceCoreEnvironment() *schema.Resource {
+ return &schema.Resource{
+ Description: "An Environment provides a mechanism to isolate groups of resources.",
+ ReadContext: resourceCoreEnvironmentRead,
+ CreateContext: resourceCoreEnvironmentCreate,
+ UpdateContext: resourceCoreEnvironmentUpdate,
+ DeleteContext: resourceCoreEnvironmentDelete,
+ Importer: &schema.ResourceImporter{
+ StateContext: schema.ImportStatePassthroughContext,
+ },
+ Schema: environmentSchema(),
+ }
+}
+
+func resourceCoreEnvironmentRead(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ name := d.Id()
+
+ obj, err := clientSet.CoreV1().Environments().Get(ctx, name, metav1.GetOptions{})
+ if err != nil {
+ switch {
+ case errors.IsNotFound(err):
+ d.SetId("")
+ return nil
+ default:
+ return diag.FromErr(err)
+ }
+ }
+
+ data, err := ec.Converter().Flatten(obj, environmentSchema())
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ if err = resource.SetData(d, data); err != nil {
+ return diag.FromErr(err)
+ }
+ return nil
+}
+
+func resourceCoreEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ obj := &corev1.Environment{}
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ return diag.FromErr(err)
+ }
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ return diag.FromErr(err)
+ }
+
+ out, err := clientSet.CoreV1().Environments().Create(ctx, obj, metav1.CreateOptions{})
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ d.SetId(out.Name)
+ return resourceCoreEnvironmentRead(ctx, d, m)
+}
+
+func resourceCoreEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ obj := &corev1.Environment{}
+ if err = ec.Converter().Expand(d.Get("metadata").([]any), &obj.ObjectMeta); err != nil {
+ return diag.FromErr(err)
+ }
+ if err = ec.Converter().Expand(d.Get("spec").([]any), &obj.Spec); err != nil {
+ return diag.FromErr(err)
+ }
+
+ out, err := clientSet.CoreV1().Environments().Update(ctx, obj, metav1.UpdateOptions{})
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ d.SetId(out.Name)
+ return resourceCoreEnvironmentRead(ctx, d, m)
+}
+
+func resourceCoreEnvironmentDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
+ clientSet, err := ec.ResolveClientSet(m)
+ if err != nil {
+ return diag.FromErr(err)
+ }
+
+ name := d.Id()
+
+ if err = clientSet.CoreV1().Environments().Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
+ switch {
+ case errors.IsNotFound(err):
+ // We will consider this a successful delete.
+ default:
+ return diag.FromErr(err)
+ }
+ }
+
+ d.SetId("")
+ return nil
+}
diff --git a/ec/core/resource_core_environment_test.go b/ec/core/resource_core_environment_test.go
new file mode 100644
index 0000000..4117dbc
--- /dev/null
+++ b/ec/core/resource_core_environment_test.go
@@ -0,0 +1,71 @@
+package core_test
+
+import (
+ "context"
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/nitrado/terraform-provider-ec/ec/provider/providertest"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
+ "gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
+)
+
+func TestCoreResourceEnvironments(t *testing.T) {
+ name := "dflt"
+ pf, cs := providertest.SetupProviderFactories(t)
+
+ resource.Test(t, resource.TestCase{
+ IsUnitTest: true,
+ ProviderFactories: pf,
+ CheckDestroy: testCheckCoreEnvironmentDestroy(cs),
+ Steps: []resource.TestStep{
+ {
+ Config: testCoreResourceEnvironmentConfigBasic(name),
+ Check: resource.ComposeAggregateTestCheckFunc(
+ resource.TestCheckResourceAttr("ec_core_environment.test", "metadata.0.name", name),
+ resource.TestCheckResourceAttr("ec_core_environment.test", "spec.#", "1"),
+ resource.TestCheckResourceAttr("ec_core_environment.test", "spec.0.display_name", "My Env"),
+ resource.TestCheckResourceAttr("ec_core_environment.test", "spec.0.description", "My Env Description"),
+ ),
+ },
+ {
+ ResourceName: "ec_core_environment.test",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
+
+func testCoreResourceEnvironmentConfigBasic(name string) string {
+ return fmt.Sprintf(`resource "ec_core_environment" "test" {
+ metadata {
+ name = "%s"
+ }
+ spec {
+ display_name = "My Env"
+ description = "My Env Description"
+ }
+}`, name)
+}
+
+func testCheckCoreEnvironmentDestroy(cs clientset.Interface) func(s *terraform.State) error {
+ return func(s *terraform.State) error {
+ for _, rs := range s.RootModule().Resources {
+ if rs.Type != "ec_core_environment" {
+ continue
+ }
+
+ name := rs.Primary.ID
+ resp, err := cs.CoreV1().Environments().Get(context.Background(), name, metav1.GetOptions{})
+ if err == nil {
+ if resp.Name == rs.Primary.ID {
+ return fmt.Errorf("Environment still exists: %s", rs.Primary.ID)
+ }
+ }
+ }
+ return nil
+ }
+}
diff --git a/ec/core/schema_environment.go b/ec/core/schema_environment.go
new file mode 100644
index 0000000..8360b85
--- /dev/null
+++ b/ec/core/schema_environment.go
@@ -0,0 +1,40 @@
+package core
+
+// Code generated by schema-gen. DO NOT EDIT.
+
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
+
+func environmentSchema() map[string]*schema.Schema {
+ return map[string]*schema.Schema{
+ "metadata": {
+ Type: schema.TypeList,
+ Description: "Standard object's metadata.",
+ Optional: true,
+ MaxItems: 1,
+ Elem: &schema.Resource{Schema: meta.Schema()},
+ },
+ "spec": {
+ Type: schema.TypeList,
+ Description: "Spec configures the environment.",
+ Optional: true,
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "description": {
+ Type: schema.TypeString,
+ Description: "Description is the description of the environment.",
+ Optional: true,
+ },
+ "display_name": {
+ Type: schema.TypeString,
+ Description: "DisplayName is friendly name of the environment.",
+ Optional: true,
+ },
+ },
+ },
+ },
+ }
+}
diff --git a/ec/ec.go b/ec/ec.go
new file mode 100644
index 0000000..339420c
--- /dev/null
+++ b/ec/ec.go
@@ -0,0 +1,54 @@
+package ec
+
+import (
+ "errors"
+ "strings"
+
+ "github.com/nitrado/tfconv"
+ "gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
+ "k8s.io/apimachinery/pkg/api/resource"
+)
+
+// ResolveClientSet resolves the ClientSet from the given context.
+func ResolveClientSet(m any) (clientset.Interface, error) {
+ clientSet, ok := m.(clientset.Interface)
+ if !ok {
+ return nil, errors.New("invalid clientset")
+ }
+ return clientSet, nil
+}
+
+// ScopedName returns the encoded name of an object.
+func ScopedName(env, name string) string {
+ if env != "" {
+ return env + "/" + name
+ }
+ return name
+}
+
+// SplitName decodes the key into its parts.
+func SplitName(key string) (env, name string) {
+ parts := strings.SplitN(key, "/", 2)
+ switch len(parts) {
+ case 1:
+ return "", parts[0]
+ default:
+ return parts[0], parts[1]
+ }
+}
+
+// Converter returns the configured converter.
+func Converter() *tfconv.Converter {
+ c := tfconv.New("json")
+ c.Register(resource.Quantity{}, expandQuantity, flattenQuantity)
+ return c
+}
+
+func expandQuantity(v any) (any, error) {
+ return resource.ParseQuantity(v.(string))
+}
+
+func flattenQuantity(v any) (any, error) {
+ q := v.(resource.Quantity)
+ return (&q).String(), nil
+}
diff --git a/ec/armada/schema_metadata.go b/ec/meta/schema_metadata.go
similarity index 74%
rename from ec/armada/schema_metadata.go
rename to ec/meta/schema_metadata.go
index 174cf45..3bca150 100644
--- a/ec/armada/schema_metadata.go
+++ b/ec/meta/schema_metadata.go
@@ -1,10 +1,11 @@
-package armada
+package meta
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
-func metadataSchema() map[string]*schema.Schema {
+// Schema is the common object metadata schema.
+func Schema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"annotations": {
Type: schema.TypeMap,
@@ -26,6 +27,14 @@ func metadataSchema() map[string]*schema.Schema {
Computed: true,
ValidateDiagFunc: validateName,
},
+ "environment": {
+ Type: schema.TypeString,
+ Description: "The name of the environment the object belongs to.",
+ Optional: true,
+ ForceNew: true,
+ Computed: true,
+ ValidateDiagFunc: validateEnvironment,
+ },
"revision": {
Type: schema.TypeString,
Description: "An opaque resource revision.",
diff --git a/ec/meta/validators.go b/ec/meta/validators.go
new file mode 100644
index 0000000..856bf7f
--- /dev/null
+++ b/ec/meta/validators.go
@@ -0,0 +1,59 @@
+package meta
+
+import (
+ "fmt"
+ "regexp"
+
+ "github.com/hashicorp/go-cty/cty"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+)
+
+const (
+ maxNameLength = 63
+ maxEnvironmentLength = 4
+)
+
+var (
+ nameRegexp = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
+ environmentRegexp = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
+)
+
+func validateName(value any, path cty.Path) (diags diag.Diagnostics) {
+ v := value.(string)
+
+ if len(v) > maxNameLength {
+ diags = append(diags, diag.Diagnostic{
+ Severity: diag.Error,
+ Summary: fmt.Sprintf("%q must be no more than %d characters", v, maxNameLength),
+ AttributePath: path,
+ })
+ }
+ if !nameRegexp.MatchString(v) {
+ diags = append(diags, diag.Diagnostic{
+ Severity: diag.Error,
+ Summary: `"` + v + `" is not a valid name`,
+ AttributePath: path,
+ })
+ }
+ return diags
+}
+
+func validateEnvironment(value any, path cty.Path) (diags diag.Diagnostics) {
+ v := value.(string)
+
+ if len(v) > maxEnvironmentLength {
+ diags = append(diags, diag.Diagnostic{
+ Severity: diag.Error,
+ Summary: fmt.Sprintf("%q must be no more than %d characters", v, maxNameLength),
+ AttributePath: path,
+ })
+ }
+ if !environmentRegexp.MatchString(v) {
+ diags = append(diags, diag.Diagnostic{
+ Severity: diag.Error,
+ Summary: `"` + v + `" is not a valid environment`,
+ AttributePath: path,
+ })
+ }
+ return diags
+}
diff --git a/ec/provider/provider.go b/ec/provider/provider.go
index 35230d9..eb49bda 100644
--- a/ec/provider/provider.go
+++ b/ec/provider/provider.go
@@ -8,6 +8,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/nitrado/terraform-provider-ec/ec/armada"
+ "github.com/nitrado/terraform-provider-ec/ec/container"
+ "github.com/nitrado/terraform-provider-ec/ec/core"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/rest"
"golang.org/x/oauth2"
@@ -64,8 +66,10 @@ func Provider() *schema.Provider {
"ec_armada_armada_v1": armada.DataSourceArmadaArmada(),
"ec_armada_armadaset": armada.DataSourceArmadaArmadaSet(),
"ec_armada_armadaset_v1": armada.DataSourceArmadaArmadaSet(),
- "ec_armada_branch": armada.DataSourceArmadaBranch(),
- "ec_armada_branch_v1": armada.DataSourceArmadaBranch(),
+ "ec_container_branch": container.DataSourceContainerBranch(),
+ "ec_container_branch_v1": container.DataSourceContainerBranch(),
+ "ec_core_environment": core.DataSourceCoreEnvironment(),
+ "ec_core_environment_v1": core.DataSourceCoreEnvironment(),
},
ResourcesMap: map[string]*schema.Resource{
"ec_armada_site": armada.ResourceArmadaSite(),
@@ -76,8 +80,10 @@ func Provider() *schema.Provider {
"ec_armada_armada_v1": armada.ResourceArmadaArmada(),
"ec_armada_armadaset": armada.ResourceArmadaArmadaSet(),
"ec_armada_armadaset_v1": armada.ResourceArmadaArmadaSet(),
- "ec_armada_branch": armada.ResourceArmadaBranch(),
- "ec_armada_branch_v1": armada.ResourceArmadaBranch(),
+ "ec_container_branch": container.ResourceContainerBranch(),
+ "ec_container_branch_v1": container.ResourceContainerBranch(),
+ "ec_core_environment": core.ResourceCoreEnvironment(),
+ "ec_core_environment_v1": core.ResourceCoreEnvironment(),
},
}
diff --git a/ec/provider/providertest/provider.go b/ec/provider/providertest/provider.go
index 7d927ec..df10a40 100644
--- a/ec/provider/providertest/provider.go
+++ b/ec/provider/providertest/provider.go
@@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/nitrado/terraform-provider-ec/ec/provider"
"github.com/stretchr/testify/require"
- "gitlab.com/nitrado/b2b/ec/armada/pkg/api/runtime"
+ "gitlab.com/nitrado/b2b/ec/apicore/runtime"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/clientset"
"gitlab.com/nitrado/b2b/ec/armada/pkg/apiclient/fake"
)
diff --git a/examples/resources/ec_armada_branch/resource.tf b/examples/resources/ec_container_branch/resource.tf
similarity index 72%
rename from examples/resources/ec_armada_branch/resource.tf
rename to examples/resources/ec_container_branch/resource.tf
index a2cdc21..5f8cf61 100644
--- a/examples/resources/ec_armada_branch/resource.tf
+++ b/examples/resources/ec_container_branch/resource.tf
@@ -1,4 +1,4 @@
-resource "ec_armada_branch" "test" {
+resource "ec_container_branch" "test" {
metadata {
name = "test"
}
diff --git a/examples/resources/ec_armada_branch_v1/resource.tf b/examples/resources/ec_container_branch_v1/resource.tf
similarity index 71%
rename from examples/resources/ec_armada_branch_v1/resource.tf
rename to examples/resources/ec_container_branch_v1/resource.tf
index ce916e2..345c4f1 100644
--- a/examples/resources/ec_armada_branch_v1/resource.tf
+++ b/examples/resources/ec_container_branch_v1/resource.tf
@@ -1,4 +1,4 @@
-resource "ec_armada_branch_v1" "test" {
+resource "ec_container_branch_v1" "test" {
metadata {
name = "test"
}
diff --git a/go.mod b/go.mod
index 90f6284..a5a577b 100644
--- a/go.mod
+++ b/go.mod
@@ -8,9 +8,10 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/nitrado/tfconv v1.0.0
github.com/stretchr/testify v1.8.4
- gitlab.com/nitrado/b2b/ec/armada v0.1.8
- golang.org/x/oauth2 v0.13.0
- k8s.io/apimachinery v0.28.2
+ gitlab.com/nitrado/b2b/ec/apicore v1.1.1-0.20231111140503-06bb4562d8df
+ gitlab.com/nitrado/b2b/ec/armada v0.1.11-0.20231122124408-441230c48346
+ golang.org/x/oauth2 v0.14.0
+ k8s.io/apimachinery v0.28.4
)
require (
@@ -29,7 +30,7 @@ require (
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
- github.com/go-logr/logr v1.2.4 // indirect
+ github.com/go-logr/logr v1.3.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
@@ -94,19 +95,19 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
- go.opentelemetry.io/otel v1.19.0 // indirect
- go.opentelemetry.io/otel/trace v1.19.0 // indirect
+ go.opentelemetry.io/otel v1.20.0 // indirect
+ go.opentelemetry.io/otel/trace v1.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.14.0 // indirect
+ golang.org/x/crypto v0.15.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
- golang.org/x/net v0.17.0 // indirect
- golang.org/x/sys v0.13.0 // indirect
- golang.org/x/text v0.13.0 // indirect
+ golang.org/x/net v0.18.0 // indirect
+ golang.org/x/sys v0.14.0 // indirect
+ golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
- google.golang.org/grpc v1.58.3 // indirect
+ google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
@@ -118,5 +119,5 @@ require (
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
- sigs.k8s.io/yaml v1.3.0 // indirect
+ sigs.k8s.io/yaml v1.4.0 // indirect
)
diff --git a/go.sum b/go.sum
index 30cc138..8492eb5 100644
--- a/go.sum
+++ b/go.sum
@@ -112,8 +112,8 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
-github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
+github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
@@ -394,18 +394,20 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
-gitlab.com/nitrado/b2b/ec/armada v0.1.8 h1:XCaE6XxVokp9WXzTwydCbemwlY5Hjs0/RS5X0x2rWw4=
-gitlab.com/nitrado/b2b/ec/armada v0.1.8/go.mod h1:xt9GVF8A8pKc9h9KxpwXN+gD/EI73ThkN/zEXraBibc=
+gitlab.com/nitrado/b2b/ec/apicore v1.1.1-0.20231111140503-06bb4562d8df h1:HYxVX/txUwuAeNhKZyqK/9SQ+2bDlXGev6oGUdEWRSM=
+gitlab.com/nitrado/b2b/ec/apicore v1.1.1-0.20231111140503-06bb4562d8df/go.mod h1:V0HMIH6/0eiT10nAaM+8NoL9W43Ne6S0SmaK+KV5qAg=
+gitlab.com/nitrado/b2b/ec/armada v0.1.11-0.20231122124408-441230c48346 h1:ilS0nl1knxeDxdKOidMZLrLd00VUIlPy2ms9ZnuiDO4=
+gitlab.com/nitrado/b2b/ec/armada v0.1.11-0.20231122124408-441230c48346/go.mod h1:pK/1F4yXSWxh2jszMHAOX027Yk8jMIMsZVoiDpSdc0M=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
-go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
-go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
-go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
-go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
+go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc=
+go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs=
+go.opentelemetry.io/otel/trace v1.20.0 h1:+yxVAPZPbQhbC3OfAkeIVTky6iTFpcr4SiY9om7mXSQ=
+go.opentelemetry.io/otel/trace v1.20.0/go.mod h1:HJSK7F/hA5RlzpZ0zKDCHCDHm556LCDtKaAo6JmBFUU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -420,8 +422,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
-golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
-golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
+golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
+golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -497,8 +499,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
-golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
-golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
+golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
+golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -510,6 +512,8 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
+golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
+golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -570,8 +574,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
-golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
+golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -589,8 +593,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
-golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
-golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
+golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -715,8 +719,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
-google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8=
-google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE=
+google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA=
+google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:CgAqfJo+Xmu0GwA0411Ht3OU3OntXwsGmrmjI8ioGXI=
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k=
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
@@ -737,8 +741,8 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
-google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
-google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
+google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
+google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -783,6 +787,8 @@ k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw=
k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg=
k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ=
k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU=
+k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8=
+k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg=
k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY=
k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
@@ -796,5 +802,5 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
-sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
-sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
+sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
+sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
diff --git a/internal/cmd/schema-gen/gen.go b/internal/cmd/schema-gen/gen.go
index 65f7d19..5faef79 100644
--- a/internal/cmd/schema-gen/gen.go
+++ b/internal/cmd/schema-gen/gen.go
@@ -6,6 +6,7 @@ import (
"go/format"
"html"
"reflect"
+ "strings"
"text/template"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -38,15 +39,24 @@ func (g *Generator) Generate(obj any, pkgName, fnName string) ([]byte, error) {
return nil, err
}
+ var needsMeta bool
+ for _, s := range fields {
+ if strings.Contains(s, "meta.") {
+ needsMeta = true
+ }
+ }
+
buf := &bytes.Buffer{}
err = fileTmpl.Execute(buf, struct {
- PkgName string
- FuncName string
- Fields map[string]string
+ PkgName string
+ FuncName string
+ Fields map[string]string
+ NeedsMeta bool
}{
- PkgName: pkgName,
- FuncName: fnName,
- Fields: fields,
+ PkgName: pkgName,
+ FuncName: fnName,
+ Fields: fields,
+ NeedsMeta: needsMeta,
})
if err != nil {
return nil, err
@@ -116,7 +126,7 @@ func (g *Generator) customize(obj any, sf *reflect.StructField, typ reflect.Type
case "resource.Quantity":
return "", reflect.String, true
case "v1.ObjectMeta":
- return "metadataSchema", kind, true
+ return "meta.Schema", kind, true
}
return "", kind, true
@@ -126,7 +136,14 @@ var fileTmpl = template.Must(template.New("code").Parse(`package {{.PkgName}}
// Code generated by schema-gen. DO NOT EDIT.
+{{ if .NeedsMeta }}
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
+{{- else }}
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+{{- end }}
func {{.FuncName}}() map[string]*schema.Schema {
return map[string]*schema.Schema{
diff --git a/internal/cmd/schema-gen/gen_test.go b/internal/cmd/schema-gen/gen_test.go
index 570c500..d47973d 100644
--- a/internal/cmd/schema-gen/gen_test.go
+++ b/internal/cmd/schema-gen/gen_test.go
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- metav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/meta/v1"
+ metav1 "gitlab.com/nitrado/b2b/ec/apicore/apis/meta/v1"
"k8s.io/apimachinery/pkg/api/resource"
)
diff --git a/internal/cmd/schema-gen/main.go b/internal/cmd/schema-gen/main.go
index c9d3541..1e31170 100644
--- a/internal/cmd/schema-gen/main.go
+++ b/internal/cmd/schema-gen/main.go
@@ -5,11 +5,13 @@ import (
"io"
"os"
- armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/armada/v1"
- containerv1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/apis/container/v1"
+ armadav1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/armada/v1"
+ containerv1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/container/v1"
+ corev1 "gitlab.com/nitrado/b2b/ec/armada/pkg/api/core/v1"
)
type objInfo struct {
+ Pkg string
Obj any
Filename string
FuncName string
@@ -17,40 +19,53 @@ type objInfo struct {
var objs = []objInfo{
{
+ Pkg: "armada",
Obj: armadav1.Resources{},
Filename: "ec/armada/schema_resources.go",
FuncName: "resourcesSchema",
},
{
+ Pkg: "armada",
Obj: armadav1.EnvVar{},
Filename: "ec/armada/schema_env.go",
FuncName: "envSchema",
},
{
+ Pkg: "armada",
Obj: &armadav1.Site{},
Filename: "ec/armada/schema_site.go",
FuncName: "siteSchema",
},
{
+ Pkg: "armada",
Obj: &armadav1.Region{},
Filename: "ec/armada/schema_region.go",
FuncName: "regionSchema",
},
{
+ Pkg: "armada",
Obj: &armadav1.Armada{},
Filename: "ec/armada/schema_armada.go",
FuncName: "armadaSchema",
},
{
+ Pkg: "armada",
Obj: &armadav1.ArmadaSet{},
Filename: "ec/armada/schema_armadaset.go",
FuncName: "armadaSetSchema",
},
{
+ Pkg: "container",
Obj: &containerv1.Branch{},
- Filename: "ec/armada/schema_branch.go",
+ Filename: "ec/container/schema_branch.go",
FuncName: "branchSchema",
},
+ {
+ Pkg: "core",
+ Obj: &corev1.Environment{},
+ Filename: "ec/core/schema_environment.go",
+ FuncName: "environmentSchema",
+ },
}
func main() {
@@ -66,7 +81,7 @@ func realMain(out io.Writer) int {
_ = os.Remove(info.Filename)
}
- b, err := gen.Generate(info.Obj, "armada", info.FuncName)
+ b, err := gen.Generate(info.Obj, info.Pkg, info.FuncName)
if err != nil {
_, _ = fmt.Fprintln(out, err.Error())
continue
diff --git a/internal/cmd/schema-gen/testdata/schema_testobject.go b/internal/cmd/schema-gen/testdata/schema_testobject.go
index 8d3b525..c0cb9c8 100644
--- a/internal/cmd/schema-gen/testdata/schema_testobject.go
+++ b/internal/cmd/schema-gen/testdata/schema_testobject.go
@@ -2,7 +2,10 @@ package testdata
// Code generated by schema-gen. DO NOT EDIT.
-import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+import (
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/nitrado/terraform-provider-ec/ec/meta"
+)
func testObjectSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
@@ -31,7 +34,7 @@ func testObjectSchema() map[string]*schema.Schema {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
- Elem: &schema.Resource{Schema: metadataSchema()},
+ Elem: &schema.Resource{Schema: meta.Schema()},
},
"slice": {
Type: schema.TypeList,