Skip to content

Commit

Permalink
consolidate comments
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 committed Aug 14, 2019
1 parent 6084e07 commit cf5cc8a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions templates/terraform/constants/scheduler_auth.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ func validateAuthHeaders(diff *schema.ResourceDiff, v interface{}) error {


func authHeaderDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// If generating an `oauth_token` and `scope` is not provided in the configuration,
// the default "https://www.googleapis.com/auth/cloud-platform" scope will be used.
// Similarly, if generating an `oidc_token` and `audience` is not provided in the
// configuration, the URI specified in target will be used. Although not in the
// configuration, in both cases the default is returned in the object, but is not in.
// state. We suppress the diff if the values are these defaults but are not stored in state.

b := strings.Split(k, ".")
if b[0] == "http_target" && len(b) > 4 {
block := b[2]
attr := b[4]

// If generating an oauth_token and scope is not provided in the configuration,
// the default "https://www.googleapis.com/auth/cloud-platform" scope will be used.
// Although not in the configuration, this is returned and will be stored in state.
if block == "oauth_token" && attr == "scope" {
if old == canonicalizeServiceScope("cloud-platform") && new == "" {
return true
}
}

// If generating an oidc_token and audience is not provided in the configuration,
// the URI specified in target will be used. Although not in the configuration,
// this is returned and will be stored in state.
if block == "oidc_token" && attr == "audience" {
uri := d.Get(strings.Join(b[0:2], ".")+".uri")
if old == uri && new == "" {
Expand Down

0 comments on commit cf5cc8a

Please sign in to comment.