Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date-based versioning support for Code Engine #5951

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.mod|go.sum|.*.map|^.secrets.baseline$",
"lines": null
},
"generated_at": "2025-01-28T03:10:54Z",
"generated_at": "2025-02-06T19:26:40Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -478,15 +478,15 @@
"hashed_secret": "dc61ac50e6f36d09340d8ca062da1f0d4215004f",
"is_secret": false,
"is_verified": false,
"line_number": 198,
"line_number": 199,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "470851178a9e3a16c35bc88232c21d04c555e5ca",
"is_secret": false,
"is_verified": false,
"line_number": 270,
"line_number": 271,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -888,23 +888,23 @@
"hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670",
"is_secret": false,
"is_verified": false,
"line_number": 3658,
"line_number": 3659,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6",
"is_secret": false,
"is_verified": false,
"line_number": 3671,
"line_number": 3672,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1",
"is_secret": false,
"is_verified": false,
"line_number": 3712,
"line_number": 3713,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -942,15 +942,15 @@
"hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9",
"is_secret": false,
"is_verified": false,
"line_number": 2369,
"line_number": 2370,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437",
"is_secret": false,
"is_verified": false,
"line_number": 2375,
"line_number": 2376,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -1978,7 +1978,7 @@
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 453,
"line_number": 506,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -2016,7 +2016,7 @@
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 233,
"line_number": 272,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -2026,7 +2026,7 @@
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 283,
"line_number": 336,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -2046,23 +2046,23 @@
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 741,
"line_number": 785,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "3c956707ac29b4a200e47fceffa923341eed7e4f",
"is_secret": false,
"is_verified": false,
"line_number": 1006,
"line_number": 1064,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b5366a2d2ac98dae978423083f8b09e5cddc705d",
"is_secret": false,
"is_verified": false,
"line_number": 1327,
"line_number": 1385,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -2124,23 +2124,23 @@
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 508,
"line_number": 552,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "a99bf28e18370eb20e9cc79a1e7f8c379075f69c",
"is_secret": false,
"is_verified": false,
"line_number": 680,
"line_number": 738,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b5366a2d2ac98dae978423083f8b09e5cddc705d",
"is_secret": false,
"is_verified": false,
"line_number": 850,
"line_number": 908,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -2150,23 +2150,23 @@
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 482,
"line_number": 526,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "3c956707ac29b4a200e47fceffa923341eed7e4f",
"is_secret": false,
"is_verified": false,
"line_number": 670,
"line_number": 728,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b5366a2d2ac98dae978423083f8b09e5cddc705d",
"is_secret": false,
"is_verified": false,
"line_number": 885,
"line_number": 943,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
6 changes: 6 additions & 0 deletions examples/ibm-code-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ resource "ibm_code_engine_app" "code_engine_app_instance" {
|------|-------------|
| build | Reference to a build that is associated with the application. |
| build_run | Reference to a build run that is associated with the application. |
| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application. |
| created_at | The timestamp when the resource was created. |
| endpoint | Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. |
| endpoint_internal | The URL to the app that is only visible within the project. |
Expand Down Expand Up @@ -334,6 +335,7 @@ resource "ibm_code_engine_function" "code_engine_function_instance" {

| Name | Description |
|------|-------------|
| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function. |
| created_at | The timestamp when the resource was created. |
| endpoint | URL to invoke the function. |
| endpoint_internal | URL to function that is only visible within the project. |
Expand Down Expand Up @@ -388,6 +390,7 @@ resource "ibm_code_engine_job" "code_engine_job_instance" {
|------|-------------|
| build | Reference to a build that is associated with the job. |
| build_run | Reference to a build run that is associated with the job. |
| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run. |
| created_at | The timestamp when the resource was created. |
| entity_tag | The version of the job instance, which is used to achieve optimistic locking. |
| href | When you provision a new job, a URL is created identifying the location of the instance. |
Expand Down Expand Up @@ -504,6 +507,7 @@ data "ibm_code_engine_app" "code_engine_app_instance" {
|------|-------------|
| build | Reference to a build that is associated with the application. |
| build_run | Reference to a build run that is associated with the application. |
| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application. |
| created_at | The timestamp when the resource was created. |
| endpoint | Optional URL to invoke the app. Depending on visibility, this is accessible publicly or in the private network only. Empty in case 'managed_domain_mappings' is set to 'local'. |
| endpoint_internal | The URL to the app that is only visible within the project. |
Expand Down Expand Up @@ -686,6 +690,7 @@ data "ibm_code_engine_function" "code_engine_function_instance" {
| code_main | Specifies the name of the function that should be invoked. |
| code_reference | Specifies either a reference to a code bundle or the source code itself. To specify the source code, use the data URL scheme and include the source code as base64 encoded. The data URL scheme is defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). |
| code_secret | The name of the secret that is used to access the specified `code_reference`. The secret is used to authenticate with a non-public endpoint that is specified as`code_reference`. |
| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the function. |
| created_at | The timestamp when the resource was created. |
| endpoint | URL to invoke the function. |
| endpoint_internal | URL to function that is only visible within the project. |
Expand Down Expand Up @@ -726,6 +731,7 @@ data "ibm_code_engine_job" "code_engine_job_instance" {
|------|-------------|
| build | Reference to a build that is associated with the job. |
| build_run | Reference to a build run that is associated with the job. |
| computed_env_variables | References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the job run. |
| created_at | The timestamp when the resource was created. |
| entity_tag | The version of the job instance, which is used to achieve optimistic locking. |
| href | When you provision a new job, a URL is created identifying the location of the instance. |
Expand Down
1 change: 1 addition & 0 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3593,6 +3593,7 @@ func (c *Config) ClientSession() (interface{}, error) {
codeEngineClientOptions := &codeengine.CodeEngineV2Options{
Authenticator: authenticator,
URL: EnvFallBack([]string{"IBMCLOUD_CODE_ENGINE_API_ENDPOINT"}, codeEngineEndpoint),
Version: core.StringPtr("2025-01-10"),
}

// Construct the service client.
Expand Down
53 changes: 53 additions & 0 deletions ibm/service/codeengine/data_source_ibm_code_engine_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,45 @@ func DataSourceIbmCodeEngineApp() *schema.Resource {
Computed: true,
Description: "Reference to a build run that is associated with the application.",
},
"computed_env_variables": {
Type: schema.TypeList,
Computed: true,
Description: "References to config maps, secrets or literal values, which are defined and set by Code Engine and are exposed as environment variables in the application.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Type: schema.TypeString,
Computed: true,
Description: "The key to reference as environment variable.",
},
"name": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the environment variable.",
},
"prefix": {
Type: schema.TypeString,
Computed: true,
Description: "A prefix that can be added to all keys of a full secret or config map reference.",
},
"reference": {
Type: schema.TypeString,
Computed: true,
Description: "The name of the secret or config map.",
},
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Specify the type of the environment variable.",
},
"value": {
Type: schema.TypeString,
Computed: true,
Description: "The literal value of the environment variable.",
},
},
},
},
"created_at": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -404,6 +443,20 @@ func dataSourceIbmCodeEngineAppRead(context context.Context, d *schema.ResourceD
}
}

if !core.IsNil(app.ComputedEnvVariables) {
computedEnvVariables := []map[string]interface{}{}
for _, computedEnvVariablesItem := range app.ComputedEnvVariables {
computedEnvVariablesItemMap, err := DataSourceIbmCodeEngineAppEnvVarToMap(&computedEnvVariablesItem) // #nosec G601
if err != nil {
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_code_engine_app", "read", "computed_env_variables-to-map").GetDiag()
}
computedEnvVariables = append(computedEnvVariables, computedEnvVariablesItemMap)
}
if err = d.Set("computed_env_variables", computedEnvVariables); err != nil {
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting computed_env_variables: %s", err), "(Data) ibm_code_engine_app", "read", "set-computed_env_variables").GetDiag()
}
}

if !core.IsNil(app.CreatedAt) {
if err = d.Set("created_at", app.CreatedAt); err != nil {
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting created_at: %s", err), "(Data) ibm_code_engine_app", "read", "set-created_at").GetDiag()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestAccIbmCodeEngineAppDataSourceBasic(t *testing.T) {
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", "4G"),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", "0"),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", "300"),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"),
),
},
},
Expand All @@ -53,7 +54,7 @@ func TestAccIbmCodeEngineAppDataSourceExtended(t *testing.T) {
appName := fmt.Sprintf("tf-data-app-extended-%d", acctest.RandIntRange(10, 1000))
appImagePort := "8080"
appManagedDomainMappings := "local_public"
appRunAsUser := "0"
appRunAsUser := "10"
appRunServiceAccount := "default"
appScaleConcurrency := fmt.Sprintf("%d", acctest.RandIntRange(50, 100))
appScaleConcurrencyTarget := fmt.Sprintf("%d", acctest.RandIntRange(20, 50))
Expand Down Expand Up @@ -90,6 +91,8 @@ func TestAccIbmCodeEngineAppDataSourceExtended(t *testing.T) {
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_memory_limit", appScaleMemoryLimit),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_min_instances", appScaleMinInstances),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "scale_request_timeout", appScaleRequestTimeout),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "computed_env_variables.#", "6"),
resource.TestCheckResourceAttr("data.ibm_code_engine_app.code_engine_app_instance", "run_env_variables.#", "1"),
),
},
},
Expand All @@ -109,7 +112,6 @@ func testAccCheckIbmCodeEngineAppDataSourceConfigBasic(projectID string, appImag

lifecycle {
ignore_changes = [
run_env_variables,
probe_liveness,
probe_readiness
]
Expand Down Expand Up @@ -155,7 +157,6 @@ func testAccCheckIbmCodeEngineAppDataSourceConfig(projectID string, appImageRefe

lifecycle {
ignore_changes = [
run_env_variables,
probe_liveness,
probe_readiness
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func testAccCheckIbmCodeEngineBindingDataSourceConfigBasic(projectID string, app

lifecycle {
ignore_changes = [
run_env_variables,
probe_liveness,
probe_readiness
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func testAccCheckIbmCodeEngineDomainMappingDataSourceConfigBasic(projectID strin

lifecycle {
ignore_changes = [
run_env_variables,
probe_liveness,
probe_readiness
]
Expand Down
Loading
Loading