Skip to content

Commit

Permalink
Add date-based versioning support for Code Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpet committed Jan 29, 2025
1 parent d6375c4 commit 979857d
Show file tree
Hide file tree
Showing 29 changed files with 527 additions and 89 deletions.
44 changes: 22 additions & 22 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-01-29T01:12:34Z",
"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": 220,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "470851178a9e3a16c35bc88232c21d04c555e5ca",
"is_secret": false,
"is_verified": false,
"line_number": 270,
"line_number": 292,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -872,39 +872,39 @@
"hashed_secret": "c427f185ddcb2440be9b77c8e45f1cd487a2e790",
"is_secret": false,
"is_verified": false,
"line_number": 1548,
"line_number": 1551,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "1f7e33de15e22de9d2eaf502df284ed25ca40018",
"is_secret": false,
"is_verified": false,
"line_number": 1615,
"line_number": 1618,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670",
"is_secret": false,
"is_verified": false,
"line_number": 3658,
"line_number": 3666,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6",
"is_secret": false,
"is_verified": false,
"line_number": 3671,
"line_number": 3679,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1",
"is_secret": false,
"is_verified": false,
"line_number": 3712,
"line_number": 3720,
"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": 2377,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437",
"is_secret": false,
"is_verified": false,
"line_number": 2375,
"line_number": 2383,
"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
27 changes: 27 additions & 0 deletions examples/ibm-code-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ $ terraform apply

Run `terraform destroy` when you don't need these resources.

## Versioning

If you want to use a specific version of Code Engine, you can do so using the `code_engine_version` argument in the IBM Cloud provider block. For example:

```hcl
provider "ibm" {
code_engine_version = var.code_engine_version
}
variable "code_engine_version" {
description = "The Code Engine date-based version string in the format 'YYYY-MM-DD'."
type = string
}
```
Create a terraform.tfvars file and specify the date-based version string in that file:

```hcl
code_engine_version = "2022-12-09"
```
When the API is updated with any breaking changes, the service introduces a new version date for the API. The API uses the most recent version on or before the date you specify. By default, if you do not specify a version, the latest version is used by the provider. You can find the available versions in the [API changelog](https://cloud.ibm.com/docs/codeengine?topic=codeengine-api-changelog#api-versioning).

## Code Engine resources

### Resource: ibm_code_engine_project
Expand Down Expand Up @@ -144,6 +165,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 +356,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 +411,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 +528,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 +711,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 +752,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
5 changes: 3 additions & 2 deletions examples/ibm-code-engine/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.ibmcloud_region
ibmcloud_api_key = var.ibmcloud_api_key
region = var.ibmcloud_region
code_engine_version = var.code_engine_version
}

terraform {
Expand Down
6 changes: 6 additions & 0 deletions examples/ibm-code-engine/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ variable "ibmcloud_region" {
type = string
}

variable "code_engine_version" {
description = "The Code Engine date-based version string in the format 'YYYY-MM-DD'."
type = string
default = "2025-01-10"
}

// Resource arguments for code_engine_project
variable "code_engine_project_name" {
description = "The name of the project."
Expand Down
8 changes: 8 additions & 0 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ type Config struct {
// Constant Retry Delay for API calls
RetryDelay time.Duration

// Code Engine date-based version
CodeEngineVersion string

// FunctionNameSpace ...
FunctionNameSpace string

Expand Down Expand Up @@ -3592,9 +3595,14 @@ func (c *Config) ClientSession() (interface{}, error) {
if fileMap != nil && c.Visibility != "public-and-private" {
codeEngineEndpoint = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_CODE_ENGINE_API_ENDPOINT", c.Region, codeEngineEndpoint)
}
ceVersion := "2025-01-10"
if c.CodeEngineVersion != "" {
ceVersion = c.CodeEngineVersion
}
codeEngineClientOptions := &codeengine.CodeEngineV2Options{
Authenticator: authenticator,
URL: EnvFallBack([]string{"IBMCLOUD_CODE_ENGINE_API_ENDPOINT"}, codeEngineEndpoint),
Version: &ceVersion,
}

// Construct the service client.
Expand Down
8 changes: 8 additions & 0 deletions ibm/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ func Provider() *schema.Provider {
Description: "The retry count to set for API calls.",
DefaultFunc: schema.EnvDefaultFunc("MAX_RETRIES", 10),
},
"code_engine_version": {
Type: schema.TypeString,
Optional: true,
Description: "The Code Engine date-based version string in the format 'YYYY-MM-DD'.",
DefaultFunc: schema.EnvDefaultFunc("CODE_ENGINE_VERSION", nil),
},
"function_namespace": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -2354,6 +2360,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
region := d.Get("region").(string)
zone := d.Get("zone").(string)
retryCount := d.Get("max_retries").(int)
ceVersion := d.Get("code_engine_version").(string)
wskNameSpace := d.Get("function_namespace").(string)
riaasEndPoint := d.Get("riaas_endpoint").(string)

Expand All @@ -2377,6 +2384,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
RetryCount: retryCount,
SoftLayerEndpointURL: softlayerEndpointUrl,
RetryDelay: conns.RetryAPIDelay,
CodeEngineVersion: ceVersion,
FunctionNameSpace: wskNameSpace,
RiaasEndPoint: riaasEndPoint,
IAMToken: iamToken,
Expand Down
Loading

0 comments on commit 979857d

Please sign in to comment.