X Tutup
Skip to content

Hide command options that are related to Windows#30788

Merged
vdemeester merged 1 commit intomoby:masterfrom
boaz0:hide_win_opts
Mar 13, 2017
Merged

Hide command options that are related to Windows#30788
vdemeester merged 1 commit intomoby:masterfrom
boaz0:hide_win_opts

Conversation

@boaz0
Copy link
Contributor

@boaz0 boaz0 commented Feb 7, 2017

- What I did

On Linux hide commands options that are relevant to Windows.

- How I did it

  • Add the Server-OS header to the ping response which will be used to determine what options to hide
  • Set the os annotation containing the operating system name
  • Hide all options that has this annotation and the value is not equal to the operating system name

- How to verify it
🤔

@boaz0
Copy link
Contributor Author

boaz0 commented Feb 7, 2017

//cc @albers @thaJeztah @dnephin
closes #30624

Copy link
Member

Choose a reason for hiding this comment

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

--squash is not windows only, I think it was just being used as an example of an experimental flag.

Copy link
Member

Choose a reason for hiding this comment

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

yes, that's true.

Copy link
Member

Choose a reason for hiding this comment

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

same here, not windows only

Copy link
Member

Choose a reason for hiding this comment

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

rather linux only at the moment 😅

client/ping.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This seems kind of hacky, I can see this failing unexpectedly.

I think it would be better to add a new header with the serverOS in a format that is easier to parse (or doesn't need to be parsed at all).

Copy link
Member

Choose a reason for hiding this comment

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

We use this Option naming convention for data objects populated from command line flags. This struct is not being used that way, so I think the name is confusing.

How about apiProperties or apiFeatures or something like that?

Choose a reason for hiding this comment

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

There's an extra blank line above "strings".

Copy link
Contributor Author

@boaz0 boaz0 Feb 7, 2017

Choose a reason for hiding this comment

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

Yes, I know. vim-go does that automatically. I can fix that, though.

EDIT to avoid overloading the Jenkins master I will push this change only if there will be at least one more comment about the design.
Thanks.

@thaJeztah
Copy link
Member

Looking at the output of the /info endpoint;

  "KernelVersion": "4.9.10-moby",
  "OperatingSystem": "Alpine Linux v3.5 (containerized)",
  "OSType": "linux",
  "Architecture": "x86_64",

I wonder if we should use the same terminology (OSType / OS-Type) for this

@boaz0
Copy link
Contributor Author

boaz0 commented Feb 22, 2017

@thaJeztah sounds right. I know OSType is also used when displaying containers statistics.
I will change that.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

design LGTM, left some comments inline

Copy link
Member

Choose a reason for hiding this comment

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

Can you include this in the isFlagSupported() function? e.g.

if !isFlagSupported(f, apiProps.OSType, apiProps.ClientVer) {
    f.Hidden = true
}

Copy link
Member

Choose a reason for hiding this comment

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

This logic should take older daemons into account; older daemons won't return an OS-Type header. As a result, this logic will hide any flag that has a os annotation set. If the daemon didn't return an OS-Type header, just show the flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I am surprised I missed it. Thanks for noticing me!

Copy link
Member

Choose a reason for hiding this comment

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

nit: Should we name this "ostype" / "os-type" as well to be consistent (otherwise there's a risk they're getting different meanings)?

Copy link
Member

Choose a reason for hiding this comment

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

nit; using an or here is probably clearer;

if !isOSTypeSupported(f, osType) || !isVersionSupported(f, clientVersion) {
    f.Hidden = true
}

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

As a follow-up we may want to look into hiding Linux flags on Windows. Especially on docker run there's a lot of flags that are Linux-specific, and I think it'll be a nice enhancements to hide those when running against a Windows daemon 👍

@boaz0
Copy link
Contributor Author

boaz0 commented Mar 1, 2017

@thaJeztah sure thing!

@GordonTheTurtle GordonTheTurtle added dco/no Automatically set by a bot when one of the commits lacks proper signature and removed dco/no Automatically set by a bot when one of the commits lacks proper signature labels Mar 1, 2017
@thaJeztah
Copy link
Member

ping @dnephin ptal

@ripcurld0 heard you're a git rebase pro 😉

@boaz0
Copy link
Contributor Author

boaz0 commented Mar 11, 2017

indeed, i am 🥇

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

// OSType returns the operating system the daemon is running on.
func (cli *DockerCli) OSType() string {
return cli.osType
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm now realizing that we never should have put these things on DockerCli directly. We should have created a new struct to store experimental and default version. That would make the signature for isSupported() and the others a lot cleaner.

I'll handle that in a new PR.

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🦁

@vdemeester vdemeester merged commit be453c5 into moby:master Mar 13, 2017
@GordonTheTurtle GordonTheTurtle added this to the 17.04.0 milestone Mar 13, 2017
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Hide command options that are related to Windows
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.

8 participants

X Tutup