Skip to content

Commit 7f6f08a

Browse files
Yavor16MNoeva
authored andcommitted
Merge pull request cloudfoundry#208 from cloudfoundry/change-parameter-naming
Change help parameter order
2 parents 64ad147 + a31df37 commit 7f6f08a

File tree

4 files changed

+67
-30
lines changed

4 files changed

+67
-30
lines changed

clients/models/operation.go

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

commands/blue_green_deploy_command.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@ func (c *BlueGreenDeployCommand) GetPluginCommand() plugin.Command {
3333
HelpText: "Deploy a multi-target app using blue-green deployment",
3434
UsageDetails: plugin.Usage{
3535
Usage: `Deploy a multi-target app using blue-green deployment
36-
cf bg-deploy MTA [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u URL] [-f] [--retries RETRIES] [--no-start] [--namespace NAMESPACE] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--no-confirm] [--skip-idle-start] [--do-not-fail-on-missing-permissions] [--abort-on-error] [--apps-start-timeout TIMEOUT] [--apps-stage-timeout TIMEOUT] [--apps-upload-timeout TIMEOUT] [--apps-task-execution-timeout TIMEOUT]
36+
cf bg-deploy MTA [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u URL] [-f] [--retries RETRIES] [--no-start] [--namespace NAMESPACE] [--apply-namespace-app-names=true/false] [--apply-namespace-service-names=true/false] [--apply-namespace-app-routes=true/false] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--no-confirm] [--skip-idle-start] [--do-not-fail-on-missing-permissions] [--abort-on-error] [--apps-start-timeout TIMEOUT] [--apps-stage-timeout TIMEOUT] [--apps-upload-timeout TIMEOUT] [--apps-task-execution-timeout TIMEOUT]
3737
3838
Perform action on an active deploy operation
3939
cf deploy -i OPERATION_ID -a ACTION [-u URL]`,
4040
Options: map[string]string{
4141
extDescriptorsOpt: "Extension descriptors",
42-
timeoutOpt: "Start apps timeout in seconds",
4342
deployServiceURLOpt: "Deploy service URL, by default 'deploy-service.<system-domain>'",
4443
versionRuleOpt: "Version rule (HIGHER, SAME_HIGHER, ALL)",
4544
operationIDOpt: "Active deploy operation ID",
4645
actionOpt: "Action to perform on active deploy operation (abort, retry, resume, monitor)",
4746
forceOpt: "Force deploy without confirmation for aborting conflicting processes",
4847
util.GetShortOption(noStartOpt): "Do not start apps",
4948
util.GetShortOption(namespaceOpt): "(EXPERIMENTAL) Namespace for the mta, applied to app and service names as well",
49+
util.GetShortOption(applyNamespaceAppNamesOpt): "Apply namespace to application names",
50+
util.GetShortOption(applyNamespaceServiceNamesOpt): "Apply namespace to service names",
51+
util.GetShortOption(applyNamespaceAppRoutesOpt): "Apply namespace to application routes",
5052
util.GetShortOption(deleteServicesOpt): "Recreate changed services / delete discontinued services",
5153
util.GetShortOption(deleteServiceKeysOpt): "Delete existing service keys and apply the new ones",
5254
util.GetShortOption(deleteServiceBrokersOpt): "Delete discontinued service brokers",
@@ -57,10 +59,10 @@ func (c *BlueGreenDeployCommand) GetPluginCommand() plugin.Command {
5759
util.GetShortOption(abortOnErrorOpt): "Auto-abort the process on any errors",
5860
util.GetShortOption(retriesOpt): "Retry the operation N times in case a non-content error occurs (default 3)",
5961
util.GetShortOption(skipIdleStart): "Directly start the new MTA version as 'live', skipping the 'idle' phase of the resources. Do not require further confirmation or testing before deleting the old version",
60-
util.GetShortOption(startTimeoutOpt): "Start app timeout in seconds",
6162
util.GetShortOption(stageTimeoutOpt): "Stage app timeout in seconds",
6263
util.GetShortOption(uploadTimeoutOpt): "Upload app timeout in seconds",
63-
util.GetShortOption(taskExecutionTimeoutOpt): "Task execution timeout in seconds",
64+
util.GetShortOption(taskExecutionTimeoutOpt): "Task execution timeout in seconds",
65+
util.CombineFullAndShortParameters(startTimeoutOpt, timeoutOpt): "Start app timeout in seconds",
6466
},
6567
},
6668
}

commands/deploy_command.go

+45-26
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ const (
4747
stageTimeoutOpt = "apps-stage-timeout"
4848
uploadTimeoutOpt = "apps-upload-timeout"
4949
taskExecutionTimeoutOpt = "apps-task-execution-timeout"
50+
applyNamespaceAppNamesOpt = "apply-namespace-app-names"
51+
applyNamespaceServiceNamesOpt = "apply-namespace-service-names"
52+
applyNamespaceAppRoutesOpt = "apply-namespace-app-routes"
5053
)
5154

5255
type listFlag struct {
@@ -98,16 +101,18 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
98101
HelpText: "Deploy a new multi-target app or sync changes to an existing one",
99102
UsageDetails: plugin.Usage{
100103
Usage: `Deploy a multi-target app archive
101-
cf deploy MTA [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u URL] [-f] [--retries RETRIES] [--no-start] [--namespace NAMESPACE] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--do-not-fail-on-missing-permissions] [--abort-on-error] [--strategy STRATEGY] [--skip-testing-phase] [--skip-idle-start] [--apps-start-timeout TIMEOUT] [--apps-stage-timeout TIMEOUT] [--apps-upload-timeout TIMEOUT] [--apps-task-execution-timeout TIMEOUT]
104+
105+
cf deploy MTA [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u URL] [-f] [--retries RETRIES] [--no-start] [--namespace NAMESPACE] [--apply-namespace-app-names=true/false] [--apply-namespace-service-names=true/false] [--apply-namespace-app-routes=true/false] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--do-not-fail-on-missing-permissions] [--abort-on-error] [--strategy STRATEGY] [--skip-testing-phase] [--skip-idle-start] [--apps-start-timeout TIMEOUT] [--apps-stage-timeout TIMEOUT] [--apps-upload-timeout TIMEOUT] [--apps-task-execution-timeout TIMEOUT]
106+
102107
103108
Perform action on an active deploy operation
104109
cf deploy -i OPERATION_ID -a ACTION [-u URL]
105110
106111
(EXPERIMENTAL) Deploy a multi-target app archive referenced by a remote URL
107-
<write MTA archive URL to STDOUT> | cf deploy [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u MTA_CONTROLLER_URL] [--retries RETRIES] [--no-start] [--namespace NAMESPACE] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--do-not-fail-on-missing-permissions] [--abort-on-error] [--strategy STRATEGY] [--skip-testing-phase] [--skip-idle-start] [--apps-start-timeout TIMEOUT] [--apps-stage-timeout TIMEOUT] [--apps-upload-timeout TIMEOUT] [--apps-task-execution-timeout TIMEOUT]`,
112+
<write MTA archive URL to STDOUT> | cf deploy [-e EXT_DESCRIPTOR[,...]] [-t TIMEOUT] [--version-rule VERSION_RULE] [-u MTA_CONTROLLER_URL] [--retries RETRIES] [--no-start] [--namespace NAMESPACE] [--apply-namespace-app-names=true/false] [--apply-namespace-service-names=true/false] [--apply-namespace-app-routes=true/false] [--delete-services] [--delete-service-keys] [--delete-service-brokers] [--keep-files] [--no-restart-subscribed-apps] [--do-not-fail-on-missing-permissions] [--abort-on-error] [--strategy STRATEGY] [--skip-testing-phase] [--skip-idle-start] [--apps-start-timeout TIMEOUT] [--apps-stage-timeout TIMEOUT] [--apps-upload-timeout TIMEOUT] [--apps-task-execution-timeout TIMEOUT]`,
113+
108114
Options: map[string]string{
109115
extDescriptorsOpt: "Extension descriptors",
110-
timeoutOpt: "Start apps timeout in seconds",
111116
deployServiceURLOpt: "Deploy service URL, by default 'deploy-service.<system-domain>'",
112117
versionRuleOpt: "Version rule (HIGHER, SAME_HIGHER, ALL)",
113118
operationIDOpt: "Active deploy operation ID",
@@ -116,7 +121,10 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
116121
moduleOpt: "Deploy list of modules which are contained in the deployment descriptor, in the current location",
117122
resourceOpt: "Deploy list of resources which are contained in the deployment descriptor, in the current location",
118123
util.GetShortOption(noStartOpt): "Do not start apps",
119-
util.GetShortOption(namespaceOpt): "(EXPERIMENTAL) Namespace for the mta, applied to app and service names as well",
124+
util.GetShortOption(namespaceOpt): "(EXPERIMENTAL) Namespace for the mta, applied to app and service names as well",
125+
util.GetShortOption(applyNamespaceAppNamesOpt): "Apply namespace to application names",
126+
util.GetShortOption(applyNamespaceServiceNamesOpt): "Apply namespace to service names",
127+
util.GetShortOption(applyNamespaceAppRoutesOpt): "Apply namespace to application routes",
120128
util.GetShortOption(deleteServicesOpt): "Recreate changed services / delete discontinued services",
121129
util.GetShortOption(deleteServiceKeysOpt): "Delete existing service keys and apply the new ones",
122130
util.GetShortOption(deleteServiceBrokersOpt): "Delete discontinued service brokers",
@@ -133,10 +141,10 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
133141
util.GetShortOption(strategyOpt): "Specify the deployment strategy when updating an mta (default, blue-green)",
134142
util.GetShortOption(skipTestingPhase): "(STRATEGY: BLUE-GREEN) Do not require confirmation for deleting the previously deployed MTA app",
135143
util.GetShortOption(skipIdleStart): "(STRATEGY: BLUE-GREEN) Directly start the new MTA version as 'live', skipping the 'idle' phase of the resources. Do not require further confirmation or testing before deleting the old version",
136-
util.GetShortOption(startTimeoutOpt): "Start app timeout in seconds",
137144
util.GetShortOption(stageTimeoutOpt): "Stage app timeout in seconds",
138145
util.GetShortOption(uploadTimeoutOpt): "Upload app timeout in seconds",
139-
util.GetShortOption(taskExecutionTimeoutOpt): "Task execution timeout in seconds",
146+
util.GetShortOption(taskExecutionTimeoutOpt): "Task execution timeout in seconds",
147+
util.CombineFullAndShortParameters(startTimeoutOpt, timeoutOpt): "Start app timeout in seconds",
140148
},
141149
},
142150
}
@@ -190,7 +198,10 @@ func (c *DeployCommand) defineCommandOptions(flags *flag.FlagSet) {
190198
flags.String(versionRuleOpt, "", "")
191199
flags.Bool(deleteServicesOpt, false, "")
192200
flags.Bool(noStartOpt, false, "")
193-
flags.String(namespaceOpt, "", "")
201+
flags.String(namespaceOpt, "", "")
202+
flags.String(applyNamespaceAppNamesOpt, "", "")
203+
flags.String(applyNamespaceServiceNamesOpt, "", "")
204+
flags.String(applyNamespaceAppRoutesOpt, "", "")
194205
flags.Bool(deleteServiceKeysOpt, false, "")
195206
flags.Bool(deleteServiceBrokersOpt, false, "")
196207
flags.Bool(keepFilesOpt, false, "")
@@ -224,7 +235,7 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
224235

225236
mtaElementsCalculator := createMtaElementsCalculator(flags)
226237

227-
rawMtaArchive, err := c.getMtaArchive(positionalArgs, mtaElementsCalculator)
238+
rawMtaArchive, err := c.getMtaArchive(positionalArgs, mtaElementsCalculator)
228239
if err != nil {
229240
ui.Failed("Error retrieving MTA: %s", err.Error())
230241
return Failure
@@ -337,6 +348,15 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
337348
// Build the process instance
338349
processBuilder := NewDeploymentStrategy(flags, c.processTypeProvider).CreateProcessBuilder()
339350
processBuilder.Namespace(namespace)
351+
if(namespace == "") {
352+
processBuilder.Parameter("applyNamespaceAppNames", "false")
353+
processBuilder.Parameter("applyNamespaceServiceNames", "false")
354+
processBuilder.Parameter("applyNamespaceAppRoutes", "false")
355+
} else {
356+
processBuilder.Parameter("applyNamespaceAppNames", GetStringOpt(applyNamespaceAppNamesOpt, flags))
357+
processBuilder.Parameter("applyNamespaceServiceNames", GetStringOpt(applyNamespaceServiceNamesOpt, flags))
358+
processBuilder.Parameter("applyNamespaceAppRoutes", GetStringOpt(applyNamespaceAppRoutesOpt, flags))
359+
}
340360
processBuilder.Parameter("appArchiveId", strings.Join(uploadedArchivePartIds, ","))
341361
processBuilder.Parameter("mtaExtDescriptorId", strings.Join(uploadedExtDescriptorIDs, ","))
342362
processBuilder.Parameter("mtaId", mtaId)
@@ -653,28 +673,13 @@ func (deployCommandFlagsValidator) ValidateParsedFlags(flags *flag.FlagSet) erro
653673
err = fmt.Errorf("%s is not a valid deployment strategy, available strategies: %v", f.Value.String(), AvailableStrategies())
654674
return
655675
}
656-
case timeoutOpt:
657-
if e := ValidateTimeoutOption(f.Name, flags, 259200); e != nil {
658-
err = e
659-
return
660-
}
661-
case startTimeoutOpt:
662-
if e := ValidateTimeoutOption(f.Name, flags, 259200); e != nil {
663-
err = e
664-
return
665-
}
666-
case stageTimeoutOpt:
676+
case timeoutOpt, startTimeoutOpt, stageTimeoutOpt, uploadTimeoutOpt, taskExecutionTimeoutOpt:
667677
if e := ValidateTimeoutOption(f.Name, flags, 259200); e != nil {
668678
err = e
669679
return
670680
}
671-
case uploadTimeoutOpt:
672-
if e := ValidateTimeoutOption(f.Name, flags, 259200); e != nil {
673-
err = e
674-
return
675-
}
676-
case taskExecutionTimeoutOpt:
677-
if e := ValidateTimeoutOption(f.Name, flags, 259200); e != nil {
681+
case applyNamespaceAppNamesOpt, applyNamespaceServiceNamesOpt, applyNamespaceAppRoutesOpt:
682+
if e := ValidateBooleanFlag(f.Name, flags); e != nil {
678683
err = e
679684
return
680685
}
@@ -695,3 +700,17 @@ func ValidateTimeoutOption(optionName string, flags *flag.FlagSet, maxAllowedVal
695700
}
696701
return nil
697702
}
703+
704+
func ValidateBooleanFlag(flagName string, flags *flag.FlagSet) error {
705+
flagValueStr := flags.Lookup(flagName).Value.String()
706+
707+
if flagValueStr == "" {
708+
return fmt.Errorf("%s flag defined but no argument specified", flagName)
709+
}
710+
711+
if flagValueStr != "true" && flagValueStr != "false" {
712+
return fmt.Errorf("invalid value for %s: %s. Expected true or false.", flagName, flagValueStr)
713+
}
714+
715+
return nil
716+
}

util/cf_command_options_util.go

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import (
55
"strings"
66
)
77

8+
func CombineFullAndShortParameters(fullParameter string, shortParameter string) string {
9+
return GetShortOption(fullParameter) + ", -" + shortParameter
10+
}
11+
812
//GetShortOption ...
913
func GetShortOption(option string) string {
1014
var opt bytes.Buffer

0 commit comments

Comments
 (0)