From c19d9dc008304e5e0c65ca48d3109e8fa3f771d6 Mon Sep 17 00:00:00 2001 From: Eric Chiang Date: Sun, 26 Mar 2017 20:25:43 -0700 Subject: [PATCH] *: update all to use new meta/v1 package --- README.md | 5 +++-- client_test.go | 11 ++++++----- examples/create-resource.go | 3 ++- tprs_test.go | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9cd14af..9df62e4 100644 --- a/README.md +++ b/README.md @@ -76,11 +76,12 @@ import ( "github.com/ericchiang/k8s" "github.com/ericchiang/k8s/api/v1" + metav1 "github.com/ericchiang/k8s/apis/meta/v1" ) func createConfigMap(client *k8s.Client, name string, values map[string]string) error { cm := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: &name, Namespace: &client.Namespace, }, @@ -134,7 +135,7 @@ Errors returned by the Kubernetes API are formatted as [`unversioned.Status`][un // exists. func createConfigMap(client *k8s.Client, name string, values map[string]string) error { cm := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: &name, Namespace: &client.Namespace, }, diff --git a/client_test.go b/client_test.go index 7aabd32..fa9b302 100644 --- a/client_test.go +++ b/client_test.go @@ -14,6 +14,7 @@ import ( "testing" "github.com/ericchiang/k8s/api/v1" + metav1 "github.com/ericchiang/k8s/apis/meta/v1" ) const skipMsg = ` @@ -98,7 +99,7 @@ func TestConfigMaps(t *testing.T) { labelVal := newName() cm := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: String(name), Namespace: String("default"), Labels: map[string]string{ @@ -162,7 +163,7 @@ func TestWatch(t *testing.T) { labelVal := newName() cm := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: String(name), Namespace: String("default"), Labels: map[string]string{ @@ -273,7 +274,7 @@ func TestWatchNamespace(t *testing.T) { // Create a configmap in the default namespace so the "default" watch has something to return defaultCM := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: String(defaultName), Namespace: String("default"), Labels: map[string]string{ @@ -291,7 +292,7 @@ func TestWatchNamespace(t *testing.T) { // Create a non-default Namespace ns := &v1.Namespace{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: String(nonDefaultNamespaceName), }, } @@ -301,7 +302,7 @@ func TestWatchNamespace(t *testing.T) { // Create a configmap in the non-default namespace nonDefaultCM := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: String(name), Namespace: String(nonDefaultNamespaceName), Labels: map[string]string{ diff --git a/examples/create-resource.go b/examples/create-resource.go index c91ed3a..f454184 100644 --- a/examples/create-resource.go +++ b/examples/create-resource.go @@ -7,11 +7,12 @@ import ( "github.com/ericchiang/k8s" "github.com/ericchiang/k8s/api/v1" + metav1 "github.com/ericchiang/k8s/apis/meta/v1" ) func createConfigMap(client *k8s.Client, name string, values map[string]string) error { cm := &v1.ConfigMap{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: &name, Namespace: &client.Namespace, }, diff --git a/tprs_test.go b/tprs_test.go index 28553e3..a466518 100644 --- a/tprs_test.go +++ b/tprs_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/ericchiang/k8s/api/unversioned" - "github.com/ericchiang/k8s/api/v1" "github.com/ericchiang/k8s/apis/extensions/v1beta1" + metav1 "github.com/ericchiang/k8s/apis/meta/v1" ) func TestTPRs(t *testing.T) { @@ -19,7 +19,7 @@ func TestTPRs(t *testing.T) { type Metric struct { *unversioned.TypeMeta `json:",inline"` - *v1.ObjectMeta `json:"metadata,omitempty"` + *metav1.ObjectMeta `json:"metadata,omitempty"` Timestamp time.Time `json:"timestamp"` Value int64 `json:"value"` @@ -34,7 +34,7 @@ func TestTPRs(t *testing.T) { // Create a ThirdPartyResource tpr := &v1beta1.ThirdPartyResource{ - Metadata: &v1.ObjectMeta{ + Metadata: &metav1.ObjectMeta{ Name: String("metric.example.com"), }, Description: String("A value and a timestamp"), @@ -50,7 +50,7 @@ func TestTPRs(t *testing.T) { } metric := &Metric{ - ObjectMeta: &v1.ObjectMeta{ + ObjectMeta: &metav1.ObjectMeta{ Name: String("foo"), }, Timestamp: time.Now(),