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: add a migrated_from label so we can know where resources were migrated from #79

Merged
merged 1 commit into from
Oct 21, 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
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