what
- Fix remote state for Terraform
utils
provider - Remove all global vars from Go code
- Implement
Logs.Verbose
- Update
terraform
commands - Refactor
why
-
Remove all global vars from Go code - this fixes remote state for Terraform
utils
provider- Terraform executes a provider data source in a separate process and calls it using RPC
- But this separate process is only one per provider, so if we call the code the get the remote state of two different components, the same process will be called
- In the previous implementation, we used the global Go variable
Config
which was used by all functions to get the CLI configuration to use it in calculations of component and stack paths - When we tried to get the remote state of two different components from two diff repos with two diff
atmos.yaml
CLI config files, Terraform executed the two calls concurrently. The first call processedatmos.yaml
and updated theConfig
global var with the component and stack paths. Then the second call also processed a differentatmos.yaml
(from another repo) and overrode the globalConfig
var with values related to the second repo - One of the calls randomly failed with the error "Searched all paths, but could not find the component
xxx
in the stackyyy
" - Removing all globals from the Go code (including the
Config
var) allows executing any part of the code concurrently without storing any state in global vars. The CLI config is now processed on all calls to theatmos
code and is used as parameter to all Go functions that require it
- Yes globals are bad (it was working before in almost all cases since we used only one
atmos.yaml
, or, if we used more than one from diff repos, the twoatmos.yaml
files were identically configured (base path, components path, stacks paths, included/excluded paths, etc.)
-
Implement
Logs.Verbose
- allow settingLogs.Verbose
inatmos.yaml
to enable/disable verbose logging (before, it was controlled only by theATMOS_LOGS_VERBOSE
ENV var) -
Update
terraform
commands - delete the generated varfile from the component's folder after a successfulterraform apply