Skip to content

Commit

Permalink
better check for empty scope
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 committed Sep 4, 2024
1 parent ccec636 commit d9f761a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion octopusdeploy_framework/resource_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func validateVariable(variableSet *variables.VariableSet, newVariable *variables
}

func mapVariableToState(data *schemas.VariableTypeResourceModel, variable *variables.Variable) {
data.SpaceID = types.StringValue(variable.SpaceID)
data.Name = types.StringValue(variable.Name)
data.Description = types.StringValue(variable.Description)
if !data.IsEditable.IsNull() {
Expand All @@ -295,7 +296,9 @@ func mapVariableToState(data *schemas.VariableTypeResourceModel, variable *varia
)
}

if !data.Scope.IsNull() {
if variable.Scope.IsEmpty() {
data.Scope = types.ListNull(types.ObjectType{AttrTypes: schemas.VariableScopeObjectType()})
} else {
data.Scope = types.ListValueMust(
types.ObjectType{AttrTypes: schemas.VariableScopeObjectType()},
[]attr.Value{schemas.MapFromVariableScope(variable.Scope)},
Expand Down

0 comments on commit d9f761a

Please sign in to comment.