generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add a new feature to run builds #201
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
Open
akocbek
wants to merge
7
commits into
main
Choose a base branch
from
run_build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+352
−89
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,9 @@ | |
{ | ||
"key": "builds" | ||
}, | ||
{ | ||
"key": "container_registry_namespace" | ||
}, | ||
{ | ||
"key": "domain_mappings" | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [[ -z "${IBMCLOUD_API_KEY}" ]]; then | ||
echo "IBMCLOUD_API_KEY is required" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${RESOURCE_GROUP_ID}" ]]; then | ||
echo "RESOURCE_GROUP_ID is required" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${CE_PROJECT_NAME}" ]]; then | ||
echo "CE_PROJECT_NAME is required" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${REGION}" ]]; then | ||
echo "REGION is required" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${BUILDS}" ]]; then | ||
echo "BUILDS is required" >&2 | ||
exit 1 | ||
fi | ||
|
||
ibmcloud login -r "${REGION}" -g "${RESOURCE_GROUP_ID}" --quiet | ||
|
||
# selecet the right code engine project | ||
ibmcloud ce project select -n "${CE_PROJECT_NAME}" | ||
|
||
# run a build for all builds | ||
for build in $BUILDS; do | ||
echo "$build" | ||
ibmcloud ce buildrun submit --build "$build" | ||
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
INPUT=$(cat) | ||
REGION=$(echo "$INPUT" | jq -r '.REGION') | ||
RESOURCE_GROUP_ID=$(echo "$INPUT" | jq -r '.RESOURCE_GROUP_ID') | ||
IBMCLOUD_API_KEY=$(echo "$INPUT" | jq -r '.IBMCLOUD_API_KEY') | ||
export IBMCLOUD_API_KEY | ||
|
||
if [[ -z "${IBMCLOUD_API_KEY}" || "${IBMCLOUD_API_KEY}" == "null" ]]; then | ||
echo '{"error": "IBMCLOUD_API_KEY is required"}' | ||
exit 0 | ||
fi | ||
|
||
if [[ -z "${RESOURCE_GROUP_ID}" || "${RESOURCE_GROUP_ID}" == "null" ]]; then | ||
echo '{"error": "RESOURCE_GROUP_ID is required"}' | ||
exit 0 | ||
fi | ||
|
||
if [[ -z "${REGION}" || "${REGION}" == "null" ]]; then | ||
echo '{"error": "REGION is required"}' | ||
exit 0 | ||
fi | ||
|
||
if ! ibmcloud login -r "${REGION}" -g "${RESOURCE_GROUP_ID}" --quiet > /dev/null 2>&1; then | ||
printf '{"error": "Failed to login using: ibmcloud login -r %s -g %s"}' "$REGION" "$RESOURCE_GROUP_ID" | ||
exit 0 | ||
fi | ||
|
||
# extract registry value from text "You are targeting region 'us-south', the registry is 'us.icr.io'." | ||
registry=$(ibmcloud cr region 2>/dev/null | grep registry | sed -E "s/.*registry is '([^']+)'.*/\1/") | ||
|
||
# Validate registry value | ||
if [[ -z "$registry" ]]; then | ||
echo '{"error": "Failed to parse registry region from ibmcloud cr region"}' | ||
exit 0 | ||
fi | ||
|
||
echo "{\"registry\": \"${registry}\"}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ variable "project_name" { | |
variable "builds" { | ||
description = "A map of code engine builds to be created.[Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-code-engine/blob/main/solutions/project/DA-inputs.md#builds)" | ||
type = map(object({ | ||
output_image = string | ||
output_image = optional(string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should imply a change to the documentation in the link in the description. The DA now has a more complex interaction between this input and container_resgistry_namespace. |
||
output_secret = string # pragma: allowlist secret | ||
source_url = string | ||
strategy_type = string | ||
|
@@ -61,6 +61,20 @@ variable "builds" { | |
default = {} | ||
} | ||
|
||
variable "container_registry_namespace" { | ||
description = "The name of the namespace to create in IBM Cloud Container Registry for organizing container images. Used only for builds that do not have output_image set." | ||
type = string | ||
default = null | ||
|
||
validation { | ||
condition = alltrue([ | ||
for build in values(var.builds) : | ||
contains(keys(build), "output_image") && build.output_image != null | ||
]) || var.container_registry_namespace != null | ||
error_message = "container_registry_namespace is required because at least one build is missing an output_image" | ||
} | ||
} | ||
|
||
############################################################################## | ||
# Code Engine Domain Mapping | ||
############################################################################## | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not have caught this last time. Is this an actual secret or is it the ID of a secret? Should it be marked
sensitive
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is just a name of a secret, so we are good here