Skip to content

Commit

Permalink
Using PUT, not necessary to send empty containers
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewald committed Nov 14, 2023
1 parent ef9e4c1 commit 830ba02
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions stackpath/structure_compute_workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,24 @@ func convertComputeWorkloadContainers(prefix string, data *schema.ResourceData)
}

// Don't perform any actions when our list of containers hasn't changed at all
if data.HasChange("container") {
oldContainers, _ := data.GetChange(prefix)

// Now loop through all the bad containers and create a
// blank entry to have the API remove the container
for _, s := range oldContainers.([]interface{}) {
containerData := s.(map[string]interface{})
// When the container name was not seen in the new containers
// it means the container was removed from the definition and
// should be removed from the API.
if !containerNames[containerData["name"]] {
containers[containerData["name"].(string)] = workload_models.V1ContainerSpec{}
// NOTE: This is no longer needed in a world of PUT
/*
if data.HasChange("container") {
oldContainers, _ := data.GetChange(prefix)
// Now loop through all the bad containers and create a
// blank entry to have the API remove the container
for _, s := range oldContainers.([]interface{}) {
containerData := s.(map[string]interface{})
// When the container name was not seen in the new containers
// it means the container was removed from the definition and
// should be removed from the API.
if !containerNames[containerData["name"]] {
containers[containerData["name"].(string)] = workload_models.V1ContainerSpec{}
}
}
}
}
*/

return containers
}
Expand Down

0 comments on commit 830ba02

Please sign in to comment.