-
Notifications
You must be signed in to change notification settings - Fork 1
feat: terraform variables added to input #165
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
Conversation
Input can override template vars, implementing the equivalent of '-var' in terraform.
aa4c103
to
b1e7015
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.
seems sensible!
tfvars/load.go
Outdated
// Intentionally commented out to avoid loading from host environment | ||
// | ||
//for _, env := range os.Environ() { | ||
// split := strings.Split(env, "=") | ||
// key := split[0] | ||
// if !strings.HasPrefix(key, "TF_VAR_") { | ||
// continue | ||
// } | ||
// key = strings.TrimPrefix(key, "TF_VAR_") | ||
// var val string | ||
// if len(split) > 1 { | ||
// val = split[1] | ||
// } | ||
// combinedVars[key] = cty.StringVal(val) | ||
//} |
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.
hmm. feels a bit weird to leave this code, but it is also nice to have the comment noting that it's explicitly not a desired behavior.
maybe we leave the comment but remove the actual code? it's not a big deal either way tho
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.
Yea, I was a bit unsure. If someone was to reference the original source, they might assume this piece of code was accidentally omitted, or should be added.
I'll remove the code, and just add in a longer comment to describe it better.
Input can override template vars, implementing the equivalent of '-var' in terraform.
To make this work, the
*.tfvar
files have to be manually parsed. Trivy takes either a set of variable values XOR a set of tfvar files. This code reads the variable values from the files, then overrides with any user supplied values.