Skip to content

Commit

Permalink
fix: Improve error handling for enterprise certificate module (#1848)
Browse files Browse the repository at this point in the history
ECP client now returns a typed error to cover all situations where ECP config is unavailable or incomplete.
  • Loading branch information
andyrzhao authored Feb 10, 2023
1 parent 8980266 commit 3fb5b61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go/compute/metadata v0.2.3
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/googleapis/enterprise-certificate-proxy v0.2.1
github.com/googleapis/enterprise-certificate-proxy v0.2.2
github.com/googleapis/gax-go/v2 v2.7.0
go.opencensus.io v0.24.0
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.2.1 h1:RY7tHKZcRlk788d5WSo/e83gOyyy742E8GSs771ySpg=
github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
github.com/googleapis/enterprise-certificate-proxy v0.2.2 h1:jUqbmxlR+gGPQq/uvQviKpS1bSQecfs2t7o6F14sk9s=
github.com/googleapis/enterprise-certificate-proxy v0.2.2/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
github.com/googleapis/gax-go/v2 v2.7.0 h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1YupQSSQ=
github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
4 changes: 1 addition & 3 deletions transport/cert/enterprise_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package cert
import (
"crypto/tls"
"errors"
"os"

"github.com/googleapis/enterprise-certificate-proxy/client"
)
Expand All @@ -36,8 +35,7 @@ type ecpSource struct {
func NewEnterpriseCertificateProxySource(configFilePath string) (Source, error) {
key, err := client.Cred(configFilePath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
// Config file missing means Enterprise Certificate Proxy is not supported.
if errors.Is(err, client.ErrCredUnavailable) {
return nil, errSourceUnavailable
}
return nil, err
Expand Down

0 comments on commit 3fb5b61

Please sign in to comment.