Skip to content

Commit

Permalink
*: Implement the List interface for TfJobList (#278)
Browse files Browse the repository at this point in the history
The error is caused by the field name in TfJobList:

// TfJobList is a list of TfJobs clusters.
type TfJobList struct {
	metav1.TypeMeta `json:",inline"`
	// Standard list metadata
	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
	Metadata metav1.ListMeta `json:"metadata,omitempty"`
	// Items is a list of TfJobs
	Items []TfJob `json:"items"`
}
The name of field Metadata should be anonymous field.

ERROR: logging before flag.Parse: E0110 16:52:24.998866    3707 runtime.go:66] Observed a panic: &errors.errorString{s:"*v1alpha1.TfJobList does not implement the List interface"} (*v1alpha1.TfJobList does not implement the List interface)
  • Loading branch information
gaocegege authored and jlewi committed Jan 11, 2018
1 parent adc8ab9 commit 7ddafd5
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 48 deletions.
6 changes: 4 additions & 2 deletions linter_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
"Exclude": [
"redundant return statement",
"comment or be unexported",
"comment on exported"
"comment on exported",
"pkg/apis/tensorflow/v1alpha1/zz_generated.deepcopy.go",
"pkg/apis/tensorflow/v1alpha1/zz_generated.defaults.go"
],
"Deadline": "300s",
"Skip": ["bin", "py"]
"Skip": ["pkg/client"]
}
2 changes: 1 addition & 1 deletion pkg/apis/tensorflow/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ type TfJobList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
Metadata metav1.ListMeta `json:"metadata,omitempty"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of TfJobs
Items []TfJob `json:"items"`
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/apis/tensorflow/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// +build !ignore_autogenerated

/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand All @@ -21,11 +21,10 @@ limitations under the License.
package v1alpha1

import (
reflect "reflect"

v1 "k8s.io/api/core/v1"
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
reflect "reflect"
)

func init() {
Expand Down Expand Up @@ -280,7 +279,7 @@ func (in *TfJob) DeepCopyObject() runtime.Object {
func (in *TfJobList) DeepCopyInto(out *TfJobList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.Metadata = in.Metadata
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TfJob, len(*in))
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/tensorflow/v1alpha1/zz_generated.defaults.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// +build !ignore_autogenerated

/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/clientset.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/clientset_generated.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
11 changes: 4 additions & 7 deletions pkg/client/clientset/versioned/fake/register.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand All @@ -26,9 +26,7 @@ import (

var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)

// TODO: unused
// var parameterCodec = runtime.NewParameterCodec(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)

func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
Expand All @@ -50,7 +48,6 @@ func init() {
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
if err := tensorflowv1alpha1.AddToScheme(scheme); err != nil {
panic(err)
}
tensorflowv1alpha1.AddToScheme(scheme)

}
2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/scheme/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
7 changes: 3 additions & 4 deletions pkg/client/clientset/versioned/scheme/register.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down Expand Up @@ -48,7 +48,6 @@ func init() {
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
if err := tensorflowv1alpha1.AddToScheme(scheme); err != nil {
panic(err)
}
tensorflowv1alpha1.AddToScheme(scheme)

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
9 changes: 4 additions & 5 deletions pkg/client/informers/externalversions/factory.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand All @@ -19,16 +19,15 @@ limitations under the License.
package externalversions

import (
reflect "reflect"
sync "sync"
time "time"

versioned "github.com/tensorflow/k8s/pkg/client/clientset/versioned"
internalinterfaces "github.com/tensorflow/k8s/pkg/client/informers/externalversions/internalinterfaces"
tensorflow "github.com/tensorflow/k8s/pkg/client/informers/externalversions/tensorflow"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
reflect "reflect"
sync "sync"
time "time"
)

type sharedInformerFactory struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/informers/externalversions/generic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand All @@ -20,7 +20,6 @@ package externalversions

import (
"fmt"

v1alpha1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand All @@ -19,11 +19,10 @@ limitations under the License.
package internalinterfaces

import (
time "time"

versioned "github.com/tensorflow/k8s/pkg/client/clientset/versioned"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
time "time"
)

type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand All @@ -19,8 +19,6 @@ limitations under the License.
package v1alpha1

import (
time "time"

tensorflow_v1alpha1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
versioned "github.com/tensorflow/k8s/pkg/client/clientset/versioned"
internalinterfaces "github.com/tensorflow/k8s/pkg/client/informers/externalversions/internalinterfaces"
Expand All @@ -29,6 +27,7 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
time "time"
)

// TfJobInformer provides access to a shared informer and lister for
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/listers/tensorflow/v1alpha1/tfjob.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2018 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.
Expand Down

0 comments on commit 7ddafd5

Please sign in to comment.