Compare commits

...

10 Commits

Author SHA1 Message Date
63eacd7406 ci: render
Rendered by https://gitlab.com/developerdurp/yml/-/pipelines/1353690986
2024-06-29 14:01:30 +00:00
719018e0d6 update 2024-06-29 09:00:38 -05:00
bf5417aa4c update 2024-06-29 08:51:22 -05:00
5e6f5a1523 update 2024-06-29 08:17:28 -05:00
f729e23a9f ci: render
Rendered by https://gitlab.com/developerdurp/yml/-/pipelines/1353663774
2024-06-29 12:44:33 +00:00
cc54a82cee update 2024-06-29 07:43:46 -05:00
806bfe7ae5 update 2024-06-29 07:42:06 -05:00
7aa1367a46 update 2024-05-28 22:21:33 -05:00
362750ad08 ci: render
Rendered by https://gitlab.com/developerdurp/yml/-/pipelines/1309595514
2024-05-29 02:59:14 +00:00
0657acd0c8 update 2024-05-28 21:58:24 -05:00
11 changed files with 51 additions and 48 deletions

View File

@@ -57,14 +57,14 @@
echo '
- |
pwsh -c "Install-Module -Name powershell-yaml -Confirm:\$false -Force
\$template = (Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml/raw?ref=dev\") | ConvertFrom-Yaml
\$template = (Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH/raw?ref=\$ENV:ENVIRONMENT\") | ConvertFrom-Yaml
\$template.version = \$ENV:VERSION
\$body = @{
branch = \"dev\"
branch = \"\$ENV:ENVIRONMENT\"
commit_message = \"Update Chart\"
content = \"\$(\$template | convertto-yaml)\"
} | ConvertTo-Json
Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml\""
Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH\""
needs:
- pipeline: $PARENT_PIPELINE_ID
job: version

View File

@@ -9,7 +9,7 @@
# Begin of fmt.sh
- |
#Terraform fmt
terraform fmt -diff -check -write=false
tofu fmt -diff -check -write=false
# End of fmt.sh
.terraform_validate:
script:
@@ -20,11 +20,11 @@
# End of cd-workdir.sh
# Begin of init.sh
- "#Terraform init \nterraform init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
# End of init.sh
# Begin of validate.sh
- "#Terraform validate\nterraform validate \n"
- "#Terraform validate\ntofu validate \n"
# End of validate.sh
.terraform_plan:
variables:
@@ -38,11 +38,11 @@
# End of cd-workdir.sh
# Begin of init.sh
- "#Terraform init \nterraform init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
# End of init.sh
# Begin of plan.sh
- "#Terraform plan \napk add --update curl jq\nalias convert_report=\"jq -r '([.resource_changes[].change.actions?]|flatten)|{\\\"create\\\":(map(select(.==\\\"create\\\"))|length),\\\"update\\\":(map(select(.==\\\"update\\\"))|length),\\\"delete\\\":(map(select(.==\\\"delete\\\"))|length)}'\"\nterraform plan -out=$PLAN $ARGUMENTS\nterraform show --json $PLAN | convert_report > $JSON_PLAN_FILE\n"
- "#Terraform plan \napk add --update curl jq \nalias convert_report=\"jq -r '([.resource_changes[].change.actions?]|flatten)|{\\\"create\\\":(map(select(.==\\\"create\\\"))|length),\\\"update\\\":(map(select(.==\\\"update\\\"))|length),\\\"delete\\\":(map(select(.==\\\"delete\\\"))|length)}'\"\ntofu plan -out=$PLAN $ARGUMENTS\ntofu show --json $PLAN | jq -r '([.resource_changes[].change.actions?]|flatten)|{\"create\":(map(select(.==\"create\"))|length),\"update\":(map(select(.==\"update\"))|length),\"delete\":(map(select(.==\"delete\"))|length)}' > $JSON_PLAN_FILE\n"
# End of plan.sh
artifacts:
reports:
@@ -56,13 +56,13 @@
# End of cd-workdir.sh
# Begin of init.sh
- "#Terraform init \nterraform init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
# End of init.sh
# Begin of apply.sh
- |
#Terraform validate
terraform apply -auto-approve $ARGUMENTS
tofu apply -auto-approve $ARGUMENTS
# End of apply.sh
.terraform_destroy:
script:
@@ -73,11 +73,11 @@
# End of cd-workdir.sh
# Begin of init.sh
- "#Terraform init \nterraform init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
- "#Terraform init \ntofu init -reconfigure -backend-config=\"address=${GITLAB_TF_ADDRESS}\" -backend-config=\"lock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"unlock_address=${GITLAB_TF_ADDRESS}/lock\" -backend-config=\"username=gitlab-ci-token\" -backend-config=\"password=${CI_JOB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\" \n"
# End of init.sh
# Begin of destroy.sh
- |
#Terraform validate
terraform destroy -auto-approve $ARGUMENTS
tofu destroy -auto-approve $ARGUMENTS
# End of destroy.sh

View File

@@ -21,7 +21,7 @@ golang-lint:
- !reference [.mr_only_rules, rules]
docker-build:
extends: .docker_build
extends: .docker-build-container
stage: build
needs:
- job: gobuild
@@ -39,13 +39,23 @@ gobuild:
rules:
- !reference [.default_mr_rules, rules]
docker-push:
extends: .docker_push_gitlab
stage: publish
needs:
- job: docker-build
artifacts: true
- pipeline: $PARENT_PIPELINE_ID
job: version
rules:
- !reference [.docker_publish_rules, rules]
#docker-build:
# extends: .docker_build
# stage: build
# needs:
# - job: gobuild
# artifacts: true
# - pipeline: $PARENT_PIPELINE_ID
# job: version
# rules:
# - !reference [.docker_rules, rules]
#docker-push:
# extends: .docker_push_gitlab
# stage: publish
# needs:
# - job: docker-build
# artifacts: true
# - pipeline: $PARENT_PIPELINE_ID
# job: version
# rules:
# - !reference [.docker_publish_rules, rules]

View File

@@ -8,8 +8,7 @@ variables:
GITLAB_TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${ENVIRONMENT_NAME}
image:
name: registry.internal.durp.info/hashicorp/terraform:light
#name: hashicorp/terraform:light
name: registry.internal.durp.info/opentofu/opentofu:latest
entrypoint: [""]
include:
@@ -33,8 +32,7 @@ plan-development:
environment:
name: development
variables:
ARGUMENTS: -var-file=terraform.tfvars
ENVIRONMENT_NAME: development
ENVIRONMENT_NAME: dev
allow_failure: false
extends: .terraform_plan
needs: ["validate","format"]
@@ -44,8 +42,7 @@ plan-production:
environment:
name: production
variables:
ARGUMENTS: -var-file=terraform.tfvars
ENVIRONMENT_NAME: production
ENVIRONMENT_NAME: prd
allow_failure: false
extends: .terraform_plan
needs: ["validate","format"]
@@ -55,8 +52,7 @@ apply-development:
environment:
name: development
variables:
ARGUMENTS: -var-file=terraform.tfvars
ENVIRONMENT_NAME: development
ENVIRONMENT_NAME: dev
allow_failure: false
extends: .terraform_apply
rules:
@@ -67,8 +63,7 @@ apply-production:
environment:
name: production
variables:
ARGUMENTS: -var-file=terraform.tfvars
ENVIRONMENT_NAME: production
ENVIRONMENT_NAME: prd
allow_failure: false
extends: .terraform_apply
rules:
@@ -79,8 +74,7 @@ destroy-development:
environment:
name: development
variables:
ARGUMENTS: -var-file=terraform.tfvars
ENVIRONMENT_NAME: development
ENVIRONMENT_NAME: dev
allow_failure: false
extends: .terraform_destroy
needs: ["apply-development"]
@@ -92,8 +86,7 @@ destroy-production:
environment:
name: production
variables:
ARGUMENTS: -var-file=terraform.tfvars
ENVIRONMENT_NAME: production
ENVIRONMENT_NAME: prd
allow_failure: false
extends: .terraform_destroy
needs: ["apply-production"]

View File

@@ -12,14 +12,14 @@ $VERSION:
echo '
- |
pwsh -c "Install-Module -Name powershell-yaml -Confirm:\$false -Force
\$template = (Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml/raw?ref=dev\") | ConvertFrom-Yaml
\$template = (Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH/raw?ref=\$ENV:ENVIRONMENT\") | ConvertFrom-Yaml
\$template.version = \$ENV:VERSION
\$body = @{
branch = \"dev\"
branch = \"\$ENV:ENVIRONMENT\"
commit_message = \"Update Chart\"
content = \"\$(\$template | convertto-yaml)\"
} | ConvertTo-Json
Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"https://gitlab.com/api/v4/projects/45028985/repository/files/durpapi%2FChart.yaml\""
Invoke-RestMethod -Headers @{ \"PRIVATE-TOKEN\"= \$ENV:GITLAB_TOKEN } -ContentType \"application/json\" -Method Put -body \$body -Uri \"\$ENV:CI_API_V4_URL/projects/\$ENV:GITLAB_PROJECT_ID/repository/files/\$ENV:GITLAB_CHART_PATH\""
needs:
- pipeline: $PARENT_PIPELINE_ID
job: version

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Terraform validate
terraform apply -auto-approve $ARGUMENTS
tofu apply -auto-approve $ARGUMENTS

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Terraform validate
terraform destroy -auto-approve $ARGUMENTS
tofu destroy -auto-approve $ARGUMENTS

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Terraform fmt
terraform fmt -diff -check -write=false
tofu fmt -diff -check -write=false

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Terraform init
terraform init -reconfigure -backend-config="address=${GITLAB_TF_ADDRESS}" -backend-config="lock_address=${GITLAB_TF_ADDRESS}/lock" -backend-config="unlock_address=${GITLAB_TF_ADDRESS}/lock" -backend-config="username=gitlab-ci-token" -backend-config="password=${CI_JOB_TOKEN}" -backend-config="lock_method=POST" -backend-config="unlock_method=DELETE" -backend-config="retry_wait_min=5"
tofu init -reconfigure -backend-config="address=${GITLAB_TF_ADDRESS}" -backend-config="lock_address=${GITLAB_TF_ADDRESS}/lock" -backend-config="unlock_address=${GITLAB_TF_ADDRESS}/lock" -backend-config="username=gitlab-ci-token" -backend-config="password=${CI_JOB_TOKEN}" -backend-config="lock_method=POST" -backend-config="unlock_method=DELETE" -backend-config="retry_wait_min=5"

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Terraform plan
apk add --update curl jq
apk add --update curl jq
alias convert_report="jq -r '([.resource_changes[].change.actions?]|flatten)|{\"create\":(map(select(.==\"create\"))|length),\"update\":(map(select(.==\"update\"))|length),\"delete\":(map(select(.==\"delete\"))|length)}'"
terraform plan -out=$PLAN $ARGUMENTS
terraform show --json $PLAN | convert_report > $JSON_PLAN_FILE
tofu plan -out=$PLAN $ARGUMENTS
tofu show --json $PLAN | jq -r '([.resource_changes[].change.actions?]|flatten)|{"create":(map(select(.=="create"))|length),"update":(map(select(.=="update"))|length),"delete":(map(select(.=="delete"))|length)}' > $JSON_PLAN_FILE

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#%%MULTILINE_YAML_START
#Terraform validate
terraform validate
tofu validate