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

feat(jx) add the OS details to jx version output #2291

Merged
merged 5 commits into from Nov 22, 2018

Conversation

jtnord
Copy link

@jtnord jtnord commented Nov 20, 2018

Submitter checklist

  • Change is code complete and matches issue description.
  • Change is covered by existing or new tests.

Description

It is useful to know the OS version of the client in reports so this
change addes an "Operating System" column to the details listed by
jx version

Special notes for the reviewer(s)

tested on Windows 10 Pro 1803, OSX (some version), Bash on Ubuntu on Windows and centos, debian and alpine docker images.

Which issue this PR fixes

It is useful to know the OS version of the client in reports so this
change addes an "Operating System" column to the details listed by
`jx version`
"golang.org/x/sys/windows/registry"
)

// returns a human friendly string of the current OS
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment on exported function GetOsVersion should be of the form "GetOsVersion ..."

"runtime"
)

// returns a human friendly string of the current OS
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment on exported function GetOsVersion should be of the form "GetOsVersion ..."

text := string(data)
text = strings.TrimSpace(text)
if err != nil {
return "", fmt.Errorf("Command failed '%s %s': %s %s\n", command, strings.Join(args, " "), text, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

error strings should not be capitalized or end with punctuation or a newline

"strings"
)

// returns a human friendly string of the current OS
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment on exported function GetOsVersion should be of the form "GetOsVersion ..."

text := string(data)
text = strings.TrimSpace(text)
if err != nil {
return "", fmt.Errorf("Command failed '%s %s': %s %s\n", command, strings.Join(args, " "), text, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

error strings should not be capitalized or end with punctuation or a newline

"strings"
)

// returns a human friendly string of the current OS
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment on exported function GetOsVersion should be of the form "GetOsVersion ..."

pkg/jx/cmd/version.go Show resolved Hide resolved
@@ -201,6 +210,12 @@ func (o *VersionOptions) UpgradeCli() error {
return options.Run()
}

// returns a human friendly string of the current OS
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment on exported method VersionOptions.GetOsVersion should be of the form "GetOsVersion ..."

pn, err = getMajorMinorVersion(&regkey)
if err != nil {
return retVal, err
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if block ends with a return statement, so drop this else and outdent its block

@jtnord
Copy link
Author

jtnord commented Nov 20, 2018

/assign markawm

}


func runCommand(command string, args ...string) (string, error) {
Copy link

Choose a reason for hiding this comment

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

This is duplicated code - assume you've added both because of the conditional building, which means not dup'd in runtime, but still in src control.
There is already a very similar function in cmd.CommonOptions.RunCommand (though I think the way it interacts with the verbose flag is not ideal). I actually starting refactoring some of this into the util package (just util.RunCommandBackground). How about adding your version (i.e. one that cares about the output) as util.RunCommand()?

Copy link
Author

Choose a reason for hiding this comment

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

So having thought about this some more, I can potentially see cases where we may want to get the OS version from the util package and that would cause circular dependencies.
I could export this function in the system package and refactor all other usage from it but that seems a bit too much work for a this small piece of code.

@jtnord
Copy link
Author

jtnord commented Nov 22, 2018

/approve

@jtnord
Copy link
Author

jtnord commented Nov 22, 2018

/approve

@jtnord
Copy link
Author

jtnord commented Nov 22, 2018

/LGTM

@jenkins-x-bot
Copy link
Contributor

@jtnord: you cannot LGTM your own PR.

In response to this:

/LGTM

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jstrachan
Copy link
Member

/approve

@rawlingsj
Copy link
Member

/lgtm

@jenkins-x-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jstrachan, jtnord, rawlingsj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [jstrachan,jtnord,rawlingsj]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Successfully merging this pull request may close these issues.

None yet

6 participants