diff --git a/example/aws/main.tf b/example/cluster/aws/main.tf similarity index 100% rename from example/aws/main.tf rename to example/cluster/aws/main.tf diff --git a/example/azure/main.tf b/example/cluster/azure/main.tf similarity index 100% rename from example/azure/main.tf rename to example/cluster/azure/main.tf diff --git a/example/byok/main.tf b/example/cluster/byok/main.tf similarity index 100% rename from example/byok/main.tf rename to example/cluster/byok/main.tf diff --git a/example/gcp/main.tf b/example/cluster/gcp/main.tf similarity index 100% rename from example/gcp/main.tf rename to example/cluster/gcp/main.tf diff --git a/example/cluster_data/main.tf b/example/cluster_data/main.tf deleted file mode 100644 index 01c6f19..0000000 --- a/example/cluster_data/main.tf +++ /dev/null @@ -1,16 +0,0 @@ -terraform { - required_providers { - plural = { - source = "pluralsh/plural" - version = "0.0.1" - } - } -} - -provider "plural" { - use_cli = true -} - -data "plural_cluster" "cluster" { - handle = "mgmt" -} \ No newline at end of file diff --git a/example/stack/main.tf b/example/stack/main.tf new file mode 100644 index 0000000..24f16b2 --- /dev/null +++ b/example/stack/main.tf @@ -0,0 +1,57 @@ +terraform { + required_providers { + plural = { + source = "pluralsh/plural" + version = "0.0.1" + } + } +} + +provider "plural" { + use_cli = true +} + +data "plural_cluster" "cluster" { + handle = "mgmt" +} + +data "plural_git_repository" "repository" { + url = "https://github.com/zreigz/tf-hello.git" +} + +resource "plural_infrastructure_stack" "stack" { + name = "tf-stack" + type = "TERRAFORM" + # approval = false + cluster_id = data.plural_cluster.cluster.id + repository = { + id = data.plural_git_repository.repository.id + ref = "main" + folder = "terraform" + } + configuration = { + # image = "" + version = "1.5.7" + } + # files = {} + environment = [ + { + name = "USERNAME" + value = "joe" + }, + { + name = "PASSWORD" + value = "test" + secret = true + } + ] + job_spec = { + namespace = "default" + # raw = "" + # ... + } + bindings = { + read = [] + write = [] + } +} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 3dd3ae4..0bb22fb 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -184,6 +184,7 @@ func (p *PluralProvider) Resources(_ context.Context) []func() resource.Resource r.NewProviderResource, r.NewServiceDeploymentResource, r.NewServiceContextResource, + r.NewInfrastructureStackResource, } } diff --git a/internal/resource/infrastructure_stack_schema.go b/internal/resource/infrastructure_stack_schema.go index 2241452..244b275 100644 --- a/internal/resource/infrastructure_stack_schema.go +++ b/internal/resource/infrastructure_stack_schema.go @@ -1,6 +1,8 @@ package resource import ( + "fmt" + "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" @@ -30,8 +32,8 @@ func (r *InfrastructureStackResource) schema() schema.Schema { PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}, }, "type": schema.StringAttribute{ - Description: "A type for the stack, specifies the tool to use to apply it.", - MarkdownDescription: "A type for the stack, specifies the tool to use to apply it.", + Description: fmt.Sprintf("A type for the stack, specifies the tool to use to apply it. Allowed values include \"%s\" and \"%s\".", gqlclient.StackTypeAnsible, gqlclient.StackTypeTerraform), + MarkdownDescription: fmt.Sprintf("A type for the stack, specifies the tool to use to apply it. Allowed values include `%s` and `%s`.", gqlclient.StackTypeAnsible, gqlclient.StackTypeTerraform), Required: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}, Validators: []validator.String{stringvalidator.OneOf(string(gqlclient.StackTypeAnsible), string(gqlclient.StackTypeTerraform))},