From 1c604ecde6d6ff8145813d65f0d895aefcf34fe6 Mon Sep 17 00:00:00 2001 From: Aravind N Date: Thu, 8 Feb 2024 10:34:19 +0530 Subject: [PATCH] Add Skip TLS Verification flag --- .github/workflows/integration.yml | 1 + cmd/root.go | 6 ++++++ cmd/sync.go | 9 +++++++-- internal/argocd/api.go | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7057135..30a664d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -2,6 +2,7 @@ name: Integration Test on: push: + branches: [ enhancement/skip-tls-verification ] jobs: build: diff --git a/cmd/root.go b/cmd/root.go index 52685c8..cc9f549 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,5 +27,11 @@ func Root() *cobra.Command { log.Fatalf("Lethal damage: %s\n\n", err) } + cmd.PersistentFlags().String("disableTlsVerification", "", "Disable TLS verification") + + if err := cmd.MarkPersistentFlagRequired("disableTlsVerification"); err != nil { + log.Fatalf("Lethal damage: %s\n\n", err) + } + return cmd } diff --git a/cmd/sync.go b/cmd/sync.go index edf9c6f..97dd60a 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -1,6 +1,8 @@ package cmd import ( + "strconv" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -17,10 +19,13 @@ func Sync() *cobra.Command { address, _ := cmd.Flags().GetString("address") token, _ := cmd.Flags().GetString("token") application, _ := cmd.Flags().GetString("application") + disableTlsVerification, _ := cmd.Flags().GetString("disableTlsVerification") + disableTlsVerificationBool, _ := strconv.ParseBool(disableTlsVerification) api := argocd.NewAPI(&argocd.APIOptions{ - Address: address, - Token: token, + Address: address, + Token: token, + DisableTlsVerification: disableTlsVerificationBool, }) controller := ctrl.NewController(api) diff --git a/internal/argocd/api.go b/internal/argocd/api.go index c2d40fd..0207fec 100644 --- a/internal/argocd/api.go +++ b/internal/argocd/api.go @@ -25,6 +25,7 @@ type API struct { type APIOptions struct { Address string Token string + DisableTlsVerification bool } // NewAPI creates new API. @@ -33,6 +34,7 @@ func NewAPI(options *APIOptions) API { ServerAddr: options.Address, AuthToken: options.Token, GRPCWeb: true, + Insecure: options.DisableTlsVerification, } connection, client := argocdclient.NewClientOrDie(&clientOptions).NewApplicationClientOrDie()