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

Support tfstate discovery within workspaces #1562

Merged
merged 5 commits into from
Jul 12, 2022
Merged

Conversation

sundowndev-snyk
Copy link
Contributor

@sundowndev-snyk sundowndev-snyk commented Jul 11, 2022

Q A
πŸ› Bug fix? yes
πŸš€ New feature? no
⚠ Deprecations? no
❌ BC Break no
πŸ”— Related issues CTX-336
❓ Documentation no

Description

The current feature that discovers state from HCL files does not support non-default workspaces. This PR intend to fix that.

fix: tfstate discovering

  • Added remain HCL fields to schemas in order to allow other fields
  • Fixed discovering for s3 and gcs backends according to the current workspace

refactor: backend to supplier config

  • Parse workspace name first then pass it to the backend to generate the supplier config

@sundowndev-snyk sundowndev-snyk added the kind/bug Something isn't working label Jul 11, 2022
@sundowndev-snyk sundowndev-snyk requested a review from moadibfr July 11, 2022 12:58
@sundowndev-snyk sundowndev-snyk force-pushed the fix/tf-hcl-schema branch 2 times, most recently from bb48e76 to 316de88 Compare July 11, 2022 13:40
@codecov-commenter
Copy link

Codecov Report

Merging #1562 (ec5190f) into main (516609f) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1562      +/-   ##
==========================================
+ Coverage   81.41%   81.43%   +0.01%     
==========================================
  Files         442      442              
  Lines       16215    16229      +14     
==========================================
+ Hits        13202    13216      +14     
  Misses       2687     2687              
  Partials      326      326              
Impacted Files Coverage Ξ”
pkg/terraform/hcl/backend.go 74.50% <100.00%> (+2.16%) ⬆️
pkg/terraform/hcl/hcl.go 86.95% <100.00%> (+10.03%) ⬆️

Parse workspace name first then pass it to the SupplierConfig function, so we don't it once and do not have to store it anywhere. Also add a test case for unknown backend.
Copy link
Contributor

@eliecharra eliecharra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss some context so I asked a few questions.

And a testcase seems useless to me

pkg/terraform/hcl/backend_test.go Outdated Show resolved Hide resolved
pkg/terraform/hcl/backend.go Show resolved Hide resolved
pkg/terraform/hcl/backend.go Outdated Show resolved Hide resolved
@eliecharra eliecharra requested review from eliecharra and removed request for moadibfr July 12, 2022 08:40
@eliecharra eliecharra self-assigned this Jul 12, 2022
@sundowndev-snyk sundowndev-snyk merged commit 7e5c31f into main Jul 12, 2022
@sundowndev-snyk sundowndev-snyk deleted the fix/tf-hcl-schema branch July 12, 2022 12:36
@sundowndev-snyk sundowndev-snyk changed the title Support tfstate discovering within workspaces Support tfstate discovery within workspaces Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants