Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Apr 22, 2024
1 parent f130903 commit ffb948c
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 18 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions example/cluster_data/main.tf

This file was deleted.

57 changes: 57 additions & 0 deletions example/stack/main.tf
Original file line number Diff line number Diff line change
@@ -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 = []
}
}
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func (p *PluralProvider) Resources(_ context.Context) []func() resource.Resource
r.NewProviderResource,
r.NewServiceDeploymentResource,
r.NewServiceContextResource,
r.NewInfrastructureStackResource,
}
}

Expand Down
6 changes: 4 additions & 2 deletions internal/resource/infrastructure_stack_schema.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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))},
Expand Down

0 comments on commit ffb948c

Please sign in to comment.