Skip to content

Commit

Permalink
Add Skip TLS Verification flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindnswamy committed Feb 8, 2024
1 parent d529271 commit 1c604ec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Integration Test

on:
push:
branches: [ enhancement/skip-tls-verification ]

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 7 additions & 2 deletions cmd/sync.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"strconv"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions internal/argocd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type API struct {
type APIOptions struct {
Address string
Token string
DisableTlsVerification bool
}

// NewAPI creates new API.
Expand All @@ -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()
Expand Down

0 comments on commit 1c604ec

Please sign in to comment.