Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/kubernetes: Upgrade K8S to 1.6.1 #14923

Merged
merged 8 commits into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions builtin/providers/kubernetes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/go-homedir"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
)

func Provider() terraform.ResourceProvider {
Expand Down
13 changes: 7 additions & 6 deletions builtin/providers/kubernetes/resource_kubernetes_config_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"log"

"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 resourceKubernetesConfigMap() *schema.Resource {
Expand Down Expand Up @@ -57,7 +58,7 @@ func resourceKubernetesConfigMapRead(d *schema.ResourceData, meta interface{}) e

namespace, name := idParts(d.Id())
log.Printf("[INFO] Reading config map %s", name)
cfgMap, err := conn.CoreV1().ConfigMaps(namespace).Get(name)
cfgMap, err := conn.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{})
if err != nil {
log.Printf("[DEBUG] Received error: %#v", err)
return err
Expand Down Expand Up @@ -103,7 +104,7 @@ func resourceKubernetesConfigMapDelete(d *schema.ResourceData, meta interface{})

namespace, name := idParts(d.Id())
log.Printf("[INFO] Deleting config map: %#v", name)
err := conn.CoreV1().ConfigMaps(namespace).Delete(name, &api.DeleteOptions{})
err := conn.CoreV1().ConfigMaps(namespace).Delete(name, &metav1.DeleteOptions{})
if err != nil {
return err
}
Expand All @@ -119,7 +120,7 @@ func resourceKubernetesConfigMapExists(d *schema.ResourceData, meta interface{})

namespace, name := idParts(d.Id())
log.Printf("[INFO] Checking config map %s", name)
_, err := conn.CoreV1().ConfigMaps(namespace).Get(name)
_, err := conn.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return false, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
meta_v1 "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"
)

func TestAccKubernetesConfigMap_basic(t *testing.T) {
Expand Down Expand Up @@ -187,7 +188,7 @@ func testAccCheckKubernetesConfigMapDestroy(s *terraform.State) error {
continue
}
namespace, name := idParts(rs.Primary.ID)
resp, err := conn.CoreV1().ConfigMaps(namespace).Get(name)
resp, err := conn.CoreV1().ConfigMaps(namespace).Get(name, meta_v1.GetOptions{})
if err == nil {
if resp.Name == rs.Primary.ID {
return fmt.Errorf("Config Map still exists: %s", rs.Primary.ID)
Expand All @@ -207,7 +208,7 @@ func testAccCheckKubernetesConfigMapExists(n string, obj *api.ConfigMap) resourc

conn := testAccProvider.Meta().(*kubernetes.Clientset)
namespace, name := idParts(rs.Primary.ID)
out, err := conn.CoreV1().ConfigMaps(namespace).Get(name)
out, err := conn.CoreV1().ConfigMaps(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"log"

"github.com/hashicorp/terraform/helper/schema"
pkgApi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
api_v1 "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/apimachinery/pkg/api/errors"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgApi "k8s.io/apimachinery/pkg/types"
api "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
)

func resourceKubernetesHorizontalPodAutoscaler() *schema.Resource {
Expand Down Expand Up @@ -105,7 +105,7 @@ func resourceKubernetesHorizontalPodAutoscalerRead(d *schema.ResourceData, meta

namespace, name := idParts(d.Id())
log.Printf("[INFO] Reading horizontal pod autoscaler %s", name)
svc, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name)
svc, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
log.Printf("[DEBUG] Received error: %#v", err)
return err
Expand Down Expand Up @@ -156,7 +156,7 @@ func resourceKubernetesHorizontalPodAutoscalerDelete(d *schema.ResourceData, met

namespace, name := idParts(d.Id())
log.Printf("[INFO] Deleting horizontal pod autoscaler: %#v", name)
err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Delete(name, &api_v1.DeleteOptions{})
err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Delete(name, &meta_v1.DeleteOptions{})
if err != nil {
return err
}
Expand All @@ -172,7 +172,7 @@ func resourceKubernetesHorizontalPodAutoscalerExists(d *schema.ResourceData, met

namespace, name := idParts(d.Id())
log.Printf("[INFO] Checking horizontal pod autoscaler %s", name)
_, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name)
_, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return false, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
api "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
kubernetes "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
)

func TestAccKubernetesHorizontalPodAutoscaler_basic(t *testing.T) {
Expand Down Expand Up @@ -161,7 +162,7 @@ func testAccCheckKubernetesHorizontalPodAutoscalerDestroy(s *terraform.State) er
continue
}
namespace, name := idParts(rs.Primary.ID)
resp, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name)
resp, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name, meta_v1.GetOptions{})
if err == nil {
if resp.Namespace == namespace && resp.Name == name {
return fmt.Errorf("Horizontal Pod Autoscaler still exists: %s", rs.Primary.ID)
Expand All @@ -181,7 +182,7 @@ func testAccCheckKubernetesHorizontalPodAutoscalerExists(n string, obj *api.Hori

conn := testAccProvider.Meta().(*kubernetes.Clientset)
namespace, name := idParts(rs.Primary.ID)
out, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name)
out, err := conn.AutoscalingV1().HorizontalPodAutoscalers(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
return err
}
Expand Down
13 changes: 7 additions & 6 deletions builtin/providers/kubernetes/resource_kubernetes_limit_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"log"

"github.com/hashicorp/terraform/helper/schema"
pkgApi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
meta_v1 "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 resourceKubernetesLimitRange() *schema.Resource {
Expand Down Expand Up @@ -106,7 +107,7 @@ func resourceKubernetesLimitRangeRead(d *schema.ResourceData, meta interface{})

namespace, name := idParts(d.Id())
log.Printf("[INFO] Reading limit range %s", name)
limitRange, err := conn.CoreV1().LimitRanges(namespace).Get(name)
limitRange, err := conn.CoreV1().LimitRanges(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
log.Printf("[DEBUG] Received error: %#v", err)
return err
Expand Down Expand Up @@ -161,7 +162,7 @@ func resourceKubernetesLimitRangeDelete(d *schema.ResourceData, meta interface{}

namespace, name := idParts(d.Id())
log.Printf("[INFO] Deleting limit range: %#v", name)
err := conn.CoreV1().LimitRanges(namespace).Delete(name, &api.DeleteOptions{})
err := conn.CoreV1().LimitRanges(namespace).Delete(name, &meta_v1.DeleteOptions{})
if err != nil {
return err
}
Expand All @@ -177,7 +178,7 @@ func resourceKubernetesLimitRangeExists(d *schema.ResourceData, meta interface{}

namespace, name := idParts(d.Id())
log.Printf("[INFO] Checking limit range %s", name)
_, err := conn.CoreV1().LimitRanges(namespace).Get(name)
_, err := conn.CoreV1().LimitRanges(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return false, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
meta_v1 "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"
)

func TestAccKubernetesLimitRange_basic(t *testing.T) {
Expand Down Expand Up @@ -263,7 +264,7 @@ func testAccCheckKubernetesLimitRangeDestroy(s *terraform.State) error {
continue
}
namespace, name := idParts(rs.Primary.ID)
resp, err := conn.CoreV1().LimitRanges(namespace).Get(name)
resp, err := conn.CoreV1().LimitRanges(namespace).Get(name, meta_v1.GetOptions{})
if err == nil {
if resp.Namespace == namespace && resp.Name == name {
return fmt.Errorf("Limit Range still exists: %s", rs.Primary.ID)
Expand All @@ -283,7 +284,7 @@ func testAccCheckKubernetesLimitRangeExists(n string, obj *api.LimitRange) resou

conn := testAccProvider.Meta().(*kubernetes.Clientset)
namespace, name := idParts(rs.Primary.ID)
out, err := conn.CoreV1().LimitRanges(namespace).Get(name)
out, err := conn.CoreV1().LimitRanges(namespace).Get(name, meta_v1.GetOptions{})
if err != nil {
return err
}
Expand Down
15 changes: 8 additions & 7 deletions builtin/providers/kubernetes/resource_kubernetes_namespace.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"
meta_v1 "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 resourceKubernetesNamespace() *schema.Resource {
Expand Down Expand Up @@ -53,7 +54,7 @@ func resourceKubernetesNamespaceRead(d *schema.ResourceData, meta interface{}) e

name := d.Id()
log.Printf("[INFO] Reading namespace %s", name)
namespace, err := conn.CoreV1().Namespaces().Get(name)
namespace, err := conn.CoreV1().Namespaces().Get(name, meta_v1.GetOptions{})
if err != nil {
log.Printf("[DEBUG] Received error: %#v", err)
return err
Expand Down Expand Up @@ -92,7 +93,7 @@ func resourceKubernetesNamespaceDelete(d *schema.ResourceData, meta interface{})

name := d.Id()
log.Printf("[INFO] Deleting namespace: %#v", name)
err := conn.CoreV1().Namespaces().Delete(name, &api.DeleteOptions{})
err := conn.CoreV1().Namespaces().Delete(name, &meta_v1.DeleteOptions{})
if err != nil {
return err
}
Expand All @@ -102,7 +103,7 @@ func resourceKubernetesNamespaceDelete(d *schema.ResourceData, meta interface{})
Pending: []string{"Terminating"},
Timeout: 5 * time.Minute,
Refresh: func() (interface{}, string, error) {
out, err := conn.CoreV1().Namespaces().Get(name)
out, err := conn.CoreV1().Namespaces().Get(name, meta_v1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return nil, "", nil
Expand Down Expand Up @@ -131,7 +132,7 @@ func resourceKubernetesNamespaceExists(d *schema.ResourceData, meta interface{})

name := d.Id()
log.Printf("[INFO] Checking namespace %s", name)
_, err := conn.CoreV1().Namespaces().Get(name)
_, err := conn.CoreV1().Namespaces().Get(name, meta_v1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return false, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
meta_v1 "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"
)

func TestAccKubernetesNamespace_basic(t *testing.T) {
Expand Down Expand Up @@ -155,7 +156,7 @@ func TestAccKubernetesNamespace_importGeneratedName(t *testing.T) {
})
}

func testAccCheckMetaAnnotations(om *api.ObjectMeta, expected map[string]string) resource.TestCheckFunc {
func testAccCheckMetaAnnotations(om *meta_v1.ObjectMeta, expected map[string]string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if len(expected) == 0 && len(om.Annotations) == 0 {
return nil
Expand All @@ -168,7 +169,7 @@ func testAccCheckMetaAnnotations(om *api.ObjectMeta, expected map[string]string)
}
}

func testAccCheckMetaLabels(om *api.ObjectMeta, expected map[string]string) resource.TestCheckFunc {
func testAccCheckMetaLabels(om *meta_v1.ObjectMeta, expected map[string]string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if len(expected) == 0 && len(om.Labels) == 0 {
return nil
Expand All @@ -189,7 +190,7 @@ func testAccCheckKubernetesNamespaceDestroy(s *terraform.State) error {
continue
}

resp, err := conn.CoreV1().Namespaces().Get(rs.Primary.ID)
resp, err := conn.CoreV1().Namespaces().Get(rs.Primary.ID, meta_v1.GetOptions{})
if err == nil {
if resp.Name == rs.Primary.ID {
return fmt.Errorf("Namespace still exists: %s", rs.Primary.ID)
Expand All @@ -208,7 +209,7 @@ func testAccCheckKubernetesNamespaceExists(n string, obj *api.Namespace) resourc
}

conn := testAccProvider.Meta().(*kubernetes.Clientset)
out, err := conn.CoreV1().Namespaces().Get(rs.Primary.ID)
out, err := conn.CoreV1().Namespaces().Get(rs.Primary.ID, meta_v1.GetOptions{})
if err != nil {
return err
}
Expand Down
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"
meta_v1 "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 resourceKubernetesPersistentVolume() *schema.Resource {
Expand Down Expand Up @@ -91,7 +92,7 @@ func resourceKubernetesPersistentVolumeCreate(d *schema.ResourceData, meta inter
Pending: []string{"Pending"},
Timeout: 5 * time.Minute,
Refresh: func() (interface{}, string, error) {
out, err := conn.CoreV1().PersistentVolumes().Get(metadata.Name)
out, err := conn.CoreV1().PersistentVolumes().Get(metadata.Name, meta_v1.GetOptions{})
if err != nil {
log.Printf("[ERROR] Received error: %#v", err)
return out, "Error", err
Expand All @@ -118,7 +119,7 @@ func resourceKubernetesPersistentVolumeRead(d *schema.ResourceData, meta interfa

name := d.Id()
log.Printf("[INFO] Reading persistent volume %s", name)
volume, err := conn.CoreV1().PersistentVolumes().Get(name)
volume, err := conn.CoreV1().PersistentVolumes().Get(name, meta_v1.GetOptions{})
if err != nil {
log.Printf("[DEBUG] Received error: %#v", err)
return err
Expand Down Expand Up @@ -168,7 +169,7 @@ func resourceKubernetesPersistentVolumeDelete(d *schema.ResourceData, meta inter

name := d.Id()
log.Printf("[INFO] Deleting persistent volume: %#v", name)
err := conn.CoreV1().PersistentVolumes().Delete(name, &api.DeleteOptions{})
err := conn.CoreV1().PersistentVolumes().Delete(name, &meta_v1.DeleteOptions{})
if err != nil {
return err
}
Expand All @@ -184,7 +185,7 @@ func resourceKubernetesPersistentVolumeExists(d *schema.ResourceData, meta inter

name := d.Id()
log.Printf("[INFO] Checking persistent volume %s", name)
_, err := conn.CoreV1().PersistentVolumes().Get(name)
_, err := conn.CoreV1().PersistentVolumes().Get(name, meta_v1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return false, nil
Expand Down
Loading