[GLBC] Better certificate handling (#639)
* Harden ssl cert logic to handle unknown state * Do not delete non-controller-created certificates (pre-shared certs) * Remove unnecessary variable * Added three tests to check ssl certificate naming * Address review comments * Early return instead of large code block
This commit is contained in:
parent
7deb1a2beb
commit
cd3e546c80
3 changed files with 253 additions and 95 deletions
|
|
@ -18,6 +18,7 @@ package utils
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -310,7 +311,7 @@ func (g GCEURLMap) PutDefaultBackend(d *compute.BackendService) {
|
|||
}
|
||||
}
|
||||
|
||||
// FakeNotFoundErr creates a NotFound error with type googleapi.Error
|
||||
// FakeGoogleAPINotFoundErr creates a NotFound error with type googleapi.Error
|
||||
func FakeGoogleAPINotFoundErr() *googleapi.Error {
|
||||
return &googleapi.Error{Code: 404}
|
||||
}
|
||||
|
|
@ -322,6 +323,15 @@ func IsHTTPErrorCode(err error, code int) bool {
|
|||
return ok && apiErr.Code == code
|
||||
}
|
||||
|
||||
// IgnoreHTTPNotFound returns the passed err if it's not a GoogleAPI error
|
||||
// with a NotFound status code.
|
||||
func IgnoreHTTPNotFound(err error) error {
|
||||
if err != nil && IsHTTPErrorCode(err, http.StatusNotFound) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// CompareLinks returns true if the 2 self links are equal.
|
||||
func CompareLinks(l1, l2 string) bool {
|
||||
// TODO: These can be partial links
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue