From 16ef37dd6d5908f9d5c369e2a7fa5849921b402a Mon Sep 17 00:00:00 2001 From: Ashish K Thakur Date: Mon, 5 Jun 2017 12:00:25 +0530 Subject: [PATCH] Update K8s APIs reference to the version in the vendored lib --- builtin/providers/kubernetes/diff_supress_funcs.go | 2 +- .../providers/kubernetes/resource_kubernetes_pod.go | 13 +++++++------ .../kubernetes/resource_kubernetes_pod_test.go | 5 +++-- .../providers/kubernetes/structures_container.go | 7 ++++--- builtin/providers/kubernetes/structures_pod.go | 5 +++-- builtin/providers/kubernetes/validators.go | 2 -- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/builtin/providers/kubernetes/diff_supress_funcs.go b/builtin/providers/kubernetes/diff_supress_funcs.go index cc02e9b8dcd0..3c22a0764c4a 100644 --- a/builtin/providers/kubernetes/diff_supress_funcs.go +++ b/builtin/providers/kubernetes/diff_supress_funcs.go @@ -2,7 +2,7 @@ package kubernetes import ( "github.com/hashicorp/terraform/helper/schema" - "k8s.io/kubernetes/pkg/api/resource" + "k8s.io/apimachinery/pkg/api/resource" ) func suppressEquivalentResourceQuantity(k, old, new string, d *schema.ResourceData) bool { diff --git a/builtin/providers/kubernetes/resource_kubernetes_pod.go b/builtin/providers/kubernetes/resource_kubernetes_pod.go index e5c62a24bae3..245b3fef1e5b 100644 --- a/builtin/providers/kubernetes/resource_kubernetes_pod.go +++ b/builtin/providers/kubernetes/resource_kubernetes_pod.go @@ -7,10 +7,11 @@ 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" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + pkgApi "k8s.io/apimachinery/pkg/types" api "k8s.io/kubernetes/pkg/api/v1" - kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5" + kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" ) func resourceKubernetesPod() *schema.Resource { @@ -66,7 +67,7 @@ func resourceKubernetesPodCreate(d *schema.ResourceData, meta interface{}) error Pending: []string{"Pending"}, Timeout: 5 * time.Minute, Refresh: func() (interface{}, string, error) { - out, err := conn.CoreV1().Pods(metadata.Namespace).Get(metadata.Name) + out, err := conn.CoreV1().Pods(metadata.Namespace).Get(metadata.Name, metav1.GetOptions{}) if err != nil { log.Printf("[ERROR] Received error: %#v", err) return out, "Error", err @@ -119,7 +120,7 @@ func resourceKubernetesPodRead(d *schema.ResourceData, meta interface{}) error { namespace, name := idParts(d.Id()) log.Printf("[INFO] Reading pod %s", name) - pod, err := conn.CoreV1().Pods(namespace).Get(name) + pod, err := conn.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{}) if err != nil { log.Printf("[DEBUG] Received error: %#v", err) return err @@ -164,7 +165,7 @@ func resourceKubernetesPodExists(d *schema.ResourceData, meta interface{}) (bool namespace, name := idParts(d.Id()) log.Printf("[INFO] Checking pod %s", name) - _, err := conn.CoreV1().Pods(namespace).Get(name) + _, err := conn.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{}) if err != nil { if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 { return false, nil diff --git a/builtin/providers/kubernetes/resource_kubernetes_pod_test.go b/builtin/providers/kubernetes/resource_kubernetes_pod_test.go index c46164cd5950..2315847b6de9 100644 --- a/builtin/providers/kubernetes/resource_kubernetes_pod_test.go +++ b/builtin/providers/kubernetes/resource_kubernetes_pod_test.go @@ -4,8 +4,9 @@ import ( "fmt" "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" api "k8s.io/kubernetes/pkg/api/v1" - kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5" + kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" @@ -297,7 +298,7 @@ func testAccCheckKubernetesPodExists(n string, obj *api.Pod) resource.TestCheckF conn := testAccProvider.Meta().(*kubernetes.Clientset) namespace, name := idParts(rs.Primary.ID) - out, err := conn.CoreV1().Pods(namespace).Get(name) + out, err := conn.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{}) if err != nil { return err } diff --git a/builtin/providers/kubernetes/structures_container.go b/builtin/providers/kubernetes/structures_container.go index f7d268aeca45..64c950f5057d 100644 --- a/builtin/providers/kubernetes/structures_container.go +++ b/builtin/providers/kubernetes/structures_container.go @@ -4,9 +4,10 @@ import ( "strconv" "strings" + meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/kubernetes/pkg/api/v1" - kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5" - "k8s.io/kubernetes/pkg/util/intstr" + kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" ) func flattenCapability(in []v1.Capability) []string { @@ -238,7 +239,7 @@ func flattenValueFrom(in *v1.EnvVarSource) []interface{} { } func flattenContainerVolumeMounts(in []v1.VolumeMount, conn *kubernetes.Clientset, namespace string) ([]interface{}, error) { - secretList, err := conn.CoreV1().Secrets(namespace).List(v1.ListOptions{}) + secretList, err := conn.CoreV1().Secrets(namespace).List(meta_v1.ListOptions{}) if err != nil { return nil, err } diff --git a/builtin/providers/kubernetes/structures_pod.go b/builtin/providers/kubernetes/structures_pod.go index 89229ee2605e..988511f5e0ee 100644 --- a/builtin/providers/kubernetes/structures_pod.go +++ b/builtin/providers/kubernetes/structures_pod.go @@ -5,8 +5,9 @@ import ( "strings" "github.com/hashicorp/terraform/helper/schema" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/api/v1" - kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5" + kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" ) // Flatteners @@ -120,7 +121,7 @@ func flattenSeLinuxOptions(in *v1.SELinuxOptions) []interface{} { //volumes excludes the ones internal to k8s func flattenVolumes(volumes []v1.Volume, conn *kubernetes.Clientset, namespace string) ([]interface{}, error) { - secretList, err := conn.CoreV1().Secrets(namespace).List(v1.ListOptions{}) + secretList, err := conn.CoreV1().Secrets(namespace).List(metav1.ListOptions{}) if err != nil { return nil, err } diff --git a/builtin/providers/kubernetes/validators.go b/builtin/providers/kubernetes/validators.go index 458142ecba77..03dd2cf55586 100644 --- a/builtin/providers/kubernetes/validators.go +++ b/builtin/providers/kubernetes/validators.go @@ -5,13 +5,11 @@ import ( "strconv" "strings" - "github.com/hashicorp/terraform/helper/schema" "k8s.io/apimachinery/pkg/api/resource" apiValidation "k8s.io/apimachinery/pkg/api/validation" utilValidation "k8s.io/apimachinery/pkg/util/validation" - ) func validateAnnotations(value interface{}, key string) (ws []string, es []error) {