Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(argocd client): Add handling of argocd-api-plaintext option #274

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ func init() {
stringFlag(flags, "argocd-api-server-addr", "ArgoCD API Server Address.",
newStringOpts().
withDefault("argocd-server"))
boolFlag(flags, "argocd-api-insecure", "Enable to use insecure connections to the ArgoCD API server.")
boolFlag(flags, "argocd-api-insecure", "Enable to use insecure connections over TLS to the ArgoCD API server.")
stringFlag(flags, "argocd-api-namespace", "ArgoCD namespace where the application watcher will read Custom Resource Definitions (CRD) for Application and ApplicationSet resources.",
newStringOpts().
withDefault("argocd"))
boolFlag(flags, "argocd-api-plaintext", "Enable to use plaintext connections without TLS.")
stringFlag(flags, "kubernetes-type", "Kubernetes Type One of eks, or local. Defaults to local.",
newStringOpts().
withChoices("eks", "local").
Expand Down
3 changes: 2 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ The full list of supported environment variables is described below:

|Env Var|Description|Default Value|
|-----------|-------------|------|
|`KUBECHECKS_ARGOCD_API_INSECURE`|Enable to use insecure connections to the ArgoCD API server.|`false`|
|`KUBECHECKS_ARGOCD_API_INSECURE`|Enable to use insecure connections over TLS to the ArgoCD API server.|`false`|
|`KUBECHECKS_ARGOCD_API_NAMESPACE`|ArgoCD namespace where the application watcher will read Custom Resource Definitions (CRD) for Application and ApplicationSet resources.|`argocd`|
|`KUBECHECKS_ARGOCD_API_PLAINTEXT`|Enable to use plaintext connections without TLS.|`false`|
|`KUBECHECKS_ARGOCD_API_SERVER_ADDR`|ArgoCD API Server Address.|`argocd-server`|
|`KUBECHECKS_ARGOCD_API_TOKEN`|ArgoCD API token.||
|`KUBECHECKS_ENABLE_CONFTEST`|Set to true to enable conftest policy checking of manifests.|`false`|
Expand Down
1 change: 1 addition & 0 deletions pkg/argo_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewArgoClient(cfg config.ServerConfig) (*ArgoClient, error) {
AuthToken: cfg.ArgoCDToken,
GRPCWebRootPath: cfg.ArgoCDPathPrefix,
Insecure: cfg.ArgoCDInsecure,
PlainText: cfg.ArgoCDPlainText,
}

log.Info().
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ServerConfig struct {
ArgoCDPathPrefix string `mapstructure:"argocd-api-path-prefix"`
ArgoCDInsecure bool `mapstructure:"argocd-api-insecure"`
ArgoCDNamespace string `mapstructure:"argocd-api-namespace"`
ArgoCDPlainText bool `mapstructure:"argocd-api-plaintext"`
KubernetesConfig string `mapstructure:"kubernetes-config"`
KubernetesType string `mapstructure:"kubernetes-type"`
KubernetesClusterID string `mapstructure:"kubernetes-clusterid"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ func TestNew(t *testing.T) {
v := viper.New()
v.Set("log-level", "info")
v.Set("argocd-api-insecure", "true")
v.Set("argocd-api-plaintext", "true")
v.Set("worst-conftest-state", "warning")
v.Set("repo-refresh-interval", "10m")

cfg, err := NewWithViper(v)
require.NoError(t, err)
assert.Equal(t, zerolog.InfoLevel, cfg.LogLevel)
assert.Equal(t, true, cfg.ArgoCDInsecure)
assert.Equal(t, true, cfg.ArgoCDPlainText)
assert.Equal(t, pkg.StateWarning, cfg.WorstConfTestState, "worst states can be overridden")
assert.Equal(t, time.Minute*10, cfg.RepoRefreshInterval)
}
Loading