Commit abeabeb7 authored by Dr. Stefan Schimanski's avatar Dr. Stefan Schimanski

client-go: fix examples

parent 7aebe7c0
...@@ -20,8 +20,8 @@ import ( ...@@ -20,8 +20,8 @@ import (
"fmt" "fmt"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
) )
...@@ -37,7 +37,7 @@ func main() { ...@@ -37,7 +37,7 @@ func main() {
panic(err.Error()) panic(err.Error())
} }
for { for {
pods, err := clientset.Core().Pods("").List(v1.ListOptions{}) pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{})
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }
......
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"fmt" "fmt"
"time" "time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
) )
...@@ -43,7 +43,7 @@ func main() { ...@@ -43,7 +43,7 @@ func main() {
panic(err.Error()) panic(err.Error())
} }
for { for {
pods, err := clientset.Core().Pods("").List(v1.ListOptions{}) pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{})
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/errors"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/apis/extensions/v1beta1" "k8s.io/client-go/pkg/apis/extensions/v1beta1"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
"k8s.io/client-go/pkg/runtime/serializer"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
...@@ -40,11 +55,11 @@ func main() { ...@@ -40,11 +55,11 @@ func main() {
} }
// initialize third party resource if it does not exist // initialize third party resource if it does not exist
tpr, err := clientset.Extensions().ThirdPartyResources().Get("example.k8s.io", metav1.GetOptions{}) tpr, err := clientset.ExtensionsV1beta1().ThirdPartyResources().Get("example.k8s.io", metav1.GetOptions{})
if err != nil { if err != nil {
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
tpr := &v1beta1.ThirdPartyResource{ tpr := &v1beta1.ThirdPartyResource{
ObjectMeta: v1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "example.k8s.io", Name: "example.k8s.io",
}, },
Versions: []v1beta1.APIVersion{ Versions: []v1beta1.APIVersion{
...@@ -53,7 +68,7 @@ func main() { ...@@ -53,7 +68,7 @@ func main() {
Description: "An Example ThirdPartyResource", Description: "An Example ThirdPartyResource",
} }
result, err := clientset.Extensions().ThirdPartyResources().Create(tpr) result, err := clientset.ExtensionsV1beta1().ThirdPartyResources().Create(tpr)
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -87,7 +102,7 @@ func main() { ...@@ -87,7 +102,7 @@ func main() {
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
// Create an instance of our TPR // Create an instance of our TPR
example := &Example{ example := &Example{
Metadata: api.ObjectMeta{ Metadata: metav1.ObjectMeta{
Name: "example1", Name: "example1",
}, },
Spec: ExampleSpec{ Spec: ExampleSpec{
...@@ -147,10 +162,9 @@ func configureClient(config *rest.Config) { ...@@ -147,10 +162,9 @@ func configureClient(config *rest.Config) {
groupversion, groupversion,
&Example{}, &Example{},
&ExampleList{}, &ExampleList{},
&api.ListOptions{},
&api.DeleteOptions{},
) )
return nil return nil
}) })
metav1.AddToGroupVersion(api.Scheme, groupversion)
schemeBuilder.AddToScheme(api.Scheme) schemeBuilder.AddToScheme(api.Scheme)
} }
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main package main
import ( import (
"encoding/json" "encoding/json"
"k8s.io/client-go/pkg/api" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime/schema"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime/schema"
) )
type ExampleSpec struct { type ExampleSpec struct {
...@@ -16,7 +30,7 @@ type ExampleSpec struct { ...@@ -16,7 +30,7 @@ type ExampleSpec struct {
type Example struct { type Example struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
Metadata api.ObjectMeta `json:"metadata"` Metadata metav1.ObjectMeta `json:"metadata"`
Spec ExampleSpec `json:"spec"` Spec ExampleSpec `json:"spec"`
} }
...@@ -34,7 +48,7 @@ func (e *Example) GetObjectKind() schema.ObjectKind { ...@@ -34,7 +48,7 @@ func (e *Example) GetObjectKind() schema.ObjectKind {
} }
// Required to satisfy ObjectMetaAccessor interface // Required to satisfy ObjectMetaAccessor interface
func (e *Example) GetObjectMeta() meta.Object { func (e *Example) GetObjectMeta() metav1.Object {
return &e.Metadata return &e.Metadata
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment