mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-12 13:25:29 +00:00
Merge pull request #53 from caesarxuchao/update-thirdparty-example
fix thirdparty example
This commit is contained in:
@@ -7,10 +7,11 @@ import (
|
|||||||
"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/errors"
|
||||||
"k8s.io/client-go/pkg/api/unversioned"
|
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"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"
|
||||||
|
"k8s.io/client-go/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/pkg/runtime/serializer"
|
"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"
|
||||||
@@ -39,7 +40,7 @@ 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")
|
tpr, err := clientset.Extensions().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{
|
||||||
@@ -130,7 +131,7 @@ func buildConfig(kubeconfig string) (*rest.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configureClient(config *rest.Config) {
|
func configureClient(config *rest.Config) {
|
||||||
groupversion := unversioned.GroupVersion{
|
groupversion := schema.GroupVersion{
|
||||||
Group: "k8s.io",
|
Group: "k8s.io",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,8 @@ import (
|
|||||||
|
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
"k8s.io/client-go/pkg/api/meta"
|
"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 {
|
type ExampleSpec struct {
|
||||||
@@ -14,21 +15,21 @@ type ExampleSpec struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Example struct {
|
type Example struct {
|
||||||
unversioned.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
Metadata api.ObjectMeta `json:"metadata"`
|
Metadata api.ObjectMeta `json:"metadata"`
|
||||||
|
|
||||||
Spec ExampleSpec `json:"spec"`
|
Spec ExampleSpec `json:"spec"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExampleList struct {
|
type ExampleList struct {
|
||||||
unversioned.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
Metadata unversioned.ListMeta `json:"metadata"`
|
Metadata metav1.ListMeta `json:"metadata"`
|
||||||
|
|
||||||
Items []Example `json:"items"`
|
Items []Example `json:"items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required to satisfy Object interface
|
// Required to satisfy Object interface
|
||||||
func (e *Example) GetObjectKind() unversioned.ObjectKind {
|
func (e *Example) GetObjectKind() schema.ObjectKind {
|
||||||
return &e.TypeMeta
|
return &e.TypeMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,12 +39,12 @@ func (e *Example) GetObjectMeta() meta.Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Required to satisfy Object interface
|
// Required to satisfy Object interface
|
||||||
func (el *ExampleList) GetObjectKind() unversioned.ObjectKind {
|
func (el *ExampleList) GetObjectKind() schema.ObjectKind {
|
||||||
return &el.TypeMeta
|
return &el.TypeMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required to satisfy ListMetaAccessor interface
|
// Required to satisfy ListMetaAccessor interface
|
||||||
func (el *ExampleList) GetListMeta() unversioned.List {
|
func (el *ExampleList) GetListMeta() metav1.List {
|
||||||
return &el.Metadata
|
return &el.Metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user