Skip to content

Commit

Permalink
Merge pull request #22 from aeber/ee_add_pull
Browse files Browse the repository at this point in the history
Add pull parameter to awx_execution_environment
  • Loading branch information
josh-silvas authored Dec 4, 2024
2 parents b8f28c3 + e38b10d commit 856c441
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.2.1
v1.3.0
2 changes: 2 additions & 0 deletions docs/resources/execution_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "awx_execution_environment" "example" {
credential = awx_credential.example.id
description = "Example Execution Environment"
organization = awx_organization.example.id
pull = "always"
}
```

Expand All @@ -35,6 +36,7 @@ resource "awx_execution_environment" "example" {
- `credential` (String) The credential used to access the execution environment.
- `description` (String) The description of the execution environment.
- `organization` (String) The organization that the execution environment belongs to.
- `pull` (String) Pull image before running?

### Read-Only

Expand Down
1 change: 1 addition & 0 deletions examples/resources/awx_execution_environment/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ resource "awx_execution_environment" "example" {
credential = awx_credential.example.id
description = "Example Execution Environment"
organization = awx_organization.example.id
pull = "always"
}
13 changes: 13 additions & 0 deletions internal/awx/resource_execution_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"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"
awx "github.com/josh-silvas/terraform-provider-awx/tools/goawx"
"github.com/josh-silvas/terraform-provider-awx/tools/utils"
)
Expand Down Expand Up @@ -52,6 +53,13 @@ func resourceExecutionEnvironment() *schema.Resource {
Default: "",
Description: "The credential used to access the execution environment.",
},
"pull": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Pull image before running?",
ValidateFunc: validation.StringInSlice([]string{"", "always", "missing", "never"}, false),
},
},
}
}
Expand All @@ -67,6 +75,7 @@ func resourceExecutionEnvironmentsCreate(ctx context.Context, d *schema.Resource
"description": d.Get("description").(string),
"organization": utils.AtoiDefault(d.Get("organization").(string), nil),
"credential": utils.AtoiDefault(d.Get("credential").(string), nil),
"pull": d.Get("pull").(string),
}, map[string]string{})
if err != nil {
log.Printf("Fail to Create ExecutionEnvironment %v", err)
Expand Down Expand Up @@ -102,6 +111,7 @@ func resourceExecutionEnvironmentsUpdate(ctx context.Context, d *schema.Resource
"description": d.Get("description").(string),
"organization": utils.AtoiDefault(d.Get("organization").(string), nil),
"credential": utils.AtoiDefault(d.Get("credential").(string), nil),
"pull": d.Get("pull").(string),
}, map[string]string{}); err != nil {
return utils.DiagUpdate(diagExecutionEnvironmentTitle, id, err)
}
Expand Down Expand Up @@ -157,6 +167,9 @@ func setExecutionEnvironmentsResourceData(d *schema.ResourceData, r *awx.Executi
if err := d.Set("credential", r.Credential); err != nil {
fmt.Println("Error setting credential", err)
}
if err := d.Set("pull", r.Pull); err != nil {
fmt.Println("Error setting pull", err)
}
d.SetId(strconv.Itoa(r.ID))
return d
}

0 comments on commit 856c441

Please sign in to comment.