Skip to content

Conversation

@dylanratcliffe
Copy link
Member

This allows scopes to be defined dynamically using any combination of plan outputs and resource values

Fixes #25
Fixes #26

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

[Sensitive data returned by an access to apiKey](1) flows to a logging call.
Copy link
Contributor

@DavidS-ovm DavidS-ovm left a 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?

@dylanratcliffe
Copy link
Member Author

Aaaaaaarrrrgh how do I keep forgetting that. Hold please

@DavidS-ovm
Copy link
Contributor

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

[Sensitive data returned by an access to apiKey](1) flows to a logging call.
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

[Sensitive data returned by an access to apiKey](1) flows to a logging call.
configResource := plan.Config.RootModule.DigResource(resourceChange.Address)

if configResource == nil {
log.WithContext(ctx).

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

[Sensitive data returned by an access to apiKey](1) flows to a logging call.
err = json.Unmarshal(overmindMappings.Value, &mappings)

if err != nil {
log.WithContext(ctx).

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

[Sensitive data returned by an access to apiKey](1) flows to a logging call.
currentProviderMappings, ok := mappings[configResource.ProviderConfigKey]

if ok {
log.WithContext(ctx).

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information

[Sensitive data returned by an access to apiKey](1) flows to a logging call.
@dylanratcliffe
Copy link
Member Author

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}

@dylanratcliffe dylanratcliffe merged commit 9c730e6 into main Jul 28, 2023
@dylanratcliffe dylanratcliffe deleted the k8s-additions branch July 28, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add k8s mappings Support getting the scope from the attributes of the matched resources

3 participants