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

feat: make it easier to understand when/how to configure custom runner images #73

Merged
merged 1 commit into from
Aug 5, 2024
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
5 changes: 5 additions & 0 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ generator:
# spacelift:
# manage_state: true

# # Custom runner to use for stacks with custom runner images configured
# # See customizing the runner image: https://docs.spacelift.io/integrations/docker#customizing-the-runner-image
# # Default: N/A, must be provided (however, not always used. If it is used and not provided an exception will be raised during code generation)
# custom_runner_image: public.ecr.aws/spacelift/runner-terraform

extra_vars:
foo: bar # "{{ extra_vars.foo }}" in a template will be replaced by "bar"

Expand Down
4 changes: 3 additions & 1 deletion spacemk/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def default(value, _default):
"manage_state": default(config.get("generator.spacelift.manage_state"), True)
}, "github": {
"custom_app": default(config.get("generator.github.custom_app"), False)
}
},
"custom_runner_image": default(config.get("generator.custom_runner_image"),
"SPACELIFT_DEFAULT_INVALID"),
}

generator = Generator()
Expand Down
5 changes: 4 additions & 1 deletion spacemk/templates/base.tf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ resource "spacelift_stack" "{{ stack._relationships.space._migration_id }}_{{ st
{% block stack_arguments_extra scoped %}{% endblock %}

{% if stack.terraform.workflow_tool == "CUSTOM" %}
{{ argument("runner_image ", extra_vars.custom_terraform_runner_image ~ ":" ~ stack.terraform.version, required=True) }}
{% if generation_config.custom_runner_image == "SPACELIFT_DEFAULT_INVALID" %}
{% raise "generator.custom_runner_image is required for stacks with custom Terraform workflow tool." %}
{% endif %}
{{ argument("runner_image ", generation_config.custom_runner_image ~ ":" ~ stack.terraform.version, required=True) }}
{% endif %}

{% if stack.vcs.provider == "github_custom" %}
Expand Down