diff options
| author | Paul Kirkwood <paul.kirkwood@vodafone.com> | 2023-02-15 10:45:45 +0000 |
|---|---|---|
| committer | Paul Kirkwood <paul.kirkwood@vodafone.com> | 2023-02-15 10:45:45 +0000 |
| commit | b877a0c938642d865529a5233cc2dfabbbad85d0 (patch) | |
| tree | 88a7505b0fa89b9487da889608e799d6c3428c2e /azuredevops/internal/service/taskagent/resource_agentpool.go | |
| parent | 9ef9902a103a6cd78ed580cc4fd72ab65d579f6d (diff) | |
auto_update can only be set to true on create
Diffstat (limited to 'azuredevops/internal/service/taskagent/resource_agentpool.go')
| -rw-r--r-- | azuredevops/internal/service/taskagent/resource_agentpool.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/azuredevops/internal/service/taskagent/resource_agentpool.go b/azuredevops/internal/service/taskagent/resource_agentpool.go index 0cba6887..e5686a7d 100644 --- a/azuredevops/internal/service/taskagent/resource_agentpool.go +++ b/azuredevops/internal/service/taskagent/resource_agentpool.go @@ -49,7 +49,6 @@ func ResourceAgentPool() *schema.Resource { "auto_update": { Type: schema.TypeBool, Optional: true, - Default: false, }, }, } @@ -153,7 +152,10 @@ func flattenAzureAgentPool(d *schema.ResourceData, agentPool *taskagent.TaskAgen d.Set("name", converter.ToString(agentPool.Name, "")) d.Set("pool_type", *agentPool.PoolType) d.Set("auto_provision", *agentPool.AutoProvision) - d.Set("auto_update", *agentPool.AutoUpdate) + + if agentPool.AutoUpdate != nil { + d.Set("auto_update", *agentPool.AutoUpdate) + } } func expandAgentPool(d *schema.ResourceData, forCreate bool) (*taskagent.TaskAgentPool, error) { @@ -169,7 +171,13 @@ func expandAgentPool(d *schema.ResourceData, forCreate bool) (*taskagent.TaskAge Name: converter.String(d.Get("name").(string)), PoolType: &poolType, AutoProvision: converter.Bool(d.Get("auto_provision").(bool)), - AutoUpdate: converter.Bool(d.Get("auto_update").(bool)), + } + + if autoUpdate, ok := d.GetOk("auto_update"); ok { + if forCreate && !autoUpdate.(bool) { + return nil, fmt.Errorf("auto_update can only be set to true on create") + } + pool.AutoUpdate = converter.Bool(d.Get("auto_update").(bool)) } return pool, nil |
