Newer
Older
docs:
csplit -sf readme -n 1 .gitlab/README.md '/<INPUTS>/'
echo '<!-- This document is generated by `make docs` from `.gitlab/README.md` -->' > README.md
echo >> README.md
yq '.spec.inputs | .[] | "| `" + key + "` | `" + .default + "` | " + .description + (.options | (" Must be one of " + (. | filter((. | test("\$$.*")) == false) | map("`" + . + "`") | join(", ") + "." )) // "") + " |"' templates/full-pipeline.yml >> README.md
echo >> README.md
echo '### Available OpenTofu Versions' >> README.md
echo >> README.md
echo 'The following OpenTofu versions are available with this component via the `opentofu_version` input:' >> README.md
echo >> README.md
yq -r '.spec.inputs.opentofu_version.options | filter((. | test("\$$.*")) == false) | .[] | "- [`" + . + "`](https://github.com/opentofu/opentofu/releases/tag/v" + . + ")"' templates/full-pipeline.yml >> README.md
tail -n+2 readme1 >> README.md
rm -f readme0 readme1 readme_inputs.md
BACKPORTS_DIR := backports
BACKPORTS_BASE_DIR := $(BACKPORTS_DIR)/OpenTofu
BACKPORTS_BASE_FILE := $(BACKPORTS_BASE_DIR)/Base.gitlab-ci.yml
# NOTE: this make target requires GNU sed and not the mac OS sed.
# Install it with `brew install gnu-sed` and follow the instructions in `brew info gnu-sed` to
# make it the standard `sed` binary (if you wish) or temporarily alias sed=gsed
@echo "Generating $(BACKPORTS_BASE_FILE) ..."
@cp $(BACKPORTS_DIR)/.Base.gitlab-ci.yml $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/fmt.yml | sed -e 's/$$\[\[ inputs.as \]\]/.opentofu:fmt/' | sed -e 's/$$\[\[ inputs.stage \]\]/validate/' | sed -e 's/$$\[\[ inputs.allow_failure \]\]/true/' >> $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/validate.yml | sed -e 's/$$\[\[ inputs.as \]\]/.opentofu:validate/' | sed -e 's/$$\[\[ inputs.stage \]\]/validate/' >> $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/plan.yml | sed -e 's/$$\[\[ inputs.as \]\]/.opentofu:plan/' | sed -e 's/$$\[\[ inputs.stage \]\]/build/' >> $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/apply.yml | sed -e 's/$$\[\[ inputs.as \]\]/.opentofu:apply/' | sed -e 's/$$\[\[ inputs.stage \]\]/deploy/' | sed -e 's/$$\[\[ inputs.auto_apply \]\]/$$_TF_AUTO_APPLY/' >> $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/destroy.yml | sed -e 's/$$\[\[ inputs.as \]\]/.opentofu:destroy/' | sed -e 's/$$\[\[ inputs.stage \]\]/cleanup/' | sed -e 's/$$\[\[ inputs.auto_destroy \]\]/$$_TF_AUTO_DESTROY/' | sed -e 's/$$\[\[ inputs.create_destroy_job \]\]/$$TF_CREATE_DESTROY_JOB/' >> $(BACKPORTS_BASE_FILE)
@sed '1,/^---$$/d' templates/delete-state.yml | sed -e 's/$$\[\[ inputs.as \]\]/.opentofu:delete-state/' | sed -e 's/$$\[\[ inputs.stage \]\]/cleanup/' | sed -e 's/$$\[\[ inputs.create_delete_state_job \]\]/$$TF_CREATE_DELETE_STATE_JOB/' | sed -e "/stage: cleanup/a \ \ needs: ['.opentofu:destroy']" >> $(BACKPORTS_BASE_FILE)
@# Common inputs
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.image_registry_base \]\]/$$GITLAB_OPENTOFU_IMAGE_REGISTRY_BASE/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.version \]\]/$$GITLAB_OPENTOFU_VERSION/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.opentofu_version \]\]/$$OPENTOFU_VERSION/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.root_dir \]\]/$$TF_ROOT/'
@sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.state_name \]\]/$$TF_STATE_NAME/'
@sed -i $(BACKPORTS_BASE_FILE) -e '/TF_STATE_NAME: $$TF_STATE_NAME/d'
@sed -i $(BACKPORTS_BASE_FILE) -e '/TF_ROOT: $$TF_ROOT/d'
@# Remove empty variable blocks - yq doesn't preserve white spaces, thus the patching ...
@yq e 'del(.*.variables | select(length==0))' backports/OpenTofu/Base.gitlab-ci.yml | diff -Bw backports/OpenTofu/Base.gitlab-ci.yml - | patch backports/OpenTofu/Base.gitlab-ci.yml -
@echo "Generated $(BACKPORTS_BASE_FILE)"