Skip to content

Commit 8fc1444

Browse files
authored
Merge pull request #3901 from thaJeztah/carry_3845
Fix bug where incorrect response is returned [carry 3845]
2 parents f33ef47 + 20ba591 commit 8fc1444

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

cmd/docker/docker.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func hideSubcommandIf(subcmd *cobra.Command, condition func(string) bool, annota
306306
func hideUnsupportedFeatures(cmd *cobra.Command, details versionDetails) error {
307307
var (
308308
notExperimental = func(_ string) bool { return !details.ServerInfo().HasExperimental }
309-
notOSType = func(v string) bool { return v != details.ServerInfo().OSType }
309+
notOSType = func(v string) bool { return details.ServerInfo().OSType != "" && v != details.ServerInfo().OSType }
310310
notSwarmStatus = func(v string) bool {
311311
s := details.ServerInfo().SwarmStatus
312312
if s == nil {
@@ -419,10 +419,11 @@ func areSubcommandsSupported(cmd *cobra.Command, details versionDetails) error {
419419
if cmdVersion, ok := curr.Annotations["version"]; ok && versions.LessThan(details.CurrentVersion(), cmdVersion) {
420420
return fmt.Errorf("%s requires API version %s, but the Docker daemon API version is %s", cmd.CommandPath(), cmdVersion, details.CurrentVersion())
421421
}
422-
if ost, ok := curr.Annotations["ostype"]; ok && ost != details.ServerInfo().OSType {
423-
return fmt.Errorf("%s is only supported on a Docker daemon running on %s, but the Docker daemon is running on %s", cmd.CommandPath(), ost, details.ServerInfo().OSType)
422+
si := details.ServerInfo()
423+
if ost, ok := curr.Annotations["ostype"]; ok && si.OSType != "" && ost != si.OSType {
424+
return fmt.Errorf("%s is only supported on a Docker daemon running on %s, but the Docker daemon is running on %s", cmd.CommandPath(), ost, si.OSType)
424425
}
425-
if _, ok := curr.Annotations["experimental"]; ok && !details.ServerInfo().HasExperimental {
426+
if _, ok := curr.Annotations["experimental"]; ok && !si.HasExperimental {
426427
return fmt.Errorf("%s is only supported on a Docker daemon with experimental features enabled", cmd.CommandPath())
427428
}
428429
}

0 commit comments

Comments
 (0)