summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2021-08-17 17:37:17 +0000
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2021-08-17 17:37:17 +0000
commit41146cce2bb672c2082537a39f608fbf20f8985f (patch)
tree49cea38229af396c8b1eda8391a8805e0a849811
parent566a74d01f862bc05a6400b84759859a308fc31a (diff)
downloadgitlab-shell-41146cce2bb672c2082537a39f608fbf20f8985f.tar.gz
test: move os.stat check before the hcc creation
-rw-r--r--client/httpclient.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/client/httpclient.go b/client/httpclient.go
index fceb0f4..a2ecfd0 100644
--- a/client/httpclient.go
+++ b/client/httpclient.go
@@ -74,6 +74,13 @@ func NewHTTPClientWithOpts(gitlabURL, gitlabRelativeURLRoot, caFile, caPath stri
} else if strings.HasPrefix(gitlabURL, httpProtocol) {
transport, host = buildHttpTransport(gitlabURL)
} else if strings.HasPrefix(gitlabURL, httpsProtocol) {
+ if _, err := os.Stat(caFile); err != nil {
+ if os.IsNotExist(err) {
+ return nil, fmt.Errorf("cannot find cafile '%s': %w", caFile, ErrCafileNotFound)
+ }
+ return nil, err
+ }
+
hcc := &httpClientCfg{
caFile: caFile,
caPath: caPath,
@@ -83,13 +90,6 @@ func NewHTTPClientWithOpts(gitlabURL, gitlabRelativeURLRoot, caFile, caPath stri
opt(hcc)
}
- if _, err := os.Stat(caFile); err != nil {
- if os.IsNotExist(err) {
- return nil, fmt.Errorf("cannot find cafile '%s': %w", caFile, ErrCafileNotFound)
- }
- return nil, err
- }
-
transport, host, err = buildHttpsTransport(*hcc, selfSignedCert, gitlabURL)
if err != nil {
return nil, err