Update gitlab client to skip certificate verification for hosted instances (#158)

This commit is contained in:
Jay Gabriels
2021-10-17 13:23:59 -07:00
committed by GitHub
parent 77e81e2c12
commit 4a5d7d31e0
3 changed files with 18 additions and 2 deletions

View File

@@ -2,6 +2,15 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
## [1.7.3] - Unreleased
### Added
### Changed
- Gitlab client to skip verification of ssl certificates for hosted gitlab servers
### Deprecated
### Removed
### Fixed
### Security
## [1.7.2] - 10/14/21
### Added
- GHORG_NO_CLEAN only clones new repos and does not perform a git clean on existing repos; thanks @harmathy

View File

@@ -11,6 +11,6 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of Ghorg",
Long: `All software has versions. This is Ghorg's`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("v1.7.2")
fmt.Println("v1.7.3")
},
}

View File

@@ -1,7 +1,9 @@
package scm
import (
"crypto/tls"
"fmt"
"net/http"
"os"
"strings"
@@ -183,7 +185,12 @@ func (_ Gitlab) NewClient() (Client, error) {
var err error
var c *gitlab.Client
if baseURL != "" {
c, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
opt := gitlab.WithHTTPClient(client)
c, err = gitlab.NewClient(token, gitlab.WithBaseURL(baseURL), opt)
} else {
c, err = gitlab.NewClient(token)
}