Skip to content

Commit

Permalink
feat: make it easier to understand when/how to configure custom runne…
Browse files Browse the repository at this point in the history
…r images
  • Loading branch information
Apollorion committed Aug 5, 2024
1 parent 3a42508 commit b774880
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit b774880

Please sign in to comment.