Skip to content

Commit

Permalink
provider/kubernetes: Use PATCH to update namespace (#13114)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko authored Apr 10, 2017
1 parent 50b13c3 commit 81e184d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions builtin/providers/kubernetes/resource_kubernetes_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
pkgApi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
api "k8s.io/kubernetes/pkg/api/v1"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
Expand Down Expand Up @@ -69,15 +70,14 @@ func resourceKubernetesNamespaceRead(d *schema.ResourceData, meta interface{}) e
func resourceKubernetesNamespaceUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*kubernetes.Clientset)

metadata := expandMetadata(d.Get("metadata").([]interface{}))
// This is necessary in case the name is generated
metadata.Name = d.Id()

namespace := api.Namespace{
ObjectMeta: metadata,
ops := patchMetadata("metadata.0.", "/metadata/", d)
data, err := ops.MarshalJSON()
if err != nil {
return fmt.Errorf("Failed to marshal update operations: %s", err)
}
log.Printf("[INFO] Updating namespace: %#v", namespace)
out, err := conn.CoreV1().Namespaces().Update(&namespace)

log.Printf("[INFO] Updating namespace: %s", ops)
out, err := conn.CoreV1().Namespaces().Patch(d.Id(), pkgApi.JSONPatchType, data)
if err != nil {
return err
}
Expand Down

0 comments on commit 81e184d

Please sign in to comment.