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

Atmos vendor pull leave files removed in new version #821

Open
goruha opened this issue Dec 5, 2024 · 1 comment
Open

Atmos vendor pull leave files removed in new version #821

goruha opened this issue Dec 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@goruha
Copy link
Member

goruha commented Dec 5, 2024

Describe the Bug

Let's assume there are two versions of the component containing the following files.

Version 1

  • main.tf
  • locals.tf

Version 2

  • main.tf

If you have pulled version 2 into a component that had already pulled version 1 the locals.tf would not be removed

Expected Behavior

atmos vendor pull --component {name} before pull should remove all files from component directory except component.yaml or vendor.yaml.

Steps to Reproduce

Let's assume there are two versions of the component containing the following files.

  1. Create component aws-team-roles in components/terraform/aws-team-roles
  2. Create components/terraform/aws-team-roles/component.yaml file with the following content point to https://github.com/cloudposse/terraform-aws-components/tree/1.470.0/modules/aws-team-roles
# 'aws-team-roles' component vendoring config

# 'component.yaml' in the component folder is processed by the 'atmos' commands
# 'atmos vendor pull -c aws-team-roles' or 'atmos vendor pull --component aws-team-roles'

apiVersion: atmos/v1
kind: ComponentVendorConfig
spec:
  source:
    uri: github.com/cloudposse/terraform-aws-components.git//modules/aws-team-roles?ref={{ .Version }}
    version: 1.470.0
    included_paths:
      - "**/**"
    excluded_paths: [ ]
  1. Run atmos vendor pull --component aws-team-roles
  2. Run ls -l components/terraform/aws-team-rolesand check that filespolicy-billing.tfandpolicy-support.tf` is there
  3. Update components/terraform/aws-team-roles/component.yaml replace version: 1.470.0 with version: 1.471.0
    point to https://github.com/cloudposse/terraform-aws-components/tree/1.471.0/modules/aws-team-roles
  4. Run atmos vendor pull --component aws-team-roles

Expected

  1. Run ls -l components/terraform/aws-team-roles`
  2. Ensure that files policy-billing.tf and policy-support.tf disappeared because they we removed in https://github.com/cloudposse/terraform-aws-components/tree/1.471.0/modules/aws-team-roles

Exists

  1. Run ls -l components/terraform/aws-team-roles`
  2. The files policy-billing.tf and policy-support.tf still there

Screenshots

No response

Environment

No response

Additional Context

No response

@goruha goruha added the bug 🐛 An issue with the system label Dec 5, 2024
@osterman
Copy link
Member

osterman commented Dec 5, 2024

We need to approach this in a more nuanced way. We cannot blindly delete "vendored" files, because we don't have a record of the files that were vendored. Or if we did blindly delete files in the target path, that would need to be an opt-in feature.

At a minimum, we should only delete files that were originally vendored. This can be accomplished with a vendor.yaml.lock file. Or we can make a design choice that we delete files in the target path which are not in git. This would be the easiest implementation:

git clean -fd TARGET_PATH

There's a related issue, that highlights some of the challenges:

@osterman osterman added enhancement New feature or request and removed bug 🐛 An issue with the system labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants