Skip to content

Commit

Permalink
feat: add default for stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollorion committed Oct 25, 2024
1 parent 062ac8d commit 6d00226
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ generator:
# # The default branch for all modules. Only used if the module does not have a branch specified.
# # Default: empty string
# modules:
# default_branch: main

# # The default branch for all stacks. Only used if the stack does not have a branch specified.
# # Default: empty string
# stacks:
# default_branch: main

extra_vars:
Expand Down
3 changes: 3 additions & 0 deletions spacemk/commands/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def set_default(value, _default):
"SPACELIFT_DEFAULT_INVALID"),
"modules": {
"default_branch": set_default(config.get("generator.modules.default_branch"), ""),
},
"stacks": {
"default_branch": set_default(config.get("generator.stacks.default_branch"), ""),
}
}

Expand Down
4 changes: 4 additions & 0 deletions spacemk/templates/base.tf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ EOT
{% if stack.vcs.repository %}
resource "spacelift_stack" "{{ stack._relationships.space._migration_id }}_{{ stack._migration_id }}" {
{{ argument("auto_deploy", stack.auto_deploy, default=False) }}
{% if stack.vcs.branch == ""%}
{{ argument("branch", generation_config.stacks.default_branch, required=True) }}
{% else %}
{{ argument("branch", stack.vcs.branch, required=True) }}
{% endif %}
{{ argument("description", stack.description) }}
{{ argument("local_preview", stack.local_preview) }}
{{ argument("labels", ["migration_class:" + class] + stack.labels|default([])) }}
Expand Down

0 comments on commit 6d00226

Please sign in to comment.