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 144b219
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ 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"

github:
api_token:
endpoint: https://api.github.com

gitlab:
modules: true

spacelift:
api:
api_key_endpoint: https://<ACCOUNT NAME>>.app.spacelift.io/graphql
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 "generation_config.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 144b219

Please sign in to comment.