Skip to content

Commit

Permalink
feat: add a migrated_from label so we can know where resources were m…
Browse files Browse the repository at this point in the history
…igrated from
  • Loading branch information
Apollorion committed Oct 21, 2024
1 parent 666c250 commit d949bd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions spacemk/exporters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def export(self) -> None:
data = self._filter_data(data)
data = self._enrich_data(data)
data = self._map_data(data)
data["class"] = type(self).__name__
save_normalized_data(data)

logging.info("Stop exporting data")
7 changes: 5 additions & 2 deletions spacemk/templates/base.tf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ resource "spacelift_space" "{{ space._migration_id }}" {
{{ argument("inherit_entities", True, default=False) }}
{{ argument("name", space.name, required=True) }}
{{ argument("parent_space_id", "root", required=True) }}
{{ argument("labels", ["migration_class:" + class]) }}
{% block space_arguments_extra scoped %}{% endblock %}
}

{% if space.requires_terraform_workflow_tool %}
resource "spacelift_context" "{{ space._migration_id }}_terraform_workflow_tool" {
{{ argument("description", "Allows to use custom versions of Terraform. Make sure to provide the Terraform binary in the custom runner image for the stack.") }}
{{ argument("name", "Terraform Workflow Tool", required=True) }}
{{ argument("labels", ["migration_class:" + class]) }}
}

resource "spacelift_mounted_file" "workflow" {
Expand Down Expand Up @@ -83,7 +85,7 @@ resource "spacelift_stack" "{{ stack._relationships.space._migration_id }}_{{ st
{{ argument("branch", stack.vcs.branch, required=True) }}
{{ argument("description", stack.description) }}
{{ argument("local_preview", stack.local_preview) }}
{{ argument("labels", stack.labels) }}
{{ argument("labels", ["migration_class:" + class] + stack.labels|default([])) }}
{{ argument("manage_state", generation_config.spacelift.manage_state) }}
{{ argument("name", stack.name, required=True) }}
{{ argument("project_root", stack.vcs.project_root) }}
Expand Down Expand Up @@ -197,7 +199,7 @@ resource "spacelift_environment_variable" "{{ variable._relationships.space._mig
{% for context in contexts %}
resource "spacelift_context" "{{ context._relationships.space._migration_id }}_{{ context._migration_id }}" {
{{ argument("description", context.description) }}
{{ argument("labels", context.labels, default=[]) }}
{{ argument("labels", ["migration_class:" + class] + context.labels) }}
{{ argument("name", context.name, required=True) }}
{% block context_arguments_extra scoped %}{% endblock %}
}
Expand Down Expand Up @@ -268,6 +270,7 @@ resource "spacelift_module" "{{ module._relationships.space._migration_id }}_{{
{{ argument("repository", module.vcs.repository, required=True) }}
{{ argument("space_id", "spacelift_space." ~ module._relationships.space._migration_id ~ ".id", serialize=False) }}
{{ argument("terraform_provider", module.terraform_provider) }}
{{ argument("labels", ["migration_class:" + class]) }}
{% block module_arguments_extra scoped %}{% endblock %}

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

0 comments on commit d949bd2

Please sign in to comment.