Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Mar 15, 2021
1 parent 6a6022b commit cd7ec93
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions octopusdeploy/resource_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ func resourceVariable() *schema.Resource {
return &schema.Resource{
CreateContext: resourceVariableCreate,
DeleteContext: resourceVariableDelete,
Importer: &schema.ResourceImporter{
State: resourceVariableImport,
},
Importer: &schema.ResourceImporter{State: resourceVariableImport},
ReadContext: resourceVariableRead,
Schema: getVariableSchema(),
UpdateContext: resourceVariableUpdate,
Expand Down Expand Up @@ -50,24 +48,17 @@ func resourceVariableRead(ctx context.Context, d *schema.ResourceData, m interfa
if err != nil {
apiError := err.(*octopusdeploy.APIError)
if apiError.StatusCode == 404 {
log.Printf("[INFO] variable (%s) not found; deleting from state", d.Id())
d.SetId("")
return nil
}
return diag.FromErr(err)
}

d.Set("name", variable.Name)
d.Set("type", variable.Type)

isSensitive := d.Get("is_sensitive").(bool)
if isSensitive {
d.Set("value", nil)
} else {
d.Set("value", variable.Value)
if err := setVariable(ctx, d, variable); err != nil {
return diag.FromErr(err)
}

d.Set("description", variable.Description)

log.Printf("[INFO] variable read (%s)", d.Id())
return nil
}
Expand Down

0 comments on commit cd7ec93

Please sign in to comment.