Skip to content

Commit bfadcfc

Browse files
authored
feat: add support to CE Project names (#399)
1 parent 0fec3e5 commit bfadcfc

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

code-engine/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ statement instead the previous block.
208208
| <a name="input_cd_code_engine_job_retrylimit"></a> [cd\_code\_engine\_job\_retrylimit](#input\_cd\_code\_engine\_job\_retrylimit) | The number of times to rerun an instance of the job before the job is marked as failed. | `string` | `"3"` | no |
209209
| <a name="input_cd_code_engine_memory"></a> [cd\_code\_engine\_memory](#input\_cd\_code\_engine\_memory) | The amount of memory set for the instance of the application or job. Use M for megabytes or G for gigabytes. | `string` | `"0.5G"` | no |
210210
| <a name="input_cd_code_engine_project"></a> [cd\_code\_engine\_project](#input\_cd\_code\_engine\_project) | The name of the Code Engine project to use for the CD pipeline promoted code. The project is created if it does not already exist. | `string` | `"Sample_CD_Project"` | no |
211+
| <a name="input_cd_code_engine_project_prefix"></a> [cd\_code\_engine\_project\_prefix](#input\_cd\_code\_engine\_project\_prefix) | A string that will be prefixed to `cd_code_engine_project`. This takes precedence over values set in `code_engine_project_prefix`. | `string` | `""` | no |
211212
| <a name="input_cd_code_engine_region"></a> [cd\_code\_engine\_region](#input\_cd\_code\_engine\_region) | The region to create/lookup for the Code Engine project. | `string` | `""` | no |
212213
| <a name="input_cd_code_engine_remove_refs"></a> [cd\_code\_engine\_remove\_refs](#input\_cd\_code\_engine\_remove\_refs) | Remove references to unspecified configuration resources (configmap/secret) references (pulled from env-from-configmaps, env-from-secrets along with auto-managed by CD). | `string` | `"false"` | no |
213214
| <a name="input_cd_code_engine_resource_group"></a> [cd\_code\_engine\_resource\_group](#input\_cd\_code\_engine\_resource\_group) | The resource group of the Code Engine project. | `string` | `""` | no |
@@ -378,6 +379,7 @@ statement instead the previous block.
378379
| <a name="input_ci_code_engine_job_retrylimit"></a> [ci\_code\_engine\_job\_retrylimit](#input\_ci\_code\_engine\_job\_retrylimit) | The number of times to rerun an instance of the job before the job is marked as failed. | `string` | `"3"` | no |
379380
| <a name="input_ci_code_engine_memory"></a> [ci\_code\_engine\_memory](#input\_ci\_code\_engine\_memory) | The amount of memory set for the instance of the application or job. Use M for megabytes or G for gigabytes. | `string` | `"0.5G"` | no |
380381
| <a name="input_ci_code_engine_project"></a> [ci\_code\_engine\_project](#input\_ci\_code\_engine\_project) | The name of the Code Engine project to use for the CI pipeline build. The project is created if it does not already exist. | `string` | `"Sample_CI_Project"` | no |
382+
| <a name="input_ci_code_engine_project_prefix"></a> [ci\_code\_engine\_project\_prefix](#input\_ci\_code\_engine\_project\_prefix) | A string that will be prefixed to `ci_code_engine_project`. This takes precedence over values set in `code_engine_project_prefix`. | `string` | `""` | no |
381383
| <a name="input_ci_code_engine_region"></a> [ci\_code\_engine\_region](#input\_ci\_code\_engine\_region) | The region to create/lookup for the Code Engine project. | `string` | `""` | no |
382384
| <a name="input_ci_code_engine_registry_domain"></a> [ci\_code\_engine\_registry\_domain](#input\_ci\_code\_engine\_registry\_domain) | The container registry URL domain that is used to build and tag the image. Useful when using private-endpoint container registry. | `string` | `""` | no |
383385
| <a name="input_ci_code_engine_remove_refs"></a> [ci\_code\_engine\_remove\_refs](#input\_ci\_code\_engine\_remove\_refs) | Remove references to unspecified configuration resources (configmap/secret) references (pulled from env-from-configmaps, env-from-secrets along with auto-managed by CD). | `string` | `"false"` | no |
@@ -510,6 +512,7 @@ statement instead the previous block.
510512
| <a name="input_ci_trigger_timed_pruner_enable"></a> [ci\_trigger\_timed\_pruner\_enable](#input\_ci\_trigger\_timed\_pruner\_enable) | Set to `true` to enable the timed Pruner trigger. | `bool` | `false` | no |
511513
| <a name="input_ci_trigger_timed_pruner_name"></a> [ci\_trigger\_timed\_pruner\_name](#input\_ci\_trigger\_timed\_pruner\_name) | The name of the timed Pruner trigger. | `string` | `"Evidence Pruner Timed Trigger"` | no |
512514
| <a name="input_code_engine_project"></a> [code\_engine\_project](#input\_code\_engine\_project) | The name of the Code Engine project to use. Created if it does not exist. Applies to both the CI and CD toolchains. To set individually use `ci_code_engine_project` and `cd_code_engine_project`. | `string` | `""` | no |
515+
| <a name="input_code_engine_project_prefix"></a> [code\_engine\_project\_prefix](#input\_code\_engine\_project\_prefix) | A string that will be prefixed to`ci_code_engine_project` and `cd_code_engine_project`. | `string` | `""` | no |
513516
| <a name="input_compliance_base_image"></a> [compliance\_base\_image](#input\_compliance\_base\_image) | Pipeline baseimage to run most of the built-in pipeline code. | `string` | `""` | no |
514517
| <a name="input_compliance_pipeline_branch"></a> [compliance\_pipeline\_branch](#input\_compliance\_pipeline\_branch) | The Compliance Pipeline branch. | `string` | `"open-v9"` | no |
515518
| <a name="input_cos_api_key_secret_crn"></a> [cos\_api\_key\_secret\_crn](#input\_cos\_api\_key\_secret\_crn) | The CRN for the Cloud Object Storage apikey. | `string` | `""` | no |
@@ -565,6 +568,7 @@ statement instead the previous block.
565568
| <a name="input_pipeline_ibmcloud_api_key_secret_name"></a> [pipeline\_ibmcloud\_api\_key\_secret\_name](#input\_pipeline\_ibmcloud\_api\_key\_secret\_name) | Name of the Cloud API key secret in the secret provider. Applies to the CI, CD and CC toolchains. For specific versions see `ci_pipeline_ibmcloud_api_key_secret_name`, `cd_pipeline_ibmcloud_api_key_secret_name` and `cc_pipeline_ibmcloud_api_key_secret_name`. | `string` | `"ibmcloud-api-key"` | no |
566569
| <a name="input_pr_pipeline_git_tag"></a> [pr\_pipeline\_git\_tag](#input\_pr\_pipeline\_git\_tag) | The GIT tag within the pipeline definitions repository for the Compliance PR Pipeline. | `string` | `""` | no |
567570
| <a name="input_registry_namespace"></a> [registry\_namespace](#input\_registry\_namespace) | A unique namespace within the IBM Cloud Container Registry region where the application image is stored. | `string` | `""` | no |
571+
| <a name="input_registry_namespace"></a> [registry\_namespace\_suffix](#input\_registry\_namespace\_suffix) | A string that can be appended to the `registry_namespace` value to help ensure uniqueness.| `string` | `""` | no |
568572
| <a name="input_repo_git_token_secret_crn"></a> [repo\_git\_token\_secret\_crn](#input\_repo\_git\_token\_secret\_crn) | The CRN for the repositories Git Token. | `string` | `""` | no |
569573
| <a name="input_repo_git_token_secret_name"></a> [repo\_git\_token\_secret\_name](#input\_repo\_git\_token\_secret\_name) | Name of the Git token secret in the secret provider. Specifying a secret name for the Git Token automatically sets the authentication type to `pat`. | `string` | `""` | no |
570574
| <a name="input_repo_group"></a> [repo\_group](#input\_repo\_group) | Specify Git user or group for your application. This must be set if the repository authentication type is `pat` (personal access token). | `string` | `""` | no |

code-engine/main.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ locals {
4747
inventory_repo_existing_url = (var.inventory_repo_existing_url != "") ? var.inventory_repo_existing_url : var.inventory_repo_url
4848
evidence_repo_existing_url = (var.evidence_repo_existing_url != "") ? var.evidence_repo_existing_url : var.evidence_repo_url
4949
issues_repo_existing_url = (var.issues_repo_existing_url != "") ? var.issues_repo_existing_url : var.issues_repo_url
50+
51+
ci_code_engine_project_prefix = (var.ci_code_engine_project_prefix == "") ? var.code_engine_project_prefix : var.ci_code_engine_project_prefix
52+
cd_code_engine_project_prefix = (var.cd_code_engine_project_prefix == "") ? var.code_engine_project_prefix : var.cd_code_engine_project_prefix
53+
ci_code_engine_project = (var.ci_code_engine_project == "") ? var.code_engine_project : var.ci_code_engine_project
54+
cd_code_engine_project = (var.cd_code_engine_project == "") ? var.code_engine_project : var.cd_code_engine_project
55+
registry_namespace = format("%s%s", var.registry_namespace, var.registry_namespace_suffix)
5056
}
5157

5258
module "devsecops_ci_toolchain" {
@@ -57,7 +63,7 @@ module "devsecops_ci_toolchain" {
5763
toolchain_region = (var.ci_toolchain_region == "") ? var.toolchain_region : replace(replace(var.ci_toolchain_region, "ibm:yp:", ""), "ibm:ys1:", "")
5864
toolchain_resource_group = (var.ci_toolchain_resource_group == "") ? var.toolchain_resource_group : var.ci_toolchain_resource_group
5965
toolchain_description = var.ci_toolchain_description
60-
registry_namespace = (var.registry_namespace != "") ? var.registry_namespace : var.ci_registry_namespace
66+
registry_namespace = (local.registry_namespace != "") ? local.registry_namespace : var.ci_registry_namespace
6167
ibmcloud_api = var.ibmcloud_api
6268
compliance_base_image = (var.ci_compliance_base_image == "") ? var.compliance_base_image : var.ci_compliance_base_image
6369
ci_pipeline_branch = (var.ci_compliance_pipeline_branch == "") ? var.compliance_pipeline_branch : var.ci_compliance_pipeline_branch
@@ -217,7 +223,7 @@ module "devsecops_ci_toolchain" {
217223

218224
#CODE ENGINE
219225
deployment_target = (var.ci_deployment_target == "") ? var.deployment_target : var.ci_deployment_target
220-
code_engine_project = (var.ci_code_engine_project == "") ? var.code_engine_project : var.ci_code_engine_project
226+
code_engine_project = format("%s%s", local.ci_code_engine_project_prefix, local.ci_code_engine_project)
221227
code_engine_region = (var.ci_code_engine_region == "") ? var.toolchain_region : var.ci_code_engine_region
222228
code_engine_resource_group = (var.ci_code_engine_resource_group == "") ? var.toolchain_resource_group : var.ci_code_engine_resource_group
223229
code_engine_build_strategy = var.ci_code_engine_build_strategy
@@ -522,7 +528,7 @@ module "devsecops_cd_toolchain" {
522528

523529
#CODE ENGINE
524530
deployment_target = (var.cd_deployment_target == "") ? var.deployment_target : var.cd_deployment_target
525-
code_engine_project = (var.cd_code_engine_project == "") ? var.code_engine_project : var.cd_code_engine_project
531+
code_engine_project = format("%s%s", local.cd_code_engine_project_prefix, local.cd_code_engine_project)
526532
code_engine_region = (var.cd_code_engine_region == "") ? var.toolchain_region : var.cd_code_engine_region
527533
code_engine_resource_group = (var.cd_code_engine_resource_group == "") ? var.toolchain_resource_group : var.cd_code_engine_resource_group
528534
code_engine_binding_resource_group = var.cd_code_engine_binding_resource_group

code-engine/variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@ variable "code_engine_project" {
546546
default = ""
547547
}
548548

549+
variable "code_engine_project_prefix" {
550+
type = string
551+
description = "A string that will be prefixed to`ci_code_engine_project` and `cd_code_engine_project`."
552+
default = ""
553+
}
554+
549555
##### END OF COMMON VARIABLES ############
550556
##### START OF CI VARIABLES ##############
551557

@@ -585,6 +591,12 @@ variable "registry_namespace" {
585591
default = ""
586592
}
587593

594+
variable "registry_namespace_suffix" {
595+
type = string
596+
description = "A string that can be appended to the `registry_namespace` value to help ensure uniqueness."
597+
default = ""
598+
}
599+
588600
variable "ci_registry_namespace" {
589601
type = string
590602
description = "A unique namespace within the IBM Cloud Container Registry region where the application image is stored. (deprecated. Use `registry_namespace`)"
@@ -792,6 +804,12 @@ variable "ci_code_engine_project" {
792804
default = "Sample_CI_Project"
793805
}
794806

807+
variable "ci_code_engine_project_prefix" {
808+
type = string
809+
description = "A string that will be prefixed to `ci_code_engine_project`. This takes precedence over values set in `code_engine_project_prefix`."
810+
default = ""
811+
}
812+
795813
variable "ci_code_engine_region" {
796814
type = string
797815
description = "The region to create/lookup for the Code Engine project."
@@ -2630,6 +2648,12 @@ variable "cd_code_engine_project" {
26302648
default = "Sample_CD_Project"
26312649
}
26322650

2651+
variable "cd_code_engine_project_prefix" {
2652+
type = string
2653+
description = "A string that will be prefixed to `cd_code_engine_project`. This takes precedence over values set in `code_engine_project_prefix`."
2654+
default = ""
2655+
}
2656+
26332657
variable "cd_code_engine_region" {
26342658
type = string
26352659
description = "The region to create/lookup for the Code Engine project."

ibm_catalog.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,6 +4279,13 @@
42794279
"description": "The CRN for the IBMCloud apikey. Applies to the CI, CD and CC toolchains. Can be set independently using the toolchain specific version of the variable.",
42804280
"required": false
42814281
},
4282+
{
4283+
"key": "registry_namespace_suffix",
4284+
"type": "string",
4285+
"default_value": "",
4286+
"description": "A string that can be appended to the `registry_namespace` value to help ensure uniqueness.",
4287+
"required": true
4288+
},
42824289
{
42834290
"key": "pipeline_doi_api_key_secret_crn",
42844291
"type": "string",
@@ -4328,6 +4335,34 @@
43284335
"description": "Prefix name for the cloned compliance repos.",
43294336
"required": false
43304337
},
4338+
{
4339+
"key": "code_engine_project_prefix",
4340+
"type": "string",
4341+
"default_value": "",
4342+
"description": "A string that will be prefixed to`ci_code_engine_project` and `cd_code_engine_project`.",
4343+
"required": true
4344+
},
4345+
{
4346+
"key": "code_engine_project",
4347+
"type": "string",
4348+
"default_value": "",
4349+
"description": "The name of the Code Engine project to use. Created if it does not exist. Applies to both the CI and CD toolchains. To set individually use `ci_code_engine_project` and `cd_code_engine_project`.",
4350+
"required": true
4351+
},
4352+
{
4353+
"key": "ci_code_engine_project_prefix",
4354+
"type": "string",
4355+
"default_value": "",
4356+
"description": "A string that will be prefixed to `ci_code_engine_project`. This takes precedence over values set in `code_engine_project_prefix`.",
4357+
"required": true
4358+
},
4359+
{
4360+
"key": "cd_code_engine_project_prefix",
4361+
"type": "string",
4362+
"default_value": "",
4363+
"description": "A string that will be prefixed to `cd_code_engine_project`. This takes precedence over values set in `code_engine_project_prefix`.",
4364+
"required": true
4365+
},
43314366
{
43324367
"key": "compliance_pipeline_branch",
43334368
"type": "string",

0 commit comments

Comments
 (0)