Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit a1dc197

Browse files
author
Anca Iordache
committed
app-214 Enabled validate only for experimental mode
Signed-off-by: Anca Iordache <[email protected]>
1 parent 4e0989c commit a1dc197

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

internal/commands/root.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
4848
}
4949

5050
func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
51-
cmd.AddCommand(
51+
listOfCommands := []*cobra.Command{
5252
runCmd(dockerCli),
5353
updateCmd(dockerCli),
5454
removeCmd(dockerCli),
@@ -59,8 +59,19 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
5959
pullCmd(dockerCli),
6060
image.Cmd(dockerCli),
6161
build.Cmd(dockerCli),
62-
inspectCmd(dockerCli),
63-
)
62+
}
63+
64+
isExperimentalMode := dockerCli.ClientInfo().HasExperimental
65+
for _, ccmd := range listOfCommands {
66+
switch ccmd.Annotations["experimental"] {
67+
case "true":
68+
if isExperimentalMode {
69+
cmd.AddCommand(ccmd)
70+
}
71+
default:
72+
cmd.AddCommand(ccmd)
73+
}
74+
}
6475
}
6576

6677
func firstOrEmpty(list []string) string {

internal/commands/validate.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ type validateOptions struct {
2222
func validateCmd() *cobra.Command {
2323
var opts validateOptions
2424
cmd := &cobra.Command{
25-
Use: "validate [OPTIONS] APP_DEFINITION",
26-
Short: "Check that an App definition (.dockerapp) is syntactically correct",
27-
Example: `$ docker app validate myapp.dockerapp --set key=value --parameters-file myparam.yml`,
28-
Args: cli.RequiresMaxArgs(1),
25+
Use: "validate [OPTIONS] APP_DEFINITION",
26+
Short: "Check that an App definition (.dockerapp) is syntactically correct",
27+
Example: `$ docker app validate myapp.dockerapp --set key=value --parameters-file myparam.yml`,
28+
Args: cli.RequiresMaxArgs(1),
29+
Annotations: map[string]string{"experimental": "true"},
2930
RunE: func(cmd *cobra.Command, args []string) error {
3031
return runValidate(args, opts)
3132
},

0 commit comments

Comments
 (0)