Skip to content

Commit

Permalink
Bump to go 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
evanfarrar committed May 9, 2023
1 parent 1c803f6 commit 8623ab4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
16 changes: 10 additions & 6 deletions api/cloudcontroller/cloud_controller_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"errors"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/util"
)
Expand Down Expand Up @@ -133,18 +134,21 @@ func (connection *CloudControllerConnection) populateResponse(response *http.Res
func (*CloudControllerConnection) processRequestErrors(request *http.Request, err error) error {
switch e := err.(type) {
case *url.Error:
switch urlErr := e.Err.(type) {
case x509.UnknownAuthorityError:
if errors.As(err, &x509.UnknownAuthorityError{}) {
return ccerror.UnverifiedServerError{
URL: request.URL.String(),
}
case x509.HostnameError:
}

hostnameError := x509.HostnameError{}
if errors.As(err, &hostnameError) {
return ccerror.SSLValidationHostnameError{
Message: urlErr.Error(),
Message: hostnameError.Error(),
}
default:
return ccerror.RequestError{Err: e}
}

return ccerror.RequestError{Err: e}

default:
return err
}
Expand Down
16 changes: 10 additions & 6 deletions api/plugin/plugin_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"time"
"errors"

"code.cloudfoundry.org/cli/api/plugin/pluginerror"
"code.cloudfoundry.org/cli/util"
Expand Down Expand Up @@ -101,18 +102,21 @@ func (connection *PluginConnection) populateResponse(response *http.Response, pa
func (connection *PluginConnection) processRequestErrors(request *http.Request, err error) error {
switch e := err.(type) {
case *url.Error:
switch urlErr := e.Err.(type) {
case x509.UnknownAuthorityError:
if errors.As(err, &x509.UnknownAuthorityError{}) {
return pluginerror.UnverifiedServerError{
URL: request.URL.String(),
}
case x509.HostnameError:
}

hostnameError := x509.HostnameError{}
if errors.As(err, &hostnameError) {
return pluginerror.SSLValidationHostnameError{
Message: urlErr.Error(),
Message: hostnameError.Error(),
}
default:
return pluginerror.RequestError{Err: e}
}

return pluginerror.RequestError{Err: e}

default:
return err
}
Expand Down
3 changes: 2 additions & 1 deletion api/uaa/uaa_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"time"
"errors"

"code.cloudfoundry.org/cli/util"
)
Expand Down Expand Up @@ -100,7 +101,7 @@ func (connection *UAAConnection) populateResponse(response *http.Response, passe
func (connection *UAAConnection) processRequestErrors(request *http.Request, err error) error {
switch e := err.(type) {
case *url.Error:
if _, ok := e.Err.(x509.UnknownAuthorityError); ok {
if errors.As(err, &x509.UnknownAuthorityError{}) {
return UnverifiedServerError{
URL: request.URL.String(),
}
Expand Down
14 changes: 9 additions & 5 deletions cf/net/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strings"
asErrors "errors"

"code.cloudfoundry.org/cli/cf/errors"
. "code.cloudfoundry.org/cli/cf/i18n"
Expand Down Expand Up @@ -83,14 +84,17 @@ func WrapNetworkErrors(host string, err error) error {
}

if innerErr != nil {
switch typedInnerErr := innerErr.(type) {
case x509.UnknownAuthorityError:
if asErrors.As(innerErr, &x509.UnknownAuthorityError{}){
return errors.NewInvalidSSLCert(host, T("unknown authority"))
case x509.HostnameError:
}
if asErrors.As(innerErr, &x509.HostnameError{}){
return errors.NewInvalidSSLCert(host, T("not valid for the requested host"))
case x509.CertificateInvalidError:
}
if asErrors.As(innerErr, &x509.CertificateInvalidError{}){
return errors.NewInvalidSSLCert(host, "")
case *net.OpError:
}
typedInnerErr := new(net.OpError)
if asErrors.As(innerErr, &typedInnerErr) {
if typedInnerErr.Op == "dial" {
return fmt.Errorf("%s: %s\n%s", T("Error performing request"), err.Error(), T("TIP: If you are behind a firewall and require an HTTP proxy, verify the https_proxy environment variable is correctly set. Else, check your network connection."))
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module code.cloudfoundry.org/cli

go 1.19
go 1.20

require (
code.cloudfoundry.org/bytefmt v0.0.0-20170428003108-f4415fafc561
Expand Down Expand Up @@ -41,7 +41,7 @@ require (
github.com/sirupsen/logrus v1.2.0
github.com/tedsuo/rata v1.0.1-0.20170830210128-07d200713958
github.com/vito/go-interact v0.0.0-20171111012221-fa338ed9e9ec
golang.org/x/crypto v0.4.0
golang.org/x/crypto v0.8.0
golang.org/x/net v0.9.0
golang.org/x/text v0.9.0
gopkg.in/cheggaaa/pb.v1 v1.0.27
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand Down

0 comments on commit 8623ab4

Please sign in to comment.