@@ -43,6 +43,9 @@ const (
43
43
strategyOpt = "strategy"
44
44
skipTestingPhase = "skip-testing-phase"
45
45
skipIdleStart = "skip-idle-start"
46
+ applyNamespaceAppNamesOpt = "apply-namespace-app-names"
47
+ applyNamespaceServiceNamesOpt = "apply-namespace-service-names"
48
+ applyNamespaceAppRoutesOpt = "apply-namespace-app-routes"
46
49
)
47
50
48
51
type listFlag struct {
@@ -94,13 +97,13 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
94
97
HelpText : "Deploy a new multi-target app or sync changes to an existing one" ,
95
98
UsageDetails : plugin.Usage {
96
99
Usage : `Deploy a multi-target app archive
97
- 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]
100
+ 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]
98
101
99
102
Perform action on an active deploy operation
100
103
cf deploy -i OPERATION_ID -a ACTION [-u URL]
101
104
102
105
(EXPERIMENTAL) Deploy a multi-target app archive referenced by a remote URL
103
- <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]` ,
106
+ <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]` ,
104
107
Options : map [string ]string {
105
108
extDescriptorsOpt : "Extension descriptors" ,
106
109
deployServiceURLOpt : "Deploy service URL, by default 'deploy-service.<system-domain>'" ,
@@ -112,7 +115,10 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
112
115
moduleOpt : "Deploy list of modules which are contained in the deployment descriptor, in the current location" ,
113
116
resourceOpt : "Deploy list of resources which are contained in the deployment descriptor, in the current location" ,
114
117
util .GetShortOption (noStartOpt ): "Do not start apps" ,
115
- util .GetShortOption (namespaceOpt ): "(EXPERIMENTAL) Namespace for the mta, applied to app and service names as well" ,
118
+ util .GetShortOption (namespaceOpt ): "(EXPERIMENTAL) Namespace for the mta, applied to app and service names as well" ,
119
+ util .GetShortOption (applyNamespaceAppNamesOpt ): "Apply namespace to application names" ,
120
+ util .GetShortOption (applyNamespaceServiceNamesOpt ): "Apply namespace to service names" ,
121
+ util .GetShortOption (applyNamespaceAppRoutesOpt ): "Apply namespace to application routes" ,
116
122
util .GetShortOption (deleteServicesOpt ): "Recreate changed services / delete discontinued services" ,
117
123
util .GetShortOption (deleteServiceKeysOpt ): "Delete existing service keys and apply the new ones" ,
118
124
util .GetShortOption (deleteServiceBrokersOpt ): "Delete discontinued service brokers" ,
@@ -161,7 +167,10 @@ func (c *DeployCommand) defineCommandOptions(flags *flag.FlagSet) {
161
167
flags .String (versionRuleOpt , "" , "" )
162
168
flags .Bool (deleteServicesOpt , false , "" )
163
169
flags .Bool (noStartOpt , false , "" )
164
- flags .String (namespaceOpt , "" , "" )
170
+ flags .String (namespaceOpt , "" , "" )
171
+ flags .String (applyNamespaceAppNamesOpt , "" , "" )
172
+ flags .String (applyNamespaceServiceNamesOpt , "" , "" )
173
+ flags .String (applyNamespaceAppRoutesOpt , "" , "" )
165
174
flags .Bool (deleteServiceKeysOpt , false , "" )
166
175
flags .Bool (deleteServiceBrokersOpt , false , "" )
167
176
flags .Bool (keepFilesOpt , false , "" )
@@ -303,6 +312,15 @@ func (c *DeployCommand) executeInternal(positionalArgs []string, dsHost string,
303
312
// Build the process instance
304
313
processBuilder := NewDeploymentStrategy (flags , c .processTypeProvider ).CreateProcessBuilder ()
305
314
processBuilder .Namespace (namespace )
315
+ if (namespace == "" ) {
316
+ processBuilder .Parameter ("applyNamespaceAppNames" , "false" )
317
+ processBuilder .Parameter ("applyNamespaceServiceNames" , "false" )
318
+ processBuilder .Parameter ("applyNamespaceAppRoutes" , "false" )
319
+ } else {
320
+ processBuilder .Parameter ("applyNamespaceAppNames" , GetStringOpt (applyNamespaceAppNamesOpt , flags ))
321
+ processBuilder .Parameter ("applyNamespaceServiceNames" , GetStringOpt (applyNamespaceServiceNamesOpt , flags ))
322
+ processBuilder .Parameter ("applyNamespaceAppRoutes" , GetStringOpt (applyNamespaceAppRoutesOpt , flags ))
323
+ }
306
324
processBuilder .Parameter ("appArchiveId" , strings .Join (uploadedArchivePartIds , "," ))
307
325
processBuilder .Parameter ("mtaExtDescriptorId" , strings .Join (uploadedExtDescriptorIDs , "," ))
308
326
processBuilder .Parameter ("mtaId" , mtaId )
@@ -609,12 +627,31 @@ type deployCommandFlagsValidator struct{}
609
627
func (deployCommandFlagsValidator ) ValidateParsedFlags (flags * flag.FlagSet ) error {
610
628
var err error
611
629
flags .Visit (func (f * flag.Flag ) {
612
- if f .Name == strategyOpt {
630
+ switch f .Name {
631
+ case strategyOpt :
613
632
if f .Value .String () == "" {
614
633
err = errors .New ("strategy flag defined but no argument specified" )
615
634
} else if ! util .Contains (AvailableStrategies (), f .Value .String ()) {
616
635
err = fmt .Errorf ("%s is not a valid deployment strategy, available strategies: %v" , f .Value .String (), AvailableStrategies ())
617
636
}
637
+ case applyNamespaceAppNamesOpt :
638
+ if f .Value .String () == "" {
639
+ err = errors .New ("ApplyNamespaceAppNames flag defined but no argument specified" )
640
+ } else if f .Value .String () != "true" && f .Value .String () != "false" {
641
+ err = fmt .Errorf ("invalid value for --%s, expected true or false" , applyNamespaceAppNamesOpt )
642
+ }
643
+ case applyNamespaceServiceNamesOpt :
644
+ if f .Value .String () == "" {
645
+ err = errors .New ("ApplyNamespaceServiceNames flag defined but no argument specified" )
646
+ } else if f .Value .String () != "true" && f .Value .String () != "false" {
647
+ err = fmt .Errorf ("invalid value for --%s, expected true or false" , applyNamespaceServiceNamesOpt )
648
+ }
649
+ case applyNamespaceAppRoutesOpt :
650
+ if f .Value .String () == "" {
651
+ err = errors .New ("ApplyNamespaceAppRoutes flag defined but no argument specified" )
652
+ } else if f .Value .String () != "true" && f .Value .String () != "false" {
653
+ err = fmt .Errorf ("invalid value for --%s, expected true or false" , applyNamespaceAppRoutesOpt )
654
+ }
618
655
}
619
656
})
620
657
if err != nil {
0 commit comments