Skip to content

Commit 34f8cfe

Browse files
authored
Merge pull request #209 from cloudfoundry/add-apply-namespace-as-suffix-parameter
Add --apply-namespace-as-suffix parameter
2 parents 0885574 + 64f9bff commit 34f8cfe

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

commands/blue_green_deploy_command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ 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] [--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]
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] [--apply-namespace-as-suffix 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]`,
@@ -49,6 +49,7 @@ func (c *BlueGreenDeployCommand) GetPluginCommand() plugin.Command {
4949
util.GetShortOption(applyNamespaceAppNamesOpt): "(EXPERIMENTAL) Apply namespace to application names: (true, false)",
5050
util.GetShortOption(applyNamespaceServiceNamesOpt): "(EXPERIMENTAL) Apply namespace to service names: (true, false)",
5151
util.GetShortOption(applyNamespaceAppRoutesOpt): "(EXPERIMENTAL) Apply namespace to application routes: (true, false)",
52+
util.GetShortOption(applyNamespaceAsSuffix): "(EXPERIMENTAL) Apply namespace as a suffix rather than a prefix: (true, false)",
5253
util.GetShortOption(deleteServicesOpt): "Recreate changed services / delete discontinued services",
5354
util.GetShortOption(deleteServiceKeysOpt): "Delete existing service keys and apply the new ones",
5455
util.GetShortOption(deleteServiceBrokersOpt): "Delete discontinued service brokers",

commands/deploy_command.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ const (
5050
applyNamespaceAppNamesOpt = "apply-namespace-app-names"
5151
applyNamespaceServiceNamesOpt = "apply-namespace-service-names"
5252
applyNamespaceAppRoutesOpt = "apply-namespace-app-routes"
53+
applyNamespaceAsSuffix = "apply-namespace-as-suffix"
54+
maxNamespaceSize = 36
5355
)
5456

5557
type listFlag struct {
@@ -102,14 +104,14 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
102104
UsageDetails: plugin.Usage{
103105
Usage: `Deploy a multi-target app archive
104106
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]
107+
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] [--apply-namespace-as-suffix 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]
106108
107109
108110
Perform action on an active deploy operation
109111
cf deploy -i OPERATION_ID -a ACTION [-u URL]
110112
111113
(EXPERIMENTAL) Deploy a multi-target app archive referenced by a remote URL
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]`,
114+
<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] [--apply-namespace-as-suffix 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]`,
113115

114116
Options: map[string]string{
115117
extDescriptorsOpt: "Extension descriptors",
@@ -125,6 +127,7 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
125127
util.GetShortOption(applyNamespaceAppNamesOpt): "(EXPERIMENTAL) Apply namespace to application names: (true, false)",
126128
util.GetShortOption(applyNamespaceServiceNamesOpt): "(EXPERIMENTAL) Apply namespace to service names: (true, false)",
127129
util.GetShortOption(applyNamespaceAppRoutesOpt): "(EXPERIMENTAL) Apply namespace to application routes: (true, false)",
130+
util.GetShortOption(applyNamespaceAsSuffix): "(EXPERIMENTAL) Apply namespace as a suffix rather than a prefix: (true, false)",
128131
util.GetShortOption(deleteServicesOpt): "Recreate changed services / delete discontinued services",
129132
util.GetShortOption(deleteServiceKeysOpt): "Delete existing service keys and apply the new ones",
130133
util.GetShortOption(deleteServiceBrokersOpt): "Delete discontinued service brokers",
@@ -202,6 +205,7 @@ func (c *DeployCommand) defineCommandOptions(flags *flag.FlagSet) {
202205
flags.String(applyNamespaceAppNamesOpt, "", "")
203206
flags.String(applyNamespaceServiceNamesOpt, "", "")
204207
flags.String(applyNamespaceAppRoutesOpt, "", "")
208+
flags.String(applyNamespaceAsSuffix, "", "")
205209
flags.Bool(deleteServiceKeysOpt, false, "")
206210
flags.Bool(deleteServiceBrokersOpt, false, "")
207211
flags.Bool(keepFilesOpt, false, "")
@@ -351,6 +355,7 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
351355
processBuilder.Parameter("applyNamespaceAppNames", GetStringOpt(applyNamespaceAppNamesOpt, flags))
352356
processBuilder.Parameter("applyNamespaceServiceNames", GetStringOpt(applyNamespaceServiceNamesOpt, flags))
353357
processBuilder.Parameter("applyNamespaceAppRoutes", GetStringOpt(applyNamespaceAppRoutesOpt, flags))
358+
processBuilder.Parameter("applyNamespaceAsSuffix", GetStringOpt(applyNamespaceAsSuffix, flags))
354359

355360
processBuilder.Parameter("appArchiveId", strings.Join(uploadedArchivePartIds, ","))
356361
processBuilder.Parameter("mtaExtDescriptorId", strings.Join(uploadedExtDescriptorIDs, ","))
@@ -668,12 +673,17 @@ func (deployCommandFlagsValidator) ValidateParsedFlags(flags *flag.FlagSet) erro
668673
err = fmt.Errorf("%s is not a valid deployment strategy, available strategies: %v", f.Value.String(), AvailableStrategies())
669674
return
670675
}
676+
case namespaceOpt:
677+
if len(f.Value.String()) > maxNamespaceSize {
678+
err = fmt.Errorf("Invalid value for namespace. The namespace cannot be more than %d symbols.", maxNamespaceSize)
679+
return
680+
}
671681
case timeoutOpt, startTimeoutOpt, stageTimeoutOpt, uploadTimeoutOpt, taskExecutionTimeoutOpt:
672682
if e := ValidateTimeoutOption(f.Name, flags, 259200); e != nil {
673683
err = e
674684
return
675685
}
676-
case applyNamespaceAppNamesOpt, applyNamespaceServiceNamesOpt, applyNamespaceAppRoutesOpt:
686+
case applyNamespaceAppNamesOpt, applyNamespaceServiceNamesOpt, applyNamespaceAppRoutesOpt, applyNamespaceAsSuffix:
677687
if e := ValidateBooleanFlag(f.Name, flags); e != nil {
678688
err = e
679689
return

0 commit comments

Comments
 (0)