Skip to content

Commit

Permalink
fix: insecure skip verify check for harbor with invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed May 24, 2024
1 parent cb33506 commit 6f4441a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 6 additions & 0 deletions internal/harbor/harbor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package harbor

import (
"crypto/tls"
"net/http"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -35,11 +37,15 @@ type Harbor struct {
WebhookEventTypes []string
LagoonTargetName string
Config *config.Options
TLSSkipVerify bool
}

// New create a new harbor connection.
func New(harbor Harbor) (*Harbor, error) {
harbor.Log = ctrl.Log.WithName("controllers").WithName("HarborIntegration")
if harbor.TLSSkipVerify {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
c, err := harborclientv3.NewRESTClientForHost(harbor.API, harbor.Username, harbor.Password)
if err != nil {
return nil, err
Expand Down
9 changes: 1 addition & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"net/http"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -631,6 +629,7 @@ func main() {
WebhookURL: harborLagoonWebhook,
LagoonTargetName: lagoonTargetName,
WebhookEventTypes: strings.Split(harborWebhookEventTypes, ","),
TLSSkipVerify: tlsSkipVerify,
}

deletion := deletions.New(mgr.GetClient(),
Expand Down Expand Up @@ -887,9 +886,3 @@ func main() {
os.Exit(1)
}
}

func init() {
if tlsSkipVerify {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
}

0 comments on commit 6f4441a

Please sign in to comment.