Skip to content

Refactoring the S2I command line interface - #760

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
coreydaley:github_443_refactor_cli_code
Jun 27, 2017
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
coreydaley:github_443_refactor_cli_code

Conversation

@coreydaley

@coreydaley coreydaley commented Jun 23, 2017 •

Copy link
Copy Markdown

Refactoring the S2I cli to fall in line with the openshift client code organization
Closes #443

@coreydaley

Copy link
Copy Markdown
Author

[test]

@coreydaley

Copy link
Copy Markdown
Author

@openshift/devex ptal
Keep in mind that this was mostly just re-organizing the command line code to fall in line with the openshift client, and to get rid of some of the os.Exit calls in the cli.

@coreydaley coreydaley changed the title (WIP) Refactoring the S2I command line interface Refactoring the S2I command line interface Jun 23, 2017
Comment thread pkg/cmd/cmd.go
@@ -0,0 +1 @@
package cmd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must be a hideous golang requirement? (can't have empty directories that just contain sub-packages?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct :(
Basically gives a "no files to compile error", I believe there is one or two in origin also

Comment thread pkg/cmd/cli/cli.go Outdated
var glog = utilglog.StderrLog

// NewCmdCLI implements the S2I command line functionality.
func NewCmdCLI(cfg *api.Config) *cobra.Command {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of this arg? seems like we only pass nil when we call NewCmdCLI....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in next push

Comment thread cmd/s2i/s2i.go
basename := filepath.Base(os.Args[0])
command := cli.CommandFor(basename)
if err := command.Execute(); err != nil {
os.Exit(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we dump this error before exiting?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in next push

@bparees bparees self-assigned this Jun 23, 2017
Comment thread pkg/cmd/cli/cli.go Outdated

// NewCmdCLI implements the S2I command line functionality.
func NewCmdCLI() *cobra.Command {
rand.Seed(time.Now().UnixNano())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed - already done in main()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in next push

Comment thread pkg/cmd/cli/cli.go Outdated
// Make case-insensitive and strip executable suffix if present
if runtime.GOOS == "windows" {
basename = strings.ToLower(basename)
basename = strings.TrimSuffix(basename, ".exe")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaics all this code does nothing as basename is not read after write?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in next push

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for source to image test up to 95ebbab

@openshift-bot

Copy link
Copy Markdown
Contributor

Source To Image Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_s2i/550/) (Base Commit: 1077640) (PR Branch Commit: 95ebbab)

@coreydaley

Copy link
Copy Markdown
Author

@bparees @jim-minter updates made, ptal

@bparees

bparees commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

lgtm, will let @jim-minter have the final word.

Comment thread cmd/s2i/s2i.go

func main() {
rand.Seed(time.Now().UTC().UnixNano())
if len(os.Getenv("GOMAXPROCS")) == 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is necessary - is there a specific reason for adding it out of interest?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it was cargo-culted from origin:
https://github.com/openshift/origin/blob/master/cmd/openshift/openshift.go#L30

i think it's a harmless (if probably unnecessary) optimization

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jim-minter indeed since Go 1.5 (release notes):

By default, Go programs run with GOMAXPROCS set to the number of cores available; in prior releases it defaulted to 1.

This effectively does nothing, and, as Ben suggests, it must come as inheritance from the early v3 days ;)

@jim-minter

Copy link
Copy Markdown

nice refactor! lgtm - question about GOMAXPROCS is curiosity on my part

@bparees

bparees commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

openshift-bot commented Jun 27, 2017 •

Copy link
Copy Markdown
Contributor

Source To Image Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_s2i/550/) (Base Commit: 1077640) (PR Branch Commit: 95ebbab)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for source to image merge up to 95ebbab

@openshift-bot
openshift-bot merged commit 457cbd8 into openshift:master Jun 27, 2017
@coreydaley

Copy link
Copy Markdown
Author

@jim-minter Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants