Closed fernando-villalba closed 1 month ago
Proposed Approach for #246:
Hi Team,
I have been working on the feature request outlined in issue #246. I kindly request your review and feedback.
Here is what I have done:
Removed the civo_token
field from the provider schema and replaced it with a credential_file
option.
Implemented a priority-based token retrieval:
CIVO_TOKEN
).Added a getToken
function to handle the token retrieval logic.
Implemented readTokenFromFile
to securely read tokens from JSON files.
One additional thing that I have added is, the user can set the Credential file path in CIVO_CREDENTIAL_FILE
environment variable as well. For this I took inspiration from here
Updated and expanded test cases to cover:
Updated the example in provider.tf
to use the new credential_file
option instead of civo_token
.
The concerned code can be found in the gist here.
Screenshots:
It passes all the tests:
Test Coverage:
Thank you for your time and feedback.
Best regards,
Praveen
Hey @Praveen005 Thank you for your amazing diagnosis, this approach looks fine to me can you go ahead and raise a PR. Please do test it locally and attach Screenshots in the PR
Description
Issue
When the CLI is configured with a token, terraform should automatically take the token config from the cli config file at from
~/.civo.json
Alternatively (or preferentially) it can be taken from the environment variable as it is possible to do now.
We should dissuade users from providing credentials via an input variable. These should be strictly reserved for short lived tokens which we don’t have now.
Acceptance Criteria
~/.civo.json
token
input, the token should never be entered as variable or input that gets saved on state. Instead change this tocredentials_file
or something like that where the user can specify the location of a file with the token.Screenshots
No response
Additional information
No response