Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
*: update all to use new meta/v1 package
Browse files Browse the repository at this point in the history
  • Loading branch information
ericchiang committed Mar 27, 2017
1 parent 87481fe commit c19d9dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand Down
11 changes: 6 additions & 5 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"

"github.com/ericchiang/k8s/api/v1"
metav1 "github.com/ericchiang/k8s/apis/meta/v1"
)

const skipMsg = `
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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),
},
}
Expand All @@ -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{
Expand Down
3 changes: 2 additions & 1 deletion examples/create-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
8 changes: 4 additions & 4 deletions tprs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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"`
Expand All @@ -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"),
Expand All @@ -50,7 +50,7 @@ func TestTPRs(t *testing.T) {
}

metric := &Metric{
ObjectMeta: &v1.ObjectMeta{
ObjectMeta: &metav1.ObjectMeta{
Name: String("foo"),
},
Timestamp: time.Now(),
Expand Down

0 comments on commit c19d9dc

Please sign in to comment.