From 6f69e3f24e84e1075fc49380257574ba2704e5df Mon Sep 17 00:00:00 2001 From: YannC Date: Thu, 19 Dec 2024 15:19:47 +0100 Subject: [PATCH 1/5] feat(): add missing resources + docs --- docs/resources/namespace.md | 6 + internal/provider/provider.go | 2 + internal/provider/resource_app.go | 109 ++++++++++++++++++ internal/provider/resource_app_test.go | 60 ++++++++++ internal/provider/resource_dashboard.go | 110 +++++++++++++++++++ internal/provider/resource_dashboard_test.go | 57 ++++++++++ 6 files changed, 344 insertions(+) create mode 100644 internal/provider/resource_app.go create mode 100644 internal/provider/resource_app_test.go create mode 100644 internal/provider/resource_dashboard.go create mode 100644 internal/provider/resource_dashboard_test.go diff --git a/docs/resources/namespace.md b/docs/resources/namespace.md index 77a617d..e20e866 100644 --- a/docs/resources/namespace.md +++ b/docs/resources/namespace.md @@ -44,6 +44,12 @@ EOT - `description` (String) The namespace friendly description. - `plugin_defaults` (String) The namespace plugin defaults in yaml string. - `variables` (String) The namespace variables in yaml string. +- `allowed_namespaces` (List of Object) The allowed namespaces. + - `namespace` (String) The allowed namespace. +- `storage_type` (String) The storage type. +- `storage_configuration` (Map of String) The storage configuration. +- `secret_type` (String) The secret type. +- `secret_configuration` (Map of String) The secret configuration. ### Read-Only diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f8320c4..755665c 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -118,6 +118,8 @@ func New(version string, tenant *string) func() *schema.Provider { "kestra_user_api_token": resourceUserApiToken(), "kestra_kv": resourceKv(), "kestra_worker_group": resourceWorkerGroup(), + "kestra_app": resourceApp(), + "kestra_dashboard": resourceDashboard(), }, } diff --git a/internal/provider/resource_app.go b/internal/provider/resource_app.go new file mode 100644 index 0000000..0985c67 --- /dev/null +++ b/internal/provider/resource_app.go @@ -0,0 +1,109 @@ +package provider + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "net/http" +) + +func resourceApp() *schema.Resource { + return &schema.Resource{ + Description: "Manages an App resource.", + + CreateContext: resourceAppCreate, + ReadContext: resourceAppRead, + UpdateContext: resourceAppUpdate, + DeleteContext: resourceAppDelete, + Schema: map[string]*schema.Schema{ + "source": { + Description: "The source text.", + Type: schema.TypeString, + Required: true, + }, + "uid": { + Description: "The unique identifier.", + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAppCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + c := meta.(*Client) + var diags diag.Diagnostics + + source := d.Get("source").(string) + + req, reqErr := c.yamlRequest("POST", fmt.Sprintf("%s/apps", apiRoot(c.TenantId)), &source) + if reqErr != nil { + return diag.FromErr(reqErr.Err) + } + + d.SetId(req.(map[string]interface{})["uid"].(string)) + return diags +} + +func resourceAppRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + c := meta.(*Client) + var diags diag.Diagnostics + + id := d.Id() + url := fmt.Sprintf("%s/apps/%s", apiRoot(c.TenantId), id) + + req, reqErr := c.yamlRequest("GET", url, nil) + if reqErr != nil { + if reqErr.StatusCode == http.StatusNotFound { + d.SetId("") + return diags + } + return diag.FromErr(reqErr.Err) + } + + response := req.(map[string]interface{}) + if err := d.Set("source", response["source"].(string)); err != nil { + return diag.FromErr(err) + } + if err := d.Set("uid", response["uid"].(string)); err != nil { + return diag.FromErr(err) + } + + return diags +} + +func resourceAppUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + c := meta.(*Client) + var diags diag.Diagnostics + + if d.HasChanges("source") { + uid := d.Id() + source := d.Get("source").(string) + url := fmt.Sprintf("%s/apps/%s", apiRoot(c.TenantId), uid) + + _, reqErr := c.yamlRequest("PUT", url, &source) + if reqErr != nil { + return diag.FromErr(reqErr.Err) + } + + return diags + } + return resourceAppRead(ctx, d, meta) +} + +func resourceAppDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + c := meta.(*Client) + var diags diag.Diagnostics + + uid := d.Id() + url := fmt.Sprintf("%s/apps/%s", apiRoot(c.TenantId), uid) + + _, reqErr := c.request("DELETE", url, nil) + if reqErr != nil { + return diag.FromErr(reqErr.Err) + } + + d.SetId("") + return diags +} diff --git a/internal/provider/resource_app_test.go b/internal/provider/resource_app_test.go new file mode 100644 index 0000000..cca4e5e --- /dev/null +++ b/internal/provider/resource_app_test.go @@ -0,0 +1,60 @@ +package provider + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccResourceApp(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: providerFactories, + Steps: []resource.TestStep{ + { + Config: testAccResourceApp("new"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("kestra_app.new", "id"), + ), + }, + }, + }) +} + +func testAccResourceApp(resourceId string) string { + return fmt.Sprintf( + ` + resource "kestra_flow" "new_flow" { + namespace = "company.team" + flow_id = "get_data" + content = < Date: Thu, 19 Dec 2024 15:47:28 +0100 Subject: [PATCH 2/5] chore(ci): update CI to use super admin kestra config --- .github/docker/application.yml | 4 ++ .github/workflows/test.yml | 28 +++++----- internal/provider/resource_app_test.go | 27 +++++----- internal/provider/resource_dashboard_test.go | 55 ++++++++++---------- 4 files changed, 59 insertions(+), 55 deletions(-) diff --git a/.github/docker/application.yml b/.github/docker/application.yml index 33bc581..4d834e3 100644 --- a/.github/docker/application.yml +++ b/.github/docker/application.yml @@ -1,4 +1,8 @@ kestra: + security: + super-admin: + username: root@root.com + password: Root!1234 encryption: secret-key: LWBErwwlb/BQcxWujsm+/scPeO01cTKzvW44GbAWvII= kafka: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6c06b1..9504ee6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,20 +76,20 @@ jobs: curl "127.27.27.27:9200" > /dev/null curl -X POST "127.27.27.27:8080/api/v1/users" > /dev/null - curl -u john@doe.com:pass -X POST -H 'Content-Type: application/json' -d '{"id":"unit_test","name":"Unit Test"}' "127.27.27.27:8080/api/v1/tenants" > /dev/null + curl -u root@root.com:Root!1234 -X POST -H 'Content-Type: application/json' -d '{"id":"unit_test","name":"Unit Test"}' "127.27.27.27:8080/api/v1/tenants" > /dev/null curl -H "Content-Type: application/x-ndjson" -XPOST "127.27.27.27:9200/_bulk?pretty" --data-binary @.github/workflows/index.jsonl sleep 3 - curl -H "Content-Type: multipart/form-data" -u john@doe.com:pass -X POST -F fileContent=@internal/resources/flow.py "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/files?path=/flow.py" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d '"stringValue"' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/string" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d '1' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/int" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d '1.5' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/double" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d 'false' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/falseBoolean" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d 'true' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/trueBoolean" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d '2022-05-01T03:02:01Z' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/dateTime" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d '2022-05-01' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/date" - curl -H "Content-Type: text/plain" -u john@doe.com:pass -X PUT -d 'P3DT3H2M1S' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/duration" - curl -H "Content-Type: application/json" -u john@doe.com:pass -X PUT -d '{"some":"value","in":"object"}' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/object" - curl -H "Content-Type: application/json" -u john@doe.com:pass -X PUT -d '[{"some":"value","in":"object"},{"yet":"another","array":"object"}]' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/array" + curl -H "Content-Type: multipart/form-data" -u root@root.com:Root!1234 -X POST -F fileContent=@internal/resources/flow.py "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/files?path=/flow.py" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d '"stringValue"' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/string" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d '1' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/int" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d '1.5' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/double" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d 'false' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/falseBoolean" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d 'true' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/trueBoolean" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d '2022-05-01T03:02:01Z' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/dateTime" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d '2022-05-01' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/date" + curl -H "Content-Type: text/plain" -u root@root.com:Root!1234 -X PUT -d 'P3DT3H2M1S' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/duration" + curl -H "Content-Type: application/json" -u root@root.com:Root!1234 -X PUT -d '{"some":"value","in":"object"}' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/object" + curl -H "Content-Type: application/json" -u root@root.com:Root!1234 -X PUT -d '[{"some":"value","in":"object"},{"yet":"another","array":"object"}]' "127.27.27.27:8080/api/v1/namespaces/io.kestra.terraform.data/kv/array" - name: Set up Go @@ -108,8 +108,8 @@ jobs: TF_ACC: "1" TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }} KESTRA_URL: "http://127.27.27.27:8080" - KESTRA_USERNAME: john@doe.com - KESTRA_PASSWORD: pass + KESTRA_USERNAME: root@root.com + KESTRA_PASSWORD: Root!1234 run: | go test -v -cover ./internal/provider/ diff --git a/internal/provider/resource_app_test.go b/internal/provider/resource_app_test.go index cca4e5e..7b3e509 100644 --- a/internal/provider/resource_app_test.go +++ b/internal/provider/resource_app_test.go @@ -25,9 +25,9 @@ func TestAccResourceApp(t *testing.T) { func testAccResourceApp(resourceId string) string { return fmt.Sprintf( ` - resource "kestra_flow" "new_flow" { - namespace = "company.team" - flow_id = "get_data" + resource "kestra_flow" "new_flow" { + namespace = "company.team" + flow_id = "get_data" content = < Date: Thu, 19 Dec 2024 16:51:26 +0100 Subject: [PATCH 3/5] feat(): doc from plugindocs --- docs/index.md | 3 --- docs/resources/app.md | 25 +++++++++++++++++++++++ docs/resources/dashboard.md | 24 ++++++++++++++++++++++ docs/resources/kv.md | 2 +- docs/resources/namespace.md | 34 +++++++++++++++++++++++-------- docs/resources/service_account.md | 2 +- docs/resources/user_api_token.md | 6 +++--- 7 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 docs/resources/app.md create mode 100644 docs/resources/dashboard.md diff --git a/docs/index.md b/docs/index.md index 7a5d802..ed76301 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,9 +17,6 @@ provider "kestra" { # mandatory, the Kestra webserver/standalone URL url = "http://localhost:8080" - # optional api token (EE) - api_token = "api-token-value" - # optional basic auth username username = "john" diff --git a/docs/resources/app.md b/docs/resources/app.md new file mode 100644 index 0000000..3256b0d --- /dev/null +++ b/docs/resources/app.md @@ -0,0 +1,25 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "kestra_app Resource - terraform-provider-kestra" +subcategory: "" +description: |- + Manages an App resource. +--- + +# kestra_app (Resource) + +Manages an App resource. + + + + +## Schema + +### Required + +- `source` (String) The source text. + +### Read-Only + +- `id` (String) The ID of this resource. +- `uid` (String) The unique identifier. diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md new file mode 100644 index 0000000..7decc50 --- /dev/null +++ b/docs/resources/dashboard.md @@ -0,0 +1,24 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "kestra_dashboard Resource - terraform-provider-kestra" +subcategory: "" +description: |- + Manages a Dashboard resource. +--- + +# kestra_dashboard (Resource) + +Manages a Dashboard resource. + + + + +## Schema + +### Required + +- `source_code` (String) The source code text. + +### Read-Only + +- `id` (String) The unique identifier. diff --git a/docs/resources/kv.md b/docs/resources/kv.md index e4dc244..47d7a84 100644 --- a/docs/resources/kv.md +++ b/docs/resources/kv.md @@ -8,7 +8,7 @@ description: |- # kestra_kv (Resource) -Manages a Kestra Namespace Key Value Store. +Manages a Kestra Namespace File. diff --git a/docs/resources/namespace.md b/docs/resources/namespace.md index e20e866..efca7ad 100644 --- a/docs/resources/namespace.md +++ b/docs/resources/namespace.md @@ -14,9 +14,9 @@ Manages a Kestra Namespace. ```terraform resource "kestra_namespace" "example" { - namespace_id = "company.team" - description = "Friendly description" - variables = < +### Nested Schema for `allowed_namespaces` + +Required: + +- `namespace` (String) The namespace. + + + +### Nested Schema for `worker_group` + +Required: + +- `fallback` (String) The fallback strategy. +- `key` (String) The worker group key. + ## Import Import is supported using the following syntax: diff --git a/docs/resources/service_account.md b/docs/resources/service_account.md index f6fc1bb..e249417 100644 --- a/docs/resources/service_account.md +++ b/docs/resources/service_account.md @@ -14,7 +14,7 @@ Manages a Kestra Service Account. ```terraform resource "kestra_service_account" "example" { - username = "my-service-account" + username = "my-service-account" description = "Friendly description" } ``` diff --git a/docs/resources/user_api_token.md b/docs/resources/user_api_token.md index cb636a1..d79d1a3 100644 --- a/docs/resources/user_api_token.md +++ b/docs/resources/user_api_token.md @@ -16,10 +16,10 @@ Manages a Kestra User Api Token. resource "kestra_user_api_token" "example" { user_id = "4by6NvSLcPXFhCj8nwbZOM" - name = "test-token" + name = "test-token" description = "Test token" - max_age = "PT1H" - extended = false + max_age = "PT1H" + extended = false } ``` From 249df1654c2009a2f7e80f32b3da3dc14876cd88 Mon Sep 17 00:00:00 2001 From: YannC Date: Fri, 20 Dec 2024 09:07:22 +0100 Subject: [PATCH 4/5] feat(): missing props in namespace and tenants --- docs/resources/tenant.md | 13 ++++++ internal/provider/resource_tenant.go | 48 +++++++++++++++++++++ internal/provider/utils_namespace.go | 22 ++++++++++ internal/provider/utils_tenant.go | 62 ++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+) diff --git a/docs/resources/tenant.md b/docs/resources/tenant.md index 62714f7..1996c25 100644 --- a/docs/resources/tenant.md +++ b/docs/resources/tenant.md @@ -29,11 +29,24 @@ resource "kestra_tenant" "example" { ### Optional - `name` (String) The tenant name. +- `secret_configuration` (Map of String) The secret configuration. +- `secret_type` (String) The secret type. +- `storage_configuration` (Map of String) The storage configuration. +- `storage_type` (String) The storage type. +- `worker_group` (Block List, Max: 1) The worker group. (see [below for nested schema](#nestedblock--worker_group)) ### Read-Only - `id` (String) The ID of this resource. + +### Nested Schema for `worker_group` + +Required: + +- `fallback` (String) The fallback strategy. +- `key` (String) The worker group key. + ## Import Import is supported using the following syntax: diff --git a/internal/provider/resource_tenant.go b/internal/provider/resource_tenant.go index 171c1d5..8a1b48c 100644 --- a/internal/provider/resource_tenant.go +++ b/internal/provider/resource_tenant.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "net/http" ) @@ -28,6 +29,53 @@ func resourceTenant() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "worker_group": { + Description: "The worker group.", + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Description: "The worker group key.", + Type: schema.TypeString, + Required: true, + }, + "fallback": { + Description: "The fallback strategy.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"FAIL", "WAIT", "CANCEL"}, false), + }, + }, + }, + }, + "storage_type": { + Description: "The storage type.", + Type: schema.TypeString, + Optional: true, + }, + "storage_configuration": { + Description: "The storage configuration.", + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "secret_type": { + Description: "The secret type.", + Type: schema.TypeString, + Optional: true, + }, + "secret_configuration": { + Description: "The secret configuration.", + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, }, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, diff --git a/internal/provider/utils_namespace.go b/internal/provider/utils_namespace.go index 2ddfeaf..7589aa3 100644 --- a/internal/provider/utils_namespace.go +++ b/internal/provider/utils_namespace.go @@ -35,6 +35,17 @@ func namespaceSchemaToApi(d *schema.ResourceData) (map[string]interface{}, error } body["allowedNamespaces"] = allowedNamespacesList + if workerGroup, ok := d.GetOk("worker_group"); ok { + workerGroupList := workerGroup.([]interface{}) + if len(workerGroupList) > 0 { + workerGroupMap := workerGroupList[0].(map[string]interface{}) + body["workerGroup"] = map[string]interface{}{ + "key": workerGroupMap["key"].(string), + "fallback": workerGroupMap["fallback"].(string), + } + } + } + if storageType := d.Get("storage_type").(string); storageType != "" { body["storageType"] = storageType } @@ -111,6 +122,17 @@ func namespaceApiToSchema(r map[string]interface{}, d *schema.ResourceData, c *C } } + if workerGroup, ok := r["workerGroup"].(map[string]interface{}); ok { + if err := d.Set("worker_group", []interface{}{ + map[string]interface{}{ + "key": workerGroup["key"].(string), + "fallback": workerGroup["fallback"].(string), + }, + }); err != nil { + return diag.FromErr(err) + } + } + if storageType, ok := r["storageType"].(string); ok { if err := d.Set("storage_type", storageType); err != nil { return diag.FromErr(err) diff --git a/internal/provider/utils_tenant.go b/internal/provider/utils_tenant.go index f9a1777..0c72ede 100644 --- a/internal/provider/utils_tenant.go +++ b/internal/provider/utils_tenant.go @@ -11,6 +11,33 @@ func tenantSchemaToApi(d *schema.ResourceData) (map[string]interface{}, error) { body["id"] = d.Get("tenant_id").(string) body["name"] = d.Get("name").(string) + if workerGroup, ok := d.GetOk("worker_group"); ok { + workerGroupList := workerGroup.([]interface{}) + if len(workerGroupList) > 0 { + workerGroupMap := workerGroupList[0].(map[string]interface{}) + body["workerGroup"] = map[string]interface{}{ + "key": workerGroupMap["key"].(string), + "fallback": workerGroupMap["fallback"].(string), + } + } + } + + if storageType := d.Get("storage_type").(string); storageType != "" { + body["storageType"] = storageType + } + + if storageConfiguration := d.Get("storage_configuration").(map[string]interface{}); len(storageConfiguration) > 0 { + body["storageConfiguration"] = storageConfiguration + } + + if secretType := d.Get("secret_type").(string); secretType != "" { + body["secretType"] = secretType + } + + if secretConfiguration := d.Get("secret_configuration").(map[string]interface{}); len(secretConfiguration) > 0 { + body["secretConfiguration"] = secretConfiguration + } + return body, nil } @@ -26,5 +53,40 @@ func tenantApiToSchema(r map[string]interface{}, d *schema.ResourceData) diag.Di return diag.FromErr(err) } + if workerGroup, ok := r["workerGroup"].(map[string]interface{}); ok { + if err := d.Set("worker_group", []interface{}{ + map[string]interface{}{ + "key": workerGroup["key"].(string), + "fallback": workerGroup["fallback"].(string), + }, + }); err != nil { + return diag.FromErr(err) + } + } + + if storageType, ok := r["storageType"].(string); ok { + if err := d.Set("storage_type", storageType); err != nil { + return diag.FromErr(err) + } + } + + if storageConfiguration, ok := r["storageConfiguration"].(map[string]interface{}); ok { + if err := d.Set("storage_configuration", storageConfiguration); err != nil { + return diag.FromErr(err) + } + } + + if secretType, ok := r["secretType"].(string); ok { + if err := d.Set("secret_type", secretType); err != nil { + return diag.FromErr(err) + } + } + + if secretConfiguration, ok := r["secretConfiguration"].(map[string]interface{}); ok { + if err := d.Set("secret_configuration", secretConfiguration); err != nil { + return diag.FromErr(err) + } + } + return diags } From 09b0f55dbae15ce94bf12b1453cb808d7be3174a Mon Sep 17 00:00:00 2001 From: YannC Date: Fri, 20 Dec 2024 09:08:44 +0100 Subject: [PATCH 5/5] feat(): make email mandatory for user resource as its now in kestra 0.20 --- docs/resources/user.md | 2 +- internal/provider/resource_user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/user.md b/docs/resources/user.md index 04f248e..606bc57 100644 --- a/docs/resources/user.md +++ b/docs/resources/user.md @@ -29,12 +29,12 @@ resource "kestra_user" "example" { ### Required +- `email` (String) The user email. - `username` (String) The user name. ### Optional - `description` (String) The user description. -- `email` (String) The user email. - `first_name` (String) The user first name. - `groups` (List of String) The user groups id. - `last_name` (String) The user last name. diff --git a/internal/provider/resource_user.go b/internal/provider/resource_user.go index a33350a..8925224 100644 --- a/internal/provider/resource_user.go +++ b/internal/provider/resource_user.go @@ -45,7 +45,7 @@ func resourceUser() *schema.Resource { "email": { Description: "The user email.", Type: schema.TypeString, - Optional: true, + Required: true, }, "groups": { Description: "The user groups id.",