@@ -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
5255type listFlag struct {
@@ -98,13 +101,16 @@ 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" ,
110116 deployServiceURLOpt : "Deploy service URL, by default 'deploy-service.<system-domain>'" ,
@@ -115,7 +121,10 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
115121 moduleOpt : "Deploy list of modules which are contained in the deployment descriptor, in the current location" ,
116122 resourceOpt : "Deploy list of resources which are contained in the deployment descriptor, in the current location" ,
117123 util .GetShortOption (noStartOpt ): "Do not start apps" ,
118- 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 on app names, app routes and service names" ,
125+ util .GetShortOption (applyNamespaceAppNamesOpt ): "(EXPERIMENTAL) Apply namespace to application names: (true, false)" ,
126+ util .GetShortOption (applyNamespaceServiceNamesOpt ): "(EXPERIMENTAL) Apply namespace to service names: (true, false)" ,
127+ util .GetShortOption (applyNamespaceAppRoutesOpt ): "(EXPERIMENTAL) Apply namespace to application routes: (true, false)" ,
119128 util .GetShortOption (deleteServicesOpt ): "Recreate changed services / delete discontinued services" ,
120129 util .GetShortOption (deleteServiceKeysOpt ): "Delete existing service keys and apply the new ones" ,
121130 util .GetShortOption (deleteServiceBrokersOpt ): "Delete discontinued service brokers" ,
@@ -189,7 +198,10 @@ func (c *DeployCommand) defineCommandOptions(flags *flag.FlagSet) {
189198 flags .String (versionRuleOpt , "" , "" )
190199 flags .Bool (deleteServicesOpt , false , "" )
191200 flags .Bool (noStartOpt , false , "" )
192- flags .String (namespaceOpt , "" , "" )
201+ flags .String (namespaceOpt , "" , "" )
202+ flags .String (applyNamespaceAppNamesOpt , "" , "" )
203+ flags .String (applyNamespaceServiceNamesOpt , "" , "" )
204+ flags .String (applyNamespaceAppRoutesOpt , "" , "" )
193205 flags .Bool (deleteServiceKeysOpt , false , "" )
194206 flags .Bool (deleteServiceBrokersOpt , false , "" )
195207 flags .Bool (keepFilesOpt , false , "" )
@@ -336,6 +348,10 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
336348 // Build the process instance
337349 processBuilder := NewDeploymentStrategy (flags , c .processTypeProvider ).CreateProcessBuilder ()
338350 processBuilder .Namespace (namespace )
351+ processBuilder .Parameter ("applyNamespaceAppNames" , GetStringOpt (applyNamespaceAppNamesOpt , flags ))
352+ processBuilder .Parameter ("applyNamespaceServiceNames" , GetStringOpt (applyNamespaceServiceNamesOpt , flags ))
353+ processBuilder .Parameter ("applyNamespaceAppRoutes" , GetStringOpt (applyNamespaceAppRoutesOpt , flags ))
354+
339355 processBuilder .Parameter ("appArchiveId" , strings .Join (uploadedArchivePartIds , "," ))
340356 processBuilder .Parameter ("mtaExtDescriptorId" , strings .Join (uploadedExtDescriptorIDs , "," ))
341357 processBuilder .Parameter ("mtaId" , mtaId )
@@ -652,28 +668,13 @@ func (deployCommandFlagsValidator) ValidateParsedFlags(flags *flag.FlagSet) erro
652668 err = fmt .Errorf ("%s is not a valid deployment strategy, available strategies: %v" , f .Value .String (), AvailableStrategies ())
653669 return
654670 }
655- case timeoutOpt :
656- if e := ValidateTimeoutOption (f .Name , flags , 259200 ); e != nil {
657- err = e
658- return
659- }
660- case startTimeoutOpt :
661- if e := ValidateTimeoutOption (f .Name , flags , 259200 ); e != nil {
662- err = e
663- return
664- }
665- case stageTimeoutOpt :
666- if e := ValidateTimeoutOption (f .Name , flags , 259200 ); e != nil {
667- err = e
668- return
669- }
670- case uploadTimeoutOpt :
671+ case timeoutOpt , startTimeoutOpt , stageTimeoutOpt , uploadTimeoutOpt , taskExecutionTimeoutOpt :
671672 if e := ValidateTimeoutOption (f .Name , flags , 259200 ); e != nil {
672673 err = e
673674 return
674675 }
675- case taskExecutionTimeoutOpt :
676- if e := ValidateTimeoutOption (f .Name , flags , 259200 ); e != nil {
676+ case applyNamespaceAppNamesOpt , applyNamespaceServiceNamesOpt , applyNamespaceAppRoutesOpt :
677+ if e := ValidateBooleanFlag (f .Name , flags ); e != nil {
677678 err = e
678679 return
679680 }
@@ -694,3 +695,17 @@ func ValidateTimeoutOption(optionName string, flags *flag.FlagSet, maxAllowedVal
694695 }
695696 return nil
696697}
698+
699+ func ValidateBooleanFlag (flagName string , flags * flag.FlagSet ) error {
700+ flagValueStr := flags .Lookup (flagName ).Value .String ()
701+
702+ if flagValueStr == "" {
703+ return fmt .Errorf ("%s flag defined but no argument specified" , flagName )
704+ }
705+
706+ if flagValueStr != "true" && flagValueStr != "false" {
707+ return fmt .Errorf ("Invalid value for %s: %s. Expected true or false." , flagName , flagValueStr )
708+ }
709+
710+ return nil
711+ }
0 commit comments