Skip to content
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

Add custom flatten for monitoring channel labels #1251

Merged

Conversation

emilymye
Copy link
Contributor

@emilymye emilymye commented Jan 15, 2019

Also fix some "pertain" license text 😠

Why this is a custom flatten:

  • DiffSuppressFunc is not called for TypeMap elements in Terraform. We don't want to suppress the entire labels map diff.
  • CustomizeDiff only allows modification of the actual Diff elements for Computed values, which is not what we want to default to for labels. (Correct me if I am wrong)

Fixes hashicorp/terraform-provider-google#2839


[all]

[terraform]

Add custom flatten for monitoring channel labels

[terraform-beta]

Add custom flatten for monitoring channel labels

[ansible]

[inspec]

@rileykarson
Copy link
Member

rileykarson commented Jan 15, 2019

Is this resolving a user's issue? Also -me, @chrisst has the most context here.

@rileykarson rileykarson removed their request for review January 15, 2019 20:32
@emilymye
Copy link
Contributor Author

Added issue to description

@modular-magician
Copy link
Collaborator

I am a robot that works on MagicModules PRs!

I built this PR into one or more PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#352
depends: hashicorp/terraform-provider-google#2879

@rileykarson
Copy link
Member

Thanks!

}

replace := true
for i := 0; i < len(stateLabel); i++ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this just be a regex match for "serverLabel matches \*+ and len(stateLabel) = len(serverLabel)"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose so? This is ugly but it matches against the rest of the value that isn't asterisked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, what does that mean? Can you post an example of two strings you need to compare?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in understanding that a len 4 label (for certain labels) submitted to the api will come back obfuscated as a len 4 "****" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**CRET vs SECRET (see hashicorp/terraform-provider-google#2839)

It appears that len(secret) <= 4 is left as is. I'm not sure I want to rely on the unobfuscated value always being 4 characters, hence the ugly match, but if you feel like that's an ok thing to rely on, I can change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It partially obfuscates them? Goodness. Okay, let me see if I can devise a regex for that ... Whew.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, my way is doable but worse. Your solution LGTM - please explain in comments, if you don't mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just... wow

@chrisst
Copy link
Contributor

chrisst commented Jan 16, 2019

I ran into these "sensitive" fields in a different api and never really came up with a perfect solution. My understanding of what you have is "if server sends back stars, overwrite server response with local version". But I think that means you aren't able to tell if the user has actually changed the value of the sensitive label from "foo" to "bar". I ended up with a similar strategy of returning whatever was coming from d.Get instead of the api response for sensitive fields.

Right now the only issue I see is that it's hard to read what is going on. I think a small refactor would clear up what is going on. Maybe something like:

for serverLabel in serverLabels:
if isSensitiveLabel(serverLabel) {
// replace server response
}

it can help reduce the number of break conditions in your loop and you can throw a couple quick tests around the helper method with expected inputs and outputs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit bb4b9c5) have been included in your existing downstream PRs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit ac00e11) have been included in your existing downstream PRs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit b125b16) have been included in your existing downstream PRs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit bdfbaa2) have been included in your existing downstream PRs.

Copy link
Contributor

@chrisst chrisst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples/tests help a ton, thanks.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit 749a445) have been included in your existing downstream PRs.

@modular-magician modular-magician merged commit a516632 into GoogleCloudPlatform:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_monitoring_notification_channel: subsequent runs throw errors for slack and pagerduty
6 participants