-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Support path-only when referencing ssl certificate in compute_target_https_proxy #210
Support path-only when referencing ssl certificate in compute_target_https_proxy #210
Conversation
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.
Looks good overall, just a few things.
make testacc TEST=./google TESTARGS='-run=TestAccComputeTargetHttpsProxy'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./google -v -run=TestAccComputeTargetHttpsProxy -timeout 120m
=== RUN TestAccComputeTargetHttpsProxy_basic
--- PASS: TestAccComputeTargetHttpsProxy_basic (86.83s)
=== RUN TestAccComputeTargetHttpsProxy_update
--- PASS: TestAccComputeTargetHttpsProxy_update (109.60s)
=== RUN TestAccComputeTargetHttpsProxy_invalidCertificate
--- PASS: TestAccComputeTargetHttpsProxy_invalidCertificate (0.01s)
PASS
ok github.com/terraform-providers/terraform-provider-google/google 196.585s
@rileykarson want to do a quick check on the validate/statefunc stuff since you've done a lot of thinking around those?
for k, _ := range _newMap { | ||
sslCertificates = append(sslCertificates, k) | ||
} | ||
// Exactly one ssl certificate must be specified. |
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.
Can you confirm that the API call actually fails if more than one is specified? If it silently lets it go through, we might be breaking people with this.
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.
The google cloud documentation for this resource is misleading, it says "Currently, exactly one SSL certificate must be specified." but you can specify more than one and it works. I sent feedback to that team to fix their documentation.
I updated the code, Terraform documentation and the test to confirm we can support more than one ssl certificate.
|
||
cert_ref := &compute.TargetHttpsProxiesSetSslCertificatesRequest{ | ||
SslCertificates: sslCertificates, | ||
SslCertificates: certs, |
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.
This can be simplified a bit to
SslCertificates: []string{d.Get("ssl_certificates.0")}
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.
Not applicable anymore.
CheckDestroy: testAccCheckComputeTargetHttpsProxyDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: ` |
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.
Can you separate this config into a separate var at the bottom with the rest?
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.
Done
} | ||
func testAccComputeTargetHttpsProxy_basic1(id string) string { | ||
return fmt.Sprintf(` | ||
resource "google_compute_target_https_proxy" "foobar" { |
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.
It's nice to keep these all the way to the left- it's not really necessary, just makes it easier to copy and paste
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.
Done
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.
Concerning Validate and State funcs: LGTM - I spotted a minor nit in the schema fields, but the ValidateFunc
and StateFunc
both look good.
ValidateFunc: validateRegexp(sslCertificateRegex), | ||
StateFunc: toCanonicalSslCertificate, | ||
}, | ||
MinItems: 1, |
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.
Minor nit: having Required
set implicitly sets MinItems
to 1
.
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.
fixed
value := v.(string) | ||
|
||
m := regexp.MustCompile(sslCertificateRegex).FindStringSubmatch(value) | ||
if m == nil { |
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.
I'm just curious - will m
ever be nil
? I think our ValidateFunc
makes sure that we will always see matches here.
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.
It should never be nil. Removed this line.
84b1304
to
71211fb
Compare
Looks good, thanks! Merge at will. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
issue #47
full url
andpath-only
when referencing ssl certificate in * compute_target_https_proxy. This means bothhttps://www.googleapis.com/compute/v1/projects/MY-PROJECT/global/sslCertificates/MY_CERT
andprojects/MY-PROJECT/global/sslCertificates/MY_CERT
are valid.cc/ @danawillow @rileykarson