@@ -47,6 +47,9 @@ const (
47
47
stageTimeoutOpt = "apps-stage-timeout"
48
48
uploadTimeoutOpt = "apps-upload-timeout"
49
49
taskExecutionTimeoutOpt = "apps-task-execution-timeout"
50
+ applyNamespaceAppNamesOpt = "apply-namespace-app-names"
51
+ applyNamespaceServiceNamesOpt = "apply-namespace-service-names"
52
+ applyNamespaceAppRoutesOpt = "apply-namespace-app-routes"
50
53
)
51
54
52
55
type listFlag struct {
@@ -98,16 +101,18 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
98
101
HelpText : "Deploy a new multi-target app or sync changes to an existing one" ,
99
102
UsageDetails : plugin.Usage {
100
103
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
+
102
107
103
108
Perform action on an active deploy operation
104
109
cf deploy -i OPERATION_ID -a ACTION [-u URL]
105
110
106
111
(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
+
108
114
Options : map [string ]string {
109
115
extDescriptorsOpt : "Extension descriptors" ,
110
- timeoutOpt : "Start apps timeout in seconds" ,
111
116
deployServiceURLOpt : "Deploy service URL, by default 'deploy-service.<system-domain>'" ,
112
117
versionRuleOpt : "Version rule (HIGHER, SAME_HIGHER, ALL)" ,
113
118
operationIDOpt : "Active deploy operation ID" ,
@@ -116,7 +121,10 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
116
121
moduleOpt : "Deploy list of modules which are contained in the deployment descriptor, in the current location" ,
117
122
resourceOpt : "Deploy list of resources which are contained in the deployment descriptor, in the current location" ,
118
123
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" ,
120
128
util .GetShortOption (deleteServicesOpt ): "Recreate changed services / delete discontinued services" ,
121
129
util .GetShortOption (deleteServiceKeysOpt ): "Delete existing service keys and apply the new ones" ,
122
130
util .GetShortOption (deleteServiceBrokersOpt ): "Delete discontinued service brokers" ,
@@ -133,10 +141,10 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
133
141
util .GetShortOption (strategyOpt ): "Specify the deployment strategy when updating an mta (default, blue-green)" ,
134
142
util .GetShortOption (skipTestingPhase ): "(STRATEGY: BLUE-GREEN) Do not require confirmation for deleting the previously deployed MTA app" ,
135
143
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" ,
137
144
util .GetShortOption (stageTimeoutOpt ): "Stage app timeout in seconds" ,
138
145
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" ,
140
148
},
141
149
},
142
150
}
@@ -190,7 +198,10 @@ func (c *DeployCommand) defineCommandOptions(flags *flag.FlagSet) {
190
198
flags .String (versionRuleOpt , "" , "" )
191
199
flags .Bool (deleteServicesOpt , false , "" )
192
200
flags .Bool (noStartOpt , false , "" )
193
- flags .String (namespaceOpt , "" , "" )
201
+ flags .String (namespaceOpt , "" , "" )
202
+ flags .String (applyNamespaceAppNamesOpt , "" , "" )
203
+ flags .String (applyNamespaceServiceNamesOpt , "" , "" )
204
+ flags .String (applyNamespaceAppRoutesOpt , "" , "" )
194
205
flags .Bool (deleteServiceKeysOpt , false , "" )
195
206
flags .Bool (deleteServiceBrokersOpt , false , "" )
196
207
flags .Bool (keepFilesOpt , false , "" )
@@ -224,7 +235,7 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
224
235
225
236
mtaElementsCalculator := createMtaElementsCalculator (flags )
226
237
227
- rawMtaArchive , err := c .getMtaArchive (positionalArgs , mtaElementsCalculator )
238
+ rawMtaArchive , err := c .getMtaArchive (positionalArgs , mtaElementsCalculator )
228
239
if err != nil {
229
240
ui .Failed ("Error retrieving MTA: %s" , err .Error ())
230
241
return Failure
@@ -337,6 +348,15 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
337
348
// Build the process instance
338
349
processBuilder := NewDeploymentStrategy (flags , c .processTypeProvider ).CreateProcessBuilder ()
339
350
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
+ }
340
360
processBuilder .Parameter ("appArchiveId" , strings .Join (uploadedArchivePartIds , "," ))
341
361
processBuilder .Parameter ("mtaExtDescriptorId" , strings .Join (uploadedExtDescriptorIDs , "," ))
342
362
processBuilder .Parameter ("mtaId" , mtaId )
@@ -653,28 +673,13 @@ func (deployCommandFlagsValidator) ValidateParsedFlags(flags *flag.FlagSet) erro
653
673
err = fmt .Errorf ("%s is not a valid deployment strategy, available strategies: %v" , f .Value .String (), AvailableStrategies ())
654
674
return
655
675
}
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 :
667
677
if e := ValidateTimeoutOption (f .Name , flags , 259200 ); e != nil {
668
678
err = e
669
679
return
670
680
}
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 {
678
683
err = e
679
684
return
680
685
}
@@ -695,3 +700,17 @@ func ValidateTimeoutOption(optionName string, flags *flag.FlagSet, maxAllowedVal
695
700
}
696
701
return nil
697
702
}
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
+ }
0 commit comments