Skip to content

Commit

Permalink
Update K8s APIs reference to the version in the vendored lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishth09 committed Jun 5, 2017
1 parent 5d56830 commit 16ef37d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion builtin/providers/kubernetes/diff_supress_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions builtin/providers/kubernetes/resource_kubernetes_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions builtin/providers/kubernetes/resource_kubernetes_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions builtin/providers/kubernetes/structures_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions builtin/providers/kubernetes/structures_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions builtin/providers/kubernetes/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 16ef37d

Please sign in to comment.