Skip to content

Commit

Permalink
Fixed gometalinter errors
Browse files Browse the repository at this point in the history
Signed-off-by: JetMuffin <mofeng.cj@alibaba-inc.com>
  • Loading branch information
jetmuffin committed Jul 11, 2018
1 parent 88de5a6 commit fa0b965
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
14 changes: 9 additions & 5 deletions hack/genspec/genspec.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"

"encoding/json"
"github.com/go-openapi/spec"
"github.com/golang/glog"
"github.com/kubeflow/tf-operator/hack/genspec/lib"
Expand Down Expand Up @@ -118,6 +118,10 @@ func generateSwaggerJson() (string, error) {
},
OpenAPIDefinition: v1alpha2.GetOpenAPIDefinitions,
})
if err != nil {
return "", fmt.Errorf("failed to create server config: %v", err)
}

genericServer, err := serverConfig.Complete().New("openapi-server", genericapiserver.EmptyDelegate)
if err != nil {
return "", fmt.Errorf("failed to create server: %v", err)
Expand Down Expand Up @@ -150,21 +154,21 @@ func generateSwaggerJson() (string, error) {
}

func main() {
filename := flag.String("f", "api/openapi-spec/swagger.json", "Path to write OpenAPI spec file")
filename := flag.String("f", "pkg/apis/tensorflow/v1alpha2/openapi-spec/swagger.json", "Path to write OpenAPI spec file")

flag.Parse()

err := os.MkdirAll(filepath.Dir(*filename), 0755)
err := os.MkdirAll(filepath.Dir(*filename), 0644)
if err != nil {
glog.Fatalf("failed to create directory %s: %v", filepath.Dir(*filename), err)
}

spec, err := generateSwaggerJson()
apiSpec, err := generateSwaggerJson()
if err != nil {
glog.Fatalf("failed to generate spec: %v", err)
}

err = ioutil.WriteFile(*filename, []byte(spec), 0644)
err = ioutil.WriteFile(*filename, []byte(apiSpec), 0644)
if err != nil {
glog.Fatalf("failed to write spec: %v", err)
}
Expand Down
9 changes: 3 additions & 6 deletions pkg/apis/tensorflow/v1alpha2/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// Install registers the API group and adds type to a schema
func Install(groupFactoryRegister announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, schema *runtime.Scheme) error {
if err := announced.NewGroupMetaFactory(
return announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: GroupName,
RootScopedKinds: sets.NewString(),
Expand All @@ -18,8 +18,5 @@ func Install(groupFactoryRegister announced.APIGroupFactoryRegistry, registry *r
announced.VersionToSchemeFunc{
SchemeGroupVersion.Version: AddToScheme,
},
).Announce(groupFactoryRegister).RegisterAndEnable(registry, schema); err != nil {
return err
}
return nil
}
).Announce(groupFactoryRegister).RegisterAndEnable(registry, schema)
}

0 comments on commit fa0b965

Please sign in to comment.