fix thirdparty example

This commit is contained in:
Chao Xu
2016-12-14 11:51:34 -08:00
parent 243d8a9cb6
commit b8fd850e88
2 changed files with 13 additions and 11 deletions

View File

@@ -7,10 +7,11 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/errors"
"k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/api/v1"
"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/tools/clientcmd"
@@ -39,7 +40,7 @@ func main() {
}
// initialize third party resource if it does not exist
tpr, err := clientset.Extensions().ThirdPartyResources().Get("example.k8s.io")
tpr, err := clientset.Extensions().ThirdPartyResources().Get("example.k8s.io", metav1.GetOptions{})
if err != nil {
if errors.IsNotFound(err) {
tpr := &v1beta1.ThirdPartyResource{
@@ -130,7 +131,7 @@ func buildConfig(kubeconfig string) (*rest.Config, error) {
}
func configureClient(config *rest.Config) {
groupversion := unversioned.GroupVersion{
groupversion := schema.GroupVersion{
Group: "k8s.io",
Version: "v1",
}

View File

@@ -5,7 +5,8 @@ import (
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/meta"
"k8s.io/client-go/pkg/api/unversioned"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime/schema"
)
type ExampleSpec struct {
@@ -14,21 +15,21 @@ type ExampleSpec struct {
}
type Example struct {
unversioned.TypeMeta `json:",inline"`
Metadata api.ObjectMeta `json:"metadata"`
metav1.TypeMeta `json:",inline"`
Metadata api.ObjectMeta `json:"metadata"`
Spec ExampleSpec `json:"spec"`
}
type ExampleList struct {
unversioned.TypeMeta `json:",inline"`
Metadata unversioned.ListMeta `json:"metadata"`
metav1.TypeMeta `json:",inline"`
Metadata metav1.ListMeta `json:"metadata"`
Items []Example `json:"items"`
}
// Required to satisfy Object interface
func (e *Example) GetObjectKind() unversioned.ObjectKind {
func (e *Example) GetObjectKind() schema.ObjectKind {
return &e.TypeMeta
}
@@ -38,12 +39,12 @@ func (e *Example) GetObjectMeta() meta.Object {
}
// Required to satisfy Object interface
func (el *ExampleList) GetObjectKind() unversioned.ObjectKind {
func (el *ExampleList) GetObjectKind() schema.ObjectKind {
return &el.TypeMeta
}
// Required to satisfy ListMetaAccessor interface
func (el *ExampleList) GetListMeta() unversioned.List {
func (el *ExampleList) GetListMeta() metav1.List {
return &el.Metadata
}