Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
app-214 Enabled validate only for experimental mode
Browse files Browse the repository at this point in the history
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
  • Loading branch information
Anca Iordache committed Sep 23, 2019
1 parent 24b127c commit abd8a98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 17 additions & 4 deletions internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
fmt.Fprintf(os.Stderr, "Failed to register command line options: %v", err.Error()) //nolint:errcheck
return nil
}

cmd.Flags().BoolVar(&showVersion, "version", false, "Print version information")

return cmd
}

func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
cmd.AddCommand(

listOfCommands := []*cobra.Command{
installCmd(dockerCli),
upgradeCmd(dockerCli),
uninstallCmd(dockerCli),
Expand All @@ -67,11 +68,23 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
initCmd(dockerCli),
inspectCmd(dockerCli),
renderCmd(dockerCli),
validateCmd(),
bundleCmd(dockerCli),
pushCmd(dockerCli),
pullCmd(dockerCli),
)
validateCmd(),
}

isExperimentalMode := dockerCli.ClientInfo().HasExperimental
for _, ccmd := range listOfCommands {
switch ccmd.Annotations["experimental"] {
case "true":
if isExperimentalMode {
cmd.AddCommand(ccmd)
}
default:
cmd.AddCommand(ccmd)
}
}
}

func firstOrEmpty(list []string) string {
Expand Down
7 changes: 4 additions & 3 deletions internal/commands/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type validateOptions struct {
func validateCmd() *cobra.Command {
var opts validateOptions
cmd := &cobra.Command{
Use: "validate [APP_NAME] [--set KEY=VALUE ...] [--parameters-file PARAMETERS_FILE]",
Short: "Checks the rendered application is syntactically correct",
Args: cli.RequiresMaxArgs(1),
Use: "validate [APP_NAME] [--set KEY=VALUE ...] [--parameters-file PARAMETERS_FILE]",
Short: "Checks the rendered application is syntactically correct",
Args: cli.RequiresMaxArgs(1),
Annotations: map[string]string{"experimental": "true"},
RunE: func(cmd *cobra.Command, args []string) error {
app, err := packager.Extract(firstOrEmpty(args),
types.WithParametersFiles(opts.parametersFiles...),
Expand Down

0 comments on commit abd8a98

Please sign in to comment.