The Wayback Machine - https://web.archive.org/web/20260314091640/https://github.com/docker/cli/pull/804
Skip to content

Annotate "stack" commands to be "swarm" and "kubernetes"#804

Merged
dnephin merged 1 commit intodocker:masterfrom
thaJeztah:more-annotations
Jan 26, 2018
Merged

Annotate "stack" commands to be "swarm" and "kubernetes"#804
dnephin merged 1 commit intodocker:masterfrom
thaJeztah:more-annotations

Conversation

@thaJeztah
Copy link
Member

The stack commands require either "swarm" or "kubernetes"

- Description for the changelog

ping @dnephin @vdemeester @MistyHacks

cmd.Annotations = map[string]string{"experimental": "", "version": "1.25"}
cmd.Annotations = map[string]string{
"experimental": "",
"swarm": "",
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure if I should add "kubernetes" for the top-level docker deploy; it's still marked "experimental" (and I think we should consider removing it)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think we should remove the top level one (and thus we don't need to annotate it)

@codecov-io
Copy link

codecov-io commented Jan 11, 2018

Codecov Report

Merging #804 into master will decrease coverage by 0.01%.
The diff coverage is 19.04%.

@@            Coverage Diff             @@
##           master     #804      +/-   ##
==========================================
- Coverage   52.96%   52.95%   -0.02%     
==========================================
  Files         244      244              
  Lines       15828    15839      +11     
==========================================
+ Hits         8383     8387       +4     
- Misses       6891     6898       +7     
  Partials      554      554

Copy link
Contributor

@mdlinville mdlinville left a comment

Choose a reason for hiding this comment

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

LGTM, needs to be cherry-picked definitely.

Copy link
Collaborator

@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 🐒

cmd.Annotations = map[string]string{"experimental": "", "version": "1.25"}
cmd.Annotations = map[string]string{
"experimental": "",
"swarm": "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think we should remove the top level one (and thus we don't need to annotate it)

@thaJeztah
Copy link
Member Author

ping @dnephin okay to merge?

@dnephin
Copy link
Contributor

dnephin commented Jan 22, 2018

there is a test failure, let me try to rerun

@dnephin
Copy link
Contributor

dnephin commented Jan 22, 2018

@thaJeztah the e2e test seems to be failing consistently. Can you take a look? I think it's a real failure, doesn't look like a flake.

@dnephin
Copy link
Contributor

dnephin commented Jan 22, 2018

I think the logic for disabling kubernetes doesn't account for swarm also being set ?

@thaJeztah
Copy link
Member Author

oh, interesting one; I'd have to check where/how it's used there 😓

@vdemeester
Copy link
Collaborator

@dnephin @thaJeztah right.. the code that checks for swarm/kubernetes is pretty naive and doesn't handle something that would support both (i.e. it make the assumption that it would have none of both…). That needs to change 😅

@vdemeester
Copy link
Collaborator

vdemeester commented Jan 22, 2018

diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go
index 74d8447f..cd5be656 100644
--- a/cmd/docker/docker.go
+++ b/cmd/docker/docker.go
@@ -277,10 +277,12 @@ func areFlagsSupported(cmd *cobra.Command, details versionDetails) error {
                        if _, ok := f.Annotations["experimentalCLI"]; ok && !hasExperimentalCLI {
                                errs = append(errs, fmt.Sprintf("\"--%s\" is only supported when experimental cli features are enabled", f.Name))
                        }
-                       if _, ok := f.Annotations["kubernetes"]; ok && !hasKubernetes {
+                       _, isKubernetesAnnotated := f.Annotations["kubernetes"]
+                       _, isSwarmAnnotated := f.Annotations["swarm"]
+                       if isKubernetesAnnotated && !isSwarmAnnotated && !hasKubernetes {
                                errs = append(errs, fmt.Sprintf("\"--%s\" is only supported on a Docker cli with kubernetes features enabled", f.Name))
                        }
-                       if _, ok := f.Annotations["swarm"]; ok && hasKubernetes {
+                       if isSwarmAnnotated && !isKubernetesAnnotated && hasKubernetes {
                                errs = append(errs, fmt.Sprintf("\"--%s\" is only supported on a Docker cli with swarm features enabled", f.Name))
                        }
                }
@@ -309,10 +311,12 @@ func areSubcommandsSupported(cmd *cobra.Command, details versionDetails) error {
                if _, ok := curr.Annotations["experimentalCLI"]; ok && !hasExperimentalCLI {
                        return fmt.Errorf("%s is only supported when experimental cli features are enabled", cmd.CommandPath())
                }
-               if _, ok := curr.Annotations["kubernetes"]; ok && !hasKubernetes {
+               _, isKubernetesAnnotated := curr.Annotations["kubernetes"]
+               _, isSwarmAnnotated := curr.Annotations["swarm"]
+               if isKubernetesAnnotated && !isSwarmAnnotated && !hasKubernetes {
                        return fmt.Errorf("%s is only supported on a Docker cli with kubernetes features enabled", cmd.CommandPath())
                }
-               if _, ok := curr.Annotations["swarm"]; ok && hasKubernetes {
+               if isSwarmAnnotated && !isKubernetesAnnotated && hasKubernetes {
                        return fmt.Errorf("%s is only supported on a Docker cli with swarm features enabled", cmd.CommandPath())
                }
        }

Something like the above should fix it 👼

@thaJeztah
Copy link
Member Author

Thanks! Added that change 👍

@thaJeztah
Copy link
Member Author

oh, we may need something similar for areSubcommandsSupported(), let me check if that's indeed the case

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

We should rewrite that logic a bit; it's quite confusing because !hasKubernetes means no orchestrator set means use default means swarm; we can do so in a follow up, as it may require some changes in other locations

@vdemeester
Copy link
Collaborator

ping @dnephin 👼

@vdemeester vdemeester added this to the 18.02.0 milestone Jan 26, 2018
Copy link
Contributor

@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

This will need some cleanup if we ever add a third option, but hopefully that wont happen for a while.

@dnephin dnephin merged commit a46fa07 into docker:master Jan 26, 2018
@thaJeztah thaJeztah deleted the more-annotations branch January 26, 2018 23:00
@thaJeztah thaJeztah removed this from the 18.02.0 milestone Jan 31, 2018
@thaJeztah thaJeztah added this to the 18.03.0 milestone Jan 31, 2018
nobiit pushed a commit to nobidev/docker-cli that referenced this pull request Nov 19, 2025
Annotate "stack" commands to be "swarm" and "kubernetes"
Upstream-commit: a46fa07
Component: cli
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.

6 participants