-
Notifications
You must be signed in to change notification settings - Fork 152
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
Allow to override env vars for terraform operations in acc tests #153
Conversation
eliecharra
commented
Jan 25, 2021
Q | A |
---|---|
π Bug fix? | no |
π New feature? | no |
β Deprecations? | no |
β BC Break | no |
π Related issues | #83 |
β Documentation | yes |
Codecov Report
@@ Coverage Diff @@
## main #153 +/- ##
=======================================
Coverage 67.76% 67.76%
=======================================
Files 186 186
Lines 4197 4197
=======================================
Hits 2844 2844
Misses 1045 1045
Partials 308 308 |
aba366a
to
7461e5c
Compare
if environMap[envKeyValue[0]] == "" { | ||
environMap[envKeyValue[0]] = envKeyValue[1] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is one case that it will not be overridden but I don't know if it's possible to be in that special case. Imagine this one in that exact order:
os.Setenv("ACC_TEST_VAR_5", "")
os.Setenv("TEST_VAR_5", "test2")
The output would be that TEST_VAR_5
at the end will be test2
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, my test to check if key is present in map was weak, fixed using this form ππ»
if _, alreadyExist := environMap[envKeyValue[0]]; !alreadyExist {
environMap[envKeyValue[0]] = envKeyValue[1]
}
Test updated
doc/contributing/tests.md
Outdated
@@ -124,6 +124,34 @@ Each acceptance test should be prefixed by `TestAcc_` and should be run using en | |||
DRIFTCTL_ACC=true go test -run=TestAcc_ ./pkg/resource/aws/aws_instance_test.go | |||
``` | |||
|
|||
### Credentials | |||
|
|||
Acceptance test need credentials to perform real world action on cloud providers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acceptance tests
or Acceptance test needs
doc/contributing/tests.md
Outdated
### Credentials | ||
|
||
Acceptance test need credentials to perform real world action on cloud providers: | ||
- Read/write access are required to perform terraform action. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either we put point at the end of the sentence or not, your choice.
doc/contributing/tests.md
Outdated
- Read/write access are required to perform terraform action. | ||
- Read only access is required for driftctl execution | ||
|
||
Recommended way to run acc tests is to use two distinct credentials, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
credentials: one for terraform related actions, and one for driftctl scan.
doc/contributing/tests.md
Outdated
Recommended way to run acc tests is to use two distinct credentials, | ||
one for terraform related actions, and one for driftctl scan. | ||
|
||
You can override environment variables passed to terraform operations by using `ACC_` prefix on env variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by adding ...
doc/contributing/tests.md
Outdated
|
||
#### AWS | ||
|
||
You can use `ACC_AWS_PROFILE` to override profile used for terraform operations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to override AWS named profile used for terraform operations.
adb47eb
to
9fe8268
Compare
9fe8268
to
b2fc9dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go !