-
Notifications
You must be signed in to change notification settings - Fork 3
Added k8s mappings and dynamic scope #27
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
| scope, err := mapData.InterpolateScope(r.Values) | ||
|
|
||
| if err != nil { | ||
| log.WithContext(ctx).WithError(err).Infof("could not find scope mapping variables %v, adding them will result in better results. Error: ", mapData.Scope) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
DavidS-ovm
left a comment
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.
Do I see correctly that this is currently only supporting a single kubernetes cluster?
|
Aaaaaaarrrrgh how do I keep forgetting that. Hold please |
I blame the heat! |
| mappings := append(awsMappings, k8sMappings...) | ||
|
|
||
| if len(mappings) == 0 { | ||
| log.WithContext(ctx).WithFields(lf).WithField("terraform-address", resourceChange.Address).Warn("skipping unmapped resource") |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
| queryStr, ok := r.Values[mapData.QueryField] | ||
| currentResource = plan.PlannedValues.RootModule.DigResource(resourceChange.Address) | ||
| if currentResource == nil { | ||
| log.WithContext(ctx). |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
| configResource := plan.Config.RootModule.DigResource(resourceChange.Address) | ||
|
|
||
| if configResource == nil { | ||
| log.WithContext(ctx). |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
| err = json.Unmarshal(overmindMappings.Value, &mappings) | ||
|
|
||
| if err != nil { | ||
| log.WithContext(ctx). |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
| currentProviderMappings, ok := mappings[configResource.ProviderConfigKey] | ||
|
|
||
| if ok { | ||
| log.WithContext(ctx). |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
|
Well that was a lot harder than I thought it was going to be. In order to be flexible enough we really need to be able to map to any terraform value, plus the overmind mappings we've described. This involved reimplementing basically the entire Terraform string interpolation logic. Meaning that we can use anything that is valid for terraform as a mapping. The kube source now contains example if this i.e. // +overmind:terraform:queryMap kubernetes_deployment.metadata[0].name
// +overmind:terraform:queryMap kubernetes_deployment_v1.metadata[0].name
// +overmind:terraform:scope ${provider_mapping.cluster_name}.${values.metadata[0].namespace} |
d049b1b to
f0cafb5
Compare
This allows scopes to be defined dynamically using any combination of plan outputs and resource values
Fixes #25
Fixes #26