Skip to content

Commit

Permalink
Fix travis build errors due to lint issues (#257)
Browse files Browse the repository at this point in the history
* fixes #256 travis build failures

* apply goimports -w to generated files to fix a bunch of lint issues.

* There's no good way to tell whether a file was generated. a better way is to ensure that all files and newly submitted ones are goimported. also from now on I think it is better to enforce that even generated code are pre-goimported.

* I didn't fix all the lint warnings because I am afraid of changing any code other than using goimport. I suggest that the original author do the changes instead.
  • Loading branch information
jimexist authored and jlewi committed Jan 3, 2018
1 parent ed7cae7 commit 519b0ac
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 41 deletions.
6 changes: 5 additions & 1 deletion linter_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
"Aggregate": true,
"WarnUnmatchedNolint": true,
"LineLength": 240,
"Exclude": ["comment or be unexported", "comment on exported"],
"Exclude": [
"redundant return statement",
"comment or be unexported",
"comment on exported"
],
"Deadline": "300s",
"Skip": ["bin", "py"]
}
7 changes: 4 additions & 3 deletions pkg/apis/tensorflow/helper/helpers.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package helper

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
tfv1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
"fmt"
"k8s.io/api/core/v1"

tfv1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
"github.com/tensorflow/k8s/pkg/util"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// AsOwner make OwnerReference according to the parameter
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/tensorflow/helper/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"

"github.com/gogo/protobuf/proto"
tfv1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
"github.com/tensorflow/k8s/pkg/util"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/api/core/v1"
tfv1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
"k8s.io/apimachinery/pkg/api/resource"
)

func TestAddAccelertor(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/tensorflow/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)


func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}


// SetDefaults_TfJob sets any unspecified values to defaults
func SetDefaults_TfJob(obj *TfJob) {
c := &obj.Spec
Expand Down Expand Up @@ -71,4 +69,3 @@ func setDefault_PSPodTemplateSpec(r *TfReplicaSpec, tfImage string) {
},
}
}

24 changes: 12 additions & 12 deletions pkg/apis/tensorflow/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

// GroupName is the group name use in this package
Expand All @@ -19,16 +19,16 @@ var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: CRDVersi

// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

// addKnownTypes adds the set of types defined in this package to the supplied scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TfJob{},
&TfJobList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
scheme.AddKnownTypes(SchemeGroupVersion,
&TfJob{},
&TfJobList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)

return nil
return nil
}
13 changes: 6 additions & 7 deletions pkg/apis/tensorflow/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
Expand All @@ -24,10 +24,10 @@ const (

// TFJob describes tfjob info
type TfJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TfJobSpec `json:"spec"`
Status TfJobStatus `json:"status"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec TfJobSpec `json:"spec"`
Status TfJobStatus `json:"status"`
}

type TfJobSpec struct {
Expand Down Expand Up @@ -58,7 +58,6 @@ type ChiefSpec struct {
ReplicaIndex int `json:"replicaIndex"`
}


// TfReplicaType determines how a set of TF processes are handled.
type TfReplicaType string

Expand Down Expand Up @@ -87,7 +86,7 @@ type TfReplicaSpec struct {
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
Template *v1.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,3,opt,name=template"`
// TfPort is the port to use for TF services.
TfPort *int32 `json:"tfPort,omitempty" protobuf:"varint,1,opt,name=tfPort"`
TfPort *int32 `json:"tfPort,omitempty" protobuf:"varint,1,opt,name=tfPort"`
TfReplicaType `json:"tfReplicaType"`
// IsDefaultPS denotes if the parameter server should use the default grpc_tensorflow_server
IsDefaultPS bool
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/tensorflow/v1alpha1/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ 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
5 changes: 3 additions & 2 deletions pkg/apis/tensorflow/validation/validation.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package validation

import (
"errors"
"fmt"

tfv1 "github.com/tensorflow/k8s/pkg/apis/tensorflow/v1alpha1"
"github.com/tensorflow/k8s/pkg/util"
"fmt"
"errors"
)

// ValidateTfJobSpec checks that the TfJobSpec is valid.
Expand Down
9 changes: 6 additions & 3 deletions pkg/client/clientset/versioned/fake/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (

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

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

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

if err := tensorflowv1alpha1.AddToScheme(scheme); err != nil {
panic(err)
}
}
5 changes: 3 additions & 2 deletions pkg/client/clientset/versioned/scheme/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func init() {
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.
func AddToScheme(scheme *runtime.Scheme) {
tensorflowv1alpha1.AddToScheme(scheme)

if err := tensorflowv1alpha1.AddToScheme(scheme); err != nil {
panic(err)
}
}
7 changes: 4 additions & 3 deletions pkg/client/informers/externalversions/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ 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
1 change: 1 addition & 0 deletions pkg/client/informers/externalversions/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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
Expand Up @@ -19,10 +19,11 @@ 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
Expand Up @@ -19,6 +19,8 @@ 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 @@ -27,7 +29,6 @@ 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

0 comments on commit 519b0ac

Please sign in to comment.