Skip to content

Commit

Permalink
chore(renaming): move taskDefaults to pluginDefaults
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier-p committed Jun 5, 2024
1 parent 565776f commit 346525a
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ data "kestra_namespace" "example" {

- `description` (String) The namespace friendly description.
- `id` (String) The ID of this resource.
- `task_defaults` (String) The namespace task defaults.
- `plugin_defaults` (String) The namespace plugin defaults.
- `tenant_id` (String) The tenant id.
- `variables` (String) The namespace variables.
2 changes: 1 addition & 1 deletion docs/resources/flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tasks:
message: first {{task.id}}
level: TRACE
taskDefaults:
pluginDefaults:
- type: io.kestra.core.tasks.log.Log
values:
message: third {{flow.id}}
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ k1: 1
k2:
v1: 1
EOT
task_defaults = <<EOT
plugin_defaults = <<EOT
- type: io.kestra.core.tasks.log.Log
values:
message: first {{flow.id}}
Expand All @@ -42,7 +42,7 @@ EOT
### Optional

- `description` (String) The namespace friendly description.
- `task_defaults` (String) The namespace task defaults in yaml string.
- `plugin_defaults` (String) The namespace plugin defaults in yaml string.
- `variables` (String) The namespace variables in yaml string.

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/kestra_flow/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks:
message: first {{task.id}}
level: TRACE
taskDefaults:
pluginDefaults:
- type: io.kestra.core.tasks.log.Log
values:
message: third {{flow.id}}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/kestra_namespace/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ k1: 1
k2:
v1: 1
EOT
task_defaults = <<EOT
plugin_defaults = <<EOT
- type: io.kestra.core.tasks.log.Log
values:
message: first {{flow.id}}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/data_source_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func dataSourceNamespace() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"task_defaults": {
Description: "The namespace task defaults.",
"plugin_defaults": {
Description: "The namespace plugin defaults.",
Type: schema.TypeString,
Computed: true,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestAccResourceFlow(t *testing.T) {
"namespace: io.kestra.terraform",
"tasks:",
" - ${indent(4, file(\"/tmp/unit-test/t1.yml\"))}",
"taskDefaults:",
"pluginDefaults:",
" - type: io.kestra.core.tasks.log.Log",
" values:",
" message: third {{flow.id}}",
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func resourceNamespace() *schema.Resource {
Optional: true,
DiffSuppressFunc: isYamlEquals,
},
"task_defaults": {
Description: "The namespace task defaults in yaml string.",
"plugin_defaults": {
Description: "The namespace plugin defaults in yaml string.",
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: isYamlEquals,
Expand Down Expand Up @@ -106,7 +106,7 @@ func resourceNamespaceUpdate(ctx context.Context, d *schema.ResourceData, meta i
c := meta.(*Client)
var diags diag.Diagnostics

if d.HasChanges("description", "variables", "task_defaults") {
if d.HasChanges("description", "variables", "plugin_defaults") {
body, err := namespaceSchemaToApi(d)
if err != nil {
return diag.FromErr(err)
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestAccResourceNamespace(t *testing.T) {
"kestra_namespace.new", "description", "My Kestra Namespace 2",
),
resource.TestMatchResourceAttr(
"kestra_namespace.new", "task_defaults", regexp.MustCompile(".*format: second.*"),
"kestra_namespace.new", "plugin_defaults", regexp.MustCompile(".*format: second.*"),
),
),
},
Expand All @@ -79,7 +79,7 @@ func TestAccResourceNamespace(t *testing.T) {
})
}

func testAccResourceNamespace(id, description, variables, taskDefaults string) string {
func testAccResourceNamespace(id, description, variables, pluginDefaults string) string {
return fmt.Sprintf(
`
resource "kestra_namespace" "new" {
Expand All @@ -88,13 +88,13 @@ func testAccResourceNamespace(id, description, variables, taskDefaults string) s
variables = <<EOT
%s
EOT
task_defaults = <<EOT
plugin_defaults = <<EOT
%s
EOT
}`,
id,
description,
variables,
taskDefaults,
pluginDefaults,
)
}
12 changes: 6 additions & 6 deletions internal/provider/utils_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func namespaceSchemaToApi(d *schema.ResourceData) (map[string]interface{}, error
}
body["variables"] = variables

var taskDefaults interface{}
err = yaml.Unmarshal([]byte(d.Get("task_defaults").(string)), &taskDefaults)
var pluginDefaults interface{}
err = yaml.Unmarshal([]byte(d.Get("plugin_defaults").(string)), &pluginDefaults)
if err != nil {
return nil, err
}
body["taskDefaults"] = taskDefaults
body["pluginDefaults"] = pluginDefaults

return body, nil
}
Expand Down Expand Up @@ -61,13 +61,13 @@ func namespaceApiToSchema(r map[string]interface{}, d *schema.ResourceData, c *C
}
}

if _, ok := r["taskDefaults"]; ok {
toYaml, err := toYaml(r["taskDefaults"].(interface{}))
if _, ok := r["pluginDefaults"]; ok {
toYaml, err := toYaml(r["pluginDefaults"].(interface{}))
if err != nil {
return diag.FromErr(err)
}

if err := d.Set("task_defaults", toYaml); err != nil {
if err := d.Set("plugin_defaults", toYaml); err != nil {
return diag.FromErr(err)
}
}
Expand Down

0 comments on commit 346525a

Please sign in to comment.