Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: make version output consistent #69

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions cmd/vela-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,21 @@ import (
_ "github.com/joho/godotenv/autoload"
)

// nolint: funlen // ignore function length due to comments and flags
func main() {
// capture application version information
v := version.New()

// serialize the version information as pretty JSON
bytes, err := json.MarshalIndent(v, "", " ")
if err != nil {
logrus.Fatal(err)
}

// output the version information to stdout
fmt.Fprintf(os.Stdout, "%s\n", string(bytes))

// create new CLI application
app := cli.NewApp()

// Plugin Information
Expand All @@ -38,7 +52,7 @@ func main() {

app.Action = run
app.Compiled = time.Now()
app.Version = version.New().Semantic()
app.Version = v.Semantic()

// Plugin Flags

Expand Down Expand Up @@ -148,23 +162,14 @@ func main() {
},
}

err := app.Run(os.Args)
err = app.Run(os.Args)
if err != nil {
logrus.Fatal(err)
}
}

// run executes the plugin based off the configuration provided.
func run(c *cli.Context) error {
// capture the version information as pretty JSON
v, err := json.MarshalIndent(version.New(), "", " ")
if err != nil {
return err
}

// output the version information to stdout
fmt.Fprintf(os.Stdout, "%s\n", string(v))

// set the log level for the plugin
switch c.String("log.level") {
case "t", "trace", "Trace", "TRACE":
Expand Down Expand Up @@ -236,7 +241,7 @@ func run(c *cli.Context) error {
}

// validate the plugin
err = p.Validate()
err := p.Validate()
if err != nil {
return err
}
Expand Down
Loading