github.com/SAP/jenkins-library@v1.362.0/cmd/cloudFoundryDeploy_generated.go (about) 1 // Code generated by piper's step-generator. DO NOT EDIT. 2 3 package cmd 4 5 import ( 6 "fmt" 7 "os" 8 "path/filepath" 9 "time" 10 11 "github.com/SAP/jenkins-library/pkg/config" 12 "github.com/SAP/jenkins-library/pkg/log" 13 "github.com/SAP/jenkins-library/pkg/piperenv" 14 "github.com/SAP/jenkins-library/pkg/splunk" 15 "github.com/SAP/jenkins-library/pkg/telemetry" 16 "github.com/SAP/jenkins-library/pkg/validation" 17 "github.com/spf13/cobra" 18 ) 19 20 type cloudFoundryDeployOptions struct { 21 APIEndpoint string `json:"apiEndpoint,omitempty"` 22 AppName string `json:"appName,omitempty"` 23 ArtifactVersion string `json:"artifactVersion,omitempty"` 24 CommitHash string `json:"commitHash,omitempty"` 25 CfHome string `json:"cfHome,omitempty"` 26 CfNativeDeployParameters string `json:"cfNativeDeployParameters,omitempty"` 27 CfPluginHome string `json:"cfPluginHome,omitempty"` 28 DeployDockerImage string `json:"deployDockerImage,omitempty"` 29 DeployTool string `json:"deployTool,omitempty"` 30 BuildTool string `json:"buildTool,omitempty"` 31 DeployType string `json:"deployType,omitempty"` 32 DockerPassword string `json:"dockerPassword,omitempty"` 33 DockerUsername string `json:"dockerUsername,omitempty"` 34 KeepOldInstance bool `json:"keepOldInstance,omitempty"` 35 LoginParameters string `json:"loginParameters,omitempty"` 36 Manifest string `json:"manifest,omitempty"` 37 ManifestVariables []string `json:"manifestVariables,omitempty"` 38 ManifestVariablesFiles []string `json:"manifestVariablesFiles,omitempty"` 39 MtaDeployParameters string `json:"mtaDeployParameters,omitempty"` 40 MtaExtensionDescriptor string `json:"mtaExtensionDescriptor,omitempty"` 41 MtaExtensionCredentials map[string]interface{} `json:"mtaExtensionCredentials,omitempty"` 42 MtaPath string `json:"mtaPath,omitempty"` 43 Org string `json:"org,omitempty"` 44 Password string `json:"password,omitempty"` 45 SmokeTestScript string `json:"smokeTestScript,omitempty"` 46 SmokeTestStatusCode int `json:"smokeTestStatusCode,omitempty"` 47 Space string `json:"space,omitempty"` 48 Username string `json:"username,omitempty"` 49 } 50 51 type cloudFoundryDeployInflux struct { 52 deployment_data struct { 53 fields struct { 54 artifactURL string 55 deployTime string 56 commitHash string 57 jobTrigger string 58 } 59 tags struct { 60 artifactVersion string 61 deployUser string 62 deployResult string 63 cfAPIEndpoint string 64 cfOrg string 65 cfSpace string 66 } 67 } 68 } 69 70 func (i *cloudFoundryDeployInflux) persist(path, resourceName string) { 71 measurementContent := []struct { 72 measurement string 73 valType string 74 name string 75 value interface{} 76 }{ 77 {valType: config.InfluxField, measurement: "deployment_data", name: "artifactUrl", value: i.deployment_data.fields.artifactURL}, 78 {valType: config.InfluxField, measurement: "deployment_data", name: "deployTime", value: i.deployment_data.fields.deployTime}, 79 {valType: config.InfluxField, measurement: "deployment_data", name: "commitHash", value: i.deployment_data.fields.commitHash}, 80 {valType: config.InfluxField, measurement: "deployment_data", name: "jobTrigger", value: i.deployment_data.fields.jobTrigger}, 81 {valType: config.InfluxTag, measurement: "deployment_data", name: "artifactVersion", value: i.deployment_data.tags.artifactVersion}, 82 {valType: config.InfluxTag, measurement: "deployment_data", name: "deployUser", value: i.deployment_data.tags.deployUser}, 83 {valType: config.InfluxTag, measurement: "deployment_data", name: "deployResult", value: i.deployment_data.tags.deployResult}, 84 {valType: config.InfluxTag, measurement: "deployment_data", name: "cfApiEndpoint", value: i.deployment_data.tags.cfAPIEndpoint}, 85 {valType: config.InfluxTag, measurement: "deployment_data", name: "cfOrg", value: i.deployment_data.tags.cfOrg}, 86 {valType: config.InfluxTag, measurement: "deployment_data", name: "cfSpace", value: i.deployment_data.tags.cfSpace}, 87 } 88 89 errCount := 0 90 for _, metric := range measurementContent { 91 err := piperenv.SetResourceParameter(path, resourceName, filepath.Join(metric.measurement, fmt.Sprintf("%vs", metric.valType), metric.name), metric.value) 92 if err != nil { 93 log.Entry().WithError(err).Error("Error persisting influx environment.") 94 errCount++ 95 } 96 } 97 if errCount > 0 { 98 log.Entry().Error("failed to persist Influx environment") 99 } 100 } 101 102 // CloudFoundryDeployCommand Deploys an application to Cloud Foundry 103 func CloudFoundryDeployCommand() *cobra.Command { 104 const STEP_NAME = "cloudFoundryDeploy" 105 106 metadata := cloudFoundryDeployMetadata() 107 var stepConfig cloudFoundryDeployOptions 108 var startTime time.Time 109 var influx cloudFoundryDeployInflux 110 var logCollector *log.CollectorHook 111 var splunkClient *splunk.Splunk 112 telemetryClient := &telemetry.Telemetry{} 113 114 var createCloudFoundryDeployCmd = &cobra.Command{ 115 Use: STEP_NAME, 116 Short: "Deploys an application to Cloud Foundry", 117 Long: `Deploys an application to a test or production space within Cloud Foundry.`, 118 PreRunE: func(cmd *cobra.Command, _ []string) error { 119 startTime = time.Now() 120 log.SetStepName(STEP_NAME) 121 log.SetVerbose(GeneralConfig.Verbose) 122 123 GeneralConfig.GitHubAccessTokens = ResolveAccessTokens(GeneralConfig.GitHubTokens) 124 125 path, _ := os.Getwd() 126 fatalHook := &log.FatalHook{CorrelationID: GeneralConfig.CorrelationID, Path: path} 127 log.RegisterHook(fatalHook) 128 129 err := PrepareConfig(cmd, &metadata, STEP_NAME, &stepConfig, config.OpenPiperFile) 130 if err != nil { 131 log.SetErrorCategory(log.ErrorConfiguration) 132 return err 133 } 134 log.RegisterSecret(stepConfig.DockerPassword) 135 log.RegisterSecret(stepConfig.DockerUsername) 136 log.RegisterSecret(stepConfig.Password) 137 log.RegisterSecret(stepConfig.Username) 138 139 if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { 140 sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) 141 log.RegisterHook(&sentryHook) 142 } 143 144 if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 || len(GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint) > 0 { 145 splunkClient = &splunk.Splunk{} 146 logCollector = &log.CollectorHook{CorrelationID: GeneralConfig.CorrelationID} 147 log.RegisterHook(logCollector) 148 } 149 150 if err = log.RegisterANSHookIfConfigured(GeneralConfig.CorrelationID); err != nil { 151 log.Entry().WithError(err).Warn("failed to set up SAP Alert Notification Service log hook") 152 } 153 154 validation, err := validation.New(validation.WithJSONNamesForStructFields(), validation.WithPredefinedErrorMessages()) 155 if err != nil { 156 return err 157 } 158 if err = validation.ValidateStruct(stepConfig); err != nil { 159 log.SetErrorCategory(log.ErrorConfiguration) 160 return err 161 } 162 163 return nil 164 }, 165 Run: func(_ *cobra.Command, _ []string) { 166 stepTelemetryData := telemetry.CustomData{} 167 stepTelemetryData.ErrorCode = "1" 168 handler := func() { 169 influx.persist(GeneralConfig.EnvRootPath, "influx") 170 config.RemoveVaultSecretFiles() 171 stepTelemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds()) 172 stepTelemetryData.ErrorCategory = log.GetErrorCategory().String() 173 stepTelemetryData.PiperCommitHash = GitCommit 174 telemetryClient.SetData(&stepTelemetryData) 175 telemetryClient.Send() 176 if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 { 177 splunkClient.Initialize(GeneralConfig.CorrelationID, 178 GeneralConfig.HookConfig.SplunkConfig.Dsn, 179 GeneralConfig.HookConfig.SplunkConfig.Token, 180 GeneralConfig.HookConfig.SplunkConfig.Index, 181 GeneralConfig.HookConfig.SplunkConfig.SendLogs) 182 splunkClient.Send(telemetryClient.GetData(), logCollector) 183 } 184 if len(GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint) > 0 { 185 splunkClient.Initialize(GeneralConfig.CorrelationID, 186 GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint, 187 GeneralConfig.HookConfig.SplunkConfig.ProdCriblToken, 188 GeneralConfig.HookConfig.SplunkConfig.ProdCriblIndex, 189 GeneralConfig.HookConfig.SplunkConfig.SendLogs) 190 splunkClient.Send(telemetryClient.GetData(), logCollector) 191 } 192 } 193 log.DeferExitHandler(handler) 194 defer handler() 195 telemetryClient.Initialize(GeneralConfig.NoTelemetry, STEP_NAME, GeneralConfig.HookConfig.PendoConfig.Token) 196 cloudFoundryDeploy(stepConfig, &stepTelemetryData, &influx) 197 stepTelemetryData.ErrorCode = "0" 198 log.Entry().Info("SUCCESS") 199 }, 200 } 201 202 addCloudFoundryDeployFlags(createCloudFoundryDeployCmd, &stepConfig) 203 return createCloudFoundryDeployCmd 204 } 205 206 func addCloudFoundryDeployFlags(cmd *cobra.Command, stepConfig *cloudFoundryDeployOptions) { 207 cmd.Flags().StringVar(&stepConfig.APIEndpoint, "apiEndpoint", `https://api.cf.eu10.hana.ondemand.com`, "Cloud Foundry API endpoint") 208 cmd.Flags().StringVar(&stepConfig.AppName, "appName", os.Getenv("PIPER_appName"), "Defines the name of the application to be deployed to the Cloud Foundry space") 209 cmd.Flags().StringVar(&stepConfig.ArtifactVersion, "artifactVersion", os.Getenv("PIPER_artifactVersion"), "The artifact version, used for influx reporting") 210 cmd.Flags().StringVar(&stepConfig.CommitHash, "commitHash", os.Getenv("PIPER_commitHash"), "The commit hash, used for influx reporting") 211 cmd.Flags().StringVar(&stepConfig.CfHome, "cfHome", os.Getenv("PIPER_cfHome"), "The cf home folder used by the cf cli. If not provided the default assumed by the cf cli is used.") 212 cmd.Flags().StringVar(&stepConfig.CfNativeDeployParameters, "cfNativeDeployParameters", os.Getenv("PIPER_cfNativeDeployParameters"), "Additional parameters passed to cf native deployment command") 213 cmd.Flags().StringVar(&stepConfig.CfPluginHome, "cfPluginHome", os.Getenv("PIPER_cfPluginHome"), "The cf plugin home folder used by the cf cli. If not provided the default assumed by the cf cli is used.") 214 cmd.Flags().StringVar(&stepConfig.DeployDockerImage, "deployDockerImage", os.Getenv("PIPER_deployDockerImage"), "Docker image deployments are supported (via manifest file in general)[https://docs.cloudfoundry.org/devguide/deploy-apps/manifest-attributes.html#docker]. If no manifest is used, this parameter defines the image to be deployed. The specified name of the image is passed to the `--docker-image` parameter of the cf CLI and must adhere it's naming pattern (e.g. REPO/IMAGE:TAG). See (cf CLI documentation)[https://docs.cloudfoundry.org/devguide/deploy-apps/push-docker.html] for details. Note: The used Docker registry must be visible for the targeted Cloud Foundry instance.") 215 cmd.Flags().StringVar(&stepConfig.DeployTool, "deployTool", os.Getenv("PIPER_deployTool"), "Defines the tool which should be used for deployment.") 216 cmd.Flags().StringVar(&stepConfig.BuildTool, "buildTool", os.Getenv("PIPER_buildTool"), "Defines the tool which is used for building the artifact. If provided, `deployTool` is automatically derived from it. For MTA projects, `deployTool` defaults to `mtaDeployPlugin`. For other projects `cf_native` will be used.") 217 cmd.Flags().StringVar(&stepConfig.DeployType, "deployType", `standard`, "Defines the type of deployment, either `standard` deployment which results in a system downtime or a zero-downtime `blue-green` deployment. If 'cf_native' as deployTool and 'blue-green' as deployType is used in combination, your manifest.yaml may only contain one application. If this application has the option 'no-route' active the deployType will be changed to 'standard'.") 218 cmd.Flags().StringVar(&stepConfig.DockerPassword, "dockerPassword", os.Getenv("PIPER_dockerPassword"), "If the specified image in `deployDockerImage` is contained in a Docker registry, which requires authorization, this defines the password to be used.") 219 cmd.Flags().StringVar(&stepConfig.DockerUsername, "dockerUsername", os.Getenv("PIPER_dockerUsername"), "If the specified image in `deployDockerImage` is contained in a Docker registry, which requires authorization, this defines the username to be used.") 220 cmd.Flags().BoolVar(&stepConfig.KeepOldInstance, "keepOldInstance", false, "In case of a `blue-green` deployment the old instance will be deleted by default. If this option is set to true the old instance will remain stopped in the Cloud Foundry space.") 221 cmd.Flags().StringVar(&stepConfig.LoginParameters, "loginParameters", os.Getenv("PIPER_loginParameters"), "Addition command line options for cf login command. No escaping/quoting is performed. Not recommended for productive environments.") 222 cmd.Flags().StringVar(&stepConfig.Manifest, "manifest", os.Getenv("PIPER_manifest"), "Defines the manifest to be used for deployment to Cloud Foundry.") 223 cmd.Flags().StringSliceVar(&stepConfig.ManifestVariables, "manifestVariables", []string{}, "Defines a list of variables in the form `key=value` which are used for variable substitution within the file given by manifest.") 224 cmd.Flags().StringSliceVar(&stepConfig.ManifestVariablesFiles, "manifestVariablesFiles", []string{`manifest-variables.yml`}, "path(s) of the Yaml file(s) containing the variable values to use as a replacement in the manifest file. The order of the files is relevant in case there are conflicting variable names and values within variable files. In such a case, the values of the last file win.") 225 cmd.Flags().StringVar(&stepConfig.MtaDeployParameters, "mtaDeployParameters", `-f`, "Additional parameters passed to mta deployment command") 226 cmd.Flags().StringVar(&stepConfig.MtaExtensionDescriptor, "mtaExtensionDescriptor", os.Getenv("PIPER_mtaExtensionDescriptor"), "Defines additional extension descriptor file for deployment with the mtaDeployPlugin") 227 228 cmd.Flags().StringVar(&stepConfig.MtaPath, "mtaPath", os.Getenv("PIPER_mtaPath"), "Defines the path to *.mtar for deployment with the mtaDeployPlugin") 229 cmd.Flags().StringVar(&stepConfig.Org, "org", os.Getenv("PIPER_org"), "Cloud Foundry target organization.") 230 cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password") 231 cmd.Flags().StringVar(&stepConfig.SmokeTestScript, "smokeTestScript", `blueGreenCheckScript.sh`, "Allows to specify a script which performs a check during blue-green deployment. The script gets the FQDN as parameter and returns `exit code 0` in case check returned `smokeTestStatusCode`. More details can be found [here](https://github.com/bluemixgaragelondon/cf-blue-green-deploy#how-to-use). Currently this option is only considered for deployTool `cf_native`.") 232 cmd.Flags().IntVar(&stepConfig.SmokeTestStatusCode, "smokeTestStatusCode", 200, "Expected status code returned by the check.") 233 cmd.Flags().StringVar(&stepConfig.Space, "space", os.Getenv("PIPER_space"), "Cloud Foundry target space") 234 cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User name used for deployment") 235 236 cmd.MarkFlagRequired("apiEndpoint") 237 cmd.MarkFlagRequired("org") 238 cmd.MarkFlagRequired("password") 239 cmd.MarkFlagRequired("space") 240 cmd.MarkFlagRequired("username") 241 } 242 243 // retrieve step metadata 244 func cloudFoundryDeployMetadata() config.StepData { 245 var theMetaData = config.StepData{ 246 Metadata: config.StepMetadata{ 247 Name: "cloudFoundryDeploy", 248 Aliases: []config.Alias{}, 249 Description: "Deploys an application to Cloud Foundry", 250 }, 251 Spec: config.StepSpec{ 252 Inputs: config.StepInputs{ 253 Secrets: []config.StepSecrets{ 254 {Name: "cfCredentialsId", Description: "Jenkins 'Username with password' credentials ID containing user and password to authenticate to the Cloud Foundry API.", Type: "jenkins", Aliases: []config.Alias{{Name: "cloudFoundry/credentialsId", Deprecated: true}}}, 255 {Name: "dockerCredentialsId", Description: "Jenkins 'Username with password' credentials ID containing user and password to authenticate to the Docker registry.", Type: "jenkins"}, 256 }, 257 Parameters: []config.StepParameters{ 258 { 259 Name: "apiEndpoint", 260 ResourceRef: []config.ResourceReference{}, 261 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 262 Type: "string", 263 Mandatory: true, 264 Aliases: []config.Alias{{Name: "cfApiEndpoint"}, {Name: "cloudFoundry/apiEndpoint", Deprecated: true}}, 265 Default: `https://api.cf.eu10.hana.ondemand.com`, 266 }, 267 { 268 Name: "appName", 269 ResourceRef: []config.ResourceReference{}, 270 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 271 Type: "string", 272 Mandatory: false, 273 Aliases: []config.Alias{{Name: "cfAppName"}, {Name: "cloudFoundry/appName", Deprecated: true}}, 274 Default: os.Getenv("PIPER_appName"), 275 }, 276 { 277 Name: "artifactVersion", 278 ResourceRef: []config.ResourceReference{ 279 { 280 Name: "commonPipelineEnvironment", 281 Param: "artifactVersion", 282 }, 283 }, 284 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 285 Type: "string", 286 Mandatory: false, 287 Aliases: []config.Alias{}, 288 Default: os.Getenv("PIPER_artifactVersion"), 289 }, 290 { 291 Name: "commitHash", 292 ResourceRef: []config.ResourceReference{ 293 { 294 Name: "commonPipelineEnvironment", 295 Param: "git/headCommitId", 296 }, 297 }, 298 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 299 Type: "string", 300 Mandatory: false, 301 Aliases: []config.Alias{}, 302 Default: os.Getenv("PIPER_commitHash"), 303 }, 304 { 305 Name: "cfHome", 306 ResourceRef: []config.ResourceReference{}, 307 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 308 Type: "string", 309 Mandatory: false, 310 Aliases: []config.Alias{}, 311 Default: os.Getenv("PIPER_cfHome"), 312 }, 313 { 314 Name: "cfNativeDeployParameters", 315 ResourceRef: []config.ResourceReference{}, 316 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 317 Type: "string", 318 Mandatory: false, 319 Aliases: []config.Alias{}, 320 Default: os.Getenv("PIPER_cfNativeDeployParameters"), 321 }, 322 { 323 Name: "cfPluginHome", 324 ResourceRef: []config.ResourceReference{}, 325 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 326 Type: "string", 327 Mandatory: false, 328 Aliases: []config.Alias{}, 329 Default: os.Getenv("PIPER_cfPluginHome"), 330 }, 331 { 332 Name: "deployDockerImage", 333 ResourceRef: []config.ResourceReference{}, 334 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 335 Type: "string", 336 Mandatory: false, 337 Aliases: []config.Alias{}, 338 Default: os.Getenv("PIPER_deployDockerImage"), 339 }, 340 { 341 Name: "deployTool", 342 ResourceRef: []config.ResourceReference{}, 343 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 344 Type: "string", 345 Mandatory: false, 346 Aliases: []config.Alias{}, 347 Default: os.Getenv("PIPER_deployTool"), 348 }, 349 { 350 Name: "buildTool", 351 ResourceRef: []config.ResourceReference{ 352 { 353 Name: "commonPipelineEnvironment", 354 Param: "buildTool", 355 }, 356 }, 357 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 358 Type: "string", 359 Mandatory: false, 360 Aliases: []config.Alias{}, 361 Default: os.Getenv("PIPER_buildTool"), 362 }, 363 { 364 Name: "deployType", 365 ResourceRef: []config.ResourceReference{}, 366 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 367 Type: "string", 368 Mandatory: false, 369 Aliases: []config.Alias{}, 370 Default: `standard`, 371 }, 372 { 373 Name: "dockerPassword", 374 ResourceRef: []config.ResourceReference{ 375 { 376 Name: "dockerCredentialsId", 377 Param: "password", 378 Type: "secret", 379 }, 380 }, 381 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 382 Type: "string", 383 Mandatory: false, 384 Aliases: []config.Alias{}, 385 Default: os.Getenv("PIPER_dockerPassword"), 386 }, 387 { 388 Name: "dockerUsername", 389 ResourceRef: []config.ResourceReference{ 390 { 391 Name: "dockerCredentialsId", 392 Param: "username", 393 Type: "secret", 394 }, 395 }, 396 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 397 Type: "string", 398 Mandatory: false, 399 Aliases: []config.Alias{}, 400 Default: os.Getenv("PIPER_dockerUsername"), 401 }, 402 { 403 Name: "keepOldInstance", 404 ResourceRef: []config.ResourceReference{}, 405 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 406 Type: "bool", 407 Mandatory: false, 408 Aliases: []config.Alias{}, 409 Default: false, 410 }, 411 { 412 Name: "loginParameters", 413 ResourceRef: []config.ResourceReference{}, 414 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 415 Type: "string", 416 Mandatory: false, 417 Aliases: []config.Alias{}, 418 Default: os.Getenv("PIPER_loginParameters"), 419 }, 420 { 421 Name: "manifest", 422 ResourceRef: []config.ResourceReference{}, 423 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 424 Type: "string", 425 Mandatory: false, 426 Aliases: []config.Alias{{Name: "cfManifest"}, {Name: "cloudFoundry/manifest", Deprecated: true}}, 427 Default: os.Getenv("PIPER_manifest"), 428 }, 429 { 430 Name: "manifestVariables", 431 ResourceRef: []config.ResourceReference{}, 432 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 433 Type: "[]string", 434 Mandatory: false, 435 Aliases: []config.Alias{{Name: "cfManifestVariables"}, {Name: "cloudFoundry/manifestVariables", Deprecated: true}}, 436 Default: []string{}, 437 }, 438 { 439 Name: "manifestVariablesFiles", 440 ResourceRef: []config.ResourceReference{}, 441 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 442 Type: "[]string", 443 Mandatory: false, 444 Aliases: []config.Alias{{Name: "cfManifestVariablesFiles"}, {Name: "cloudFoundry/manifestVariablesFiles", Deprecated: true}}, 445 Default: []string{`manifest-variables.yml`}, 446 }, 447 { 448 Name: "mtaDeployParameters", 449 ResourceRef: []config.ResourceReference{}, 450 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 451 Type: "string", 452 Mandatory: false, 453 Aliases: []config.Alias{}, 454 Default: `-f`, 455 }, 456 { 457 Name: "mtaExtensionDescriptor", 458 ResourceRef: []config.ResourceReference{}, 459 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 460 Type: "string", 461 Mandatory: false, 462 Aliases: []config.Alias{{Name: "cloudFoundry/mtaExtensionDescriptor", Deprecated: true}}, 463 Default: os.Getenv("PIPER_mtaExtensionDescriptor"), 464 }, 465 { 466 Name: "mtaExtensionCredentials", 467 ResourceRef: []config.ResourceReference{}, 468 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 469 Type: "map[string]interface{}", 470 Mandatory: false, 471 Aliases: []config.Alias{{Name: "cloudFoundry/mtaExtensionCredentials", Deprecated: true}}, 472 }, 473 { 474 Name: "mtaPath", 475 ResourceRef: []config.ResourceReference{ 476 { 477 Name: "commonPipelineEnvironment", 478 Param: "mtarFilePath", 479 }, 480 }, 481 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 482 Type: "string", 483 Mandatory: false, 484 Aliases: []config.Alias{}, 485 Default: os.Getenv("PIPER_mtaPath"), 486 }, 487 { 488 Name: "org", 489 ResourceRef: []config.ResourceReference{}, 490 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 491 Type: "string", 492 Mandatory: true, 493 Aliases: []config.Alias{{Name: "cfOrg"}, {Name: "cloudFoundry/org", Deprecated: true}}, 494 Default: os.Getenv("PIPER_org"), 495 }, 496 { 497 Name: "password", 498 ResourceRef: []config.ResourceReference{ 499 { 500 Name: "cfCredentialsId", 501 Param: "password", 502 Type: "secret", 503 }, 504 505 { 506 Name: "cloudfoundryVaultSecretName", 507 Type: "vaultSecret", 508 Default: "cloudfoundry-$(org)-$(space)", 509 }, 510 }, 511 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 512 Type: "string", 513 Mandatory: true, 514 Aliases: []config.Alias{}, 515 Default: os.Getenv("PIPER_password"), 516 }, 517 { 518 Name: "smokeTestScript", 519 ResourceRef: []config.ResourceReference{}, 520 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 521 Type: "string", 522 Mandatory: false, 523 Aliases: []config.Alias{}, 524 Default: `blueGreenCheckScript.sh`, 525 }, 526 { 527 Name: "smokeTestStatusCode", 528 ResourceRef: []config.ResourceReference{}, 529 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 530 Type: "int", 531 Mandatory: false, 532 Aliases: []config.Alias{}, 533 Default: 200, 534 }, 535 { 536 Name: "space", 537 ResourceRef: []config.ResourceReference{}, 538 Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, 539 Type: "string", 540 Mandatory: true, 541 Aliases: []config.Alias{{Name: "cfSpace"}, {Name: "cloudFoundry/space", Deprecated: true}}, 542 Default: os.Getenv("PIPER_space"), 543 }, 544 { 545 Name: "username", 546 ResourceRef: []config.ResourceReference{ 547 { 548 Name: "cfCredentialsId", 549 Param: "username", 550 Type: "secret", 551 }, 552 553 { 554 Name: "cloudfoundryVaultSecretName", 555 Type: "vaultSecret", 556 Default: "cloudfoundry-$(org)-$(space)", 557 }, 558 }, 559 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 560 Type: "string", 561 Mandatory: true, 562 Aliases: []config.Alias{}, 563 Default: os.Getenv("PIPER_username"), 564 }, 565 }, 566 }, 567 Containers: []config.Container{ 568 {Name: "cfDeploy", Image: "ppiper/cf-cli:latest"}, 569 }, 570 Outputs: config.StepOutputs{ 571 Resources: []config.StepResources{ 572 { 573 Name: "influx", 574 Type: "influx", 575 Parameters: []map[string]interface{}{ 576 {"name": "deployment_data", "fields": []map[string]string{{"name": "artifactUrl"}, {"name": "deployTime"}, {"name": "commitHash"}, {"name": "jobTrigger"}}, "tags": []map[string]string{{"name": "artifactVersion"}, {"name": "deployUser"}, {"name": "deployResult"}, {"name": "cfApiEndpoint"}, {"name": "cfOrg"}, {"name": "cfSpace"}}}, 577 }, 578 }, 579 }, 580 }, 581 }, 582 } 583 return theMetaData 584 }