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

fix(autodetect): only use directories that contain var files when associating children #3000

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

hugorut
Copy link
Contributor

@hugorut hugorut commented Apr 4, 2024

Resolves issues with autodetect where we fail to properly associate child Terraform var files if the root directory also has children that contain root directories. Take the following example:

.
└── terraform
    ├── config
    │   ├── dev
    │   │   └── terraform.tfvars
    │   └── prod
    │       └── terraform.tfvars
    ├── main.tf
    └── foo
        ├── main.tf
        └── config
            ├── dev
            │   └── terraform.tfvars
            └── prod
                └── terraform.tfvars

In this case, prior to this change, when we called AssociateChildVarFiles on the terraform directory we stopped traversing at the depth of the foo directory. This meant that we were not able to associate config/dev/terraform.tfvars to the project.

I've now made a fix to add a method ChildTerraformVarFiles which traverses the tree only returning directories that contain only tfvar files. This is safe to use in the AssociateChildVarFiles context as this is only concerned with traversing to find child var files.

…ociating children

Resolves issues with autodetect where we fail to properly associate child Terraform
var files if the root directory also has children that contain root directories. Take
the following example:

```
.
└── terraform
    ├── config
    │   ├── dev
    │   │   └── terraform.tfvars
    │   └── prod
    │       └── terraform.tfvars
    ├── main.tf
    └── foo
        ├── main.tf
        └── config
            ├── dev
            │   └── terraform.tfvars
            └── prod
                └── terraform.tfvars
```

In this case, prior to this change, when we called `AssociateChildVarFiles` on the `terraform`
directory we stopped traversing at the depth of the `foo` directory. This meant that we were
not able to associate `config/dev/terraform.tfvars` to the project.

I've now made a fix to add a method `ChildTerraformVarFiles` which traverses the tree only returning
directories that contain only tfvar files. This is safe to use in the `AssociateChildVarFiles` context
as this is only concerned with traversing to find child var files.
@hugorut hugorut marked this pull request as ready for review April 4, 2024 09:55
@hugorut hugorut self-assigned this Apr 4, 2024
@hugorut hugorut changed the title fix(autodetect): only use directories that contain var files when ass… fix(autodetect): only use directories that contain var files when associating children Apr 4, 2024
@hugorut hugorut requested a review from aliscott April 4, 2024 09:56
@hugorut hugorut merged commit 8370af2 into master Apr 4, 2024
10 checks passed
@hugorut hugorut deleted the fix/terraform-var-files branch April 4, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants