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

added insecure option to repo-bootstrap, removed namespaced installation #145

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ CLI_NAME?=argocd-autopilot
IMAGE_REPOSITORY?=quay.io
IMAGE_NAMESPACE?=argoprojlabs

INSTALLATION_MANIFESTS_URL="github.com/argoproj-labs/argocd-autopilot/manifests?ref=$(VERSION)"
INSTALLATION_MANIFESTS_NAMESPACED_URL="github.com/argoproj-labs/argocd-autopilot/manifests/namespace-install?ref=$(VERSION)"
INSTALLATION_MANIFESTS_URL="github.com/argoproj-labs/argocd-autopilot/manifests/base?ref=$(VERSION)"
INSTALLATION_MANIFESTS_INSECURE_URL="github.com/argoproj-labs/argocd-autopilot/manifests/insecure?ref=$(VERSION)"

DEV_INSTALLATION_MANIFESTS_URL="manifests/"
DEV_INSTALLATION_MANIFESTS_NAMESPACED_URL="manifests/namespace-install"
DEV_INSTALLATION_MANIFESTS_URL="manifests/base"
DEV_INSTALLATION_MANIFESTS_INSECURE_URL="manifests/insecure"

CLI_SRCS := $(shell find . -name '*.go')

Expand Down
21 changes: 13 additions & 8 deletions cmd/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ type (
InstallationMode string
Namespace string
KubeConfig string
Namespaced bool
DryRun bool
HidePassword bool
Insecure bool
Timeout time.Duration
KubeFactory kube.Factory
CloneOptions *git.CloneOptions
Expand Down Expand Up @@ -97,9 +97,9 @@ func NewRepoCommand() *cobra.Command {
func NewRepoBootstrapCommand() *cobra.Command {
var (
appSpecifier string
namespaced bool
dryRun bool
hidePassword bool
insecure bool
installationMode string
cloneOpts *git.CloneOptions
f kube.Factory
Expand Down Expand Up @@ -135,9 +135,9 @@ func NewRepoBootstrapCommand() *cobra.Command {
InstallationMode: installationMode,
Namespace: cmd.Flag("namespace").Value.String(),
KubeConfig: cmd.Flag("kubeconfig").Value.String(),
Namespaced: namespaced,
DryRun: dryRun,
HidePassword: hidePassword,
Insecure: insecure,
Timeout: util.MustParseDuration(cmd.Flag("request-timeout").Value.String()),
KubeFactory: f,
CloneOptions: cloneOpts,
Expand All @@ -146,9 +146,9 @@ func NewRepoBootstrapCommand() *cobra.Command {
}

cmd.Flags().StringVar(&appSpecifier, "app", "", "The application specifier (e.g. github.com/argoproj-labs/argocd-autopilot/manifests?ref=v0.2.5), overrides the default installation argo-cd manifests")
cmd.Flags().BoolVar(&namespaced, "namespaced", false, "If true, install a namespaced version of argo-cd (no need for cluster-role)")
cmd.Flags().BoolVar(&dryRun, "dry-run", false, "If true, print manifests instead of applying them to the cluster (nothing will be commited to git)")
cmd.Flags().BoolVar(&hidePassword, "hide-password", false, "If true, will not print initial argo cd password")
cmd.Flags().BoolVar(&insecure, "insecure", false, "Run Argo-CD server without TLS")
cmd.Flags().StringVar(&installationMode, "installation-mode", "normal", "One of: normal|flat. "+
"If flat, will commit the bootstrap manifests, otherwise will commit the bootstrap kustomization.yaml")

Expand Down Expand Up @@ -270,6 +270,7 @@ func RunRepoBootstrap(ctx context.Context, opts *RepoBootstrapOptions) error {
Username: "admin",
Password: passwd,
KubeConfig: opts.KubeConfig,
Insecure: opts.Insecure,
})
if err != nil {
return err
Expand Down Expand Up @@ -407,7 +408,11 @@ func setBootstrapOptsDefaults(opts RepoBootstrapOptions) (*RepoBootstrapOptions,
}

if opts.AppSpecifier == "" {
opts.AppSpecifier = getBootstrapAppSpecifier(opts.Namespaced)
opts.AppSpecifier = getBootstrapAppSpecifier(opts.Insecure)
} else {
if opts.Insecure {
return nil, fmt.Errorf("cannot use flag '--insecure' in combination with '--app' flag")
}
}

if _, err := os.Stat(opts.AppSpecifier); err == nil {
Expand Down Expand Up @@ -478,9 +483,9 @@ func getInitialPassword(ctx context.Context, f kube.Factory, namespace string) (
return string(passwd), nil
}

func getBootstrapAppSpecifier(namespaced bool) string {
if namespaced {
return store.Get().InstallationManifestsNamespacedURL
func getBootstrapAppSpecifier(insecure bool) string {
if insecure {
return store.Get().InstallationManifestsInsecureURL
}

return store.Get().InstallationManifestsURL
Expand Down
26 changes: 19 additions & 7 deletions cmd/commands/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func Test_setBootstrapOptsDefaults(t *testing.T) {
assertFn: func(t *testing.T, opts *RepoBootstrapOptions, ret error) {
assert.NoError(t, ret)
assert.Equal(t, "argocd", opts.Namespace)
assert.Equal(t, false, opts.Namespaced)
assert.Equal(t, "manifests", opts.AppSpecifier)
assert.Equal(t, false, opts.Insecure)
assert.Equal(t, "manifests/base", opts.AppSpecifier)
},
},
"With App specifier": {
Expand All @@ -62,24 +62,36 @@ func Test_setBootstrapOptsDefaults(t *testing.T) {
assertFn: func(t *testing.T, opts *RepoBootstrapOptions, ret error) {
assert.NoError(t, ret)
assert.Equal(t, "argocd", opts.Namespace)
assert.Equal(t, false, opts.Namespaced)
assert.Equal(t, false, opts.Insecure)
assert.Equal(t, installationModeNormal, opts.InstallationMode)
assert.Equal(t, "https://github.com/foo/bar", opts.AppSpecifier)
},
},
"Namespaced": {
"Insecure": {
opts: &RepoBootstrapOptions{
CloneOptions: &git.CloneOptions{},
InstallationMode: installationModeFlat,
Namespaced: true,
Insecure: true,
Namespace: "bar",
},
assertFn: func(t *testing.T, opts *RepoBootstrapOptions, ret error) {
assert.NoError(t, ret)
assert.Equal(t, "bar", opts.Namespace)
assert.Equal(t, true, opts.Namespaced)
assert.Equal(t, true, opts.Insecure)
assert.Equal(t, installationModeFlat, opts.InstallationMode)
assert.Equal(t, "manifests/namespace-install", opts.AppSpecifier)
assert.Equal(t, "manifests/insecure", opts.AppSpecifier)
},
},
"InsecureWithAppSpecifier": {
opts: &RepoBootstrapOptions{
CloneOptions: &git.CloneOptions{},
InstallationMode: installationModeFlat,
Insecure: true,
Namespace: "bar",
AppSpecifier: "https://github.com/foo/bar",
},
assertFn: func(t *testing.T, opts *RepoBootstrapOptions, ret error) {
assert.EqualError(t, ret, "cannot use flag '--insecure' in combination with '--app' flag")
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
code.gitea.io/sdk/gitea v0.14.1
github.com/argoproj-labs/applicationset v0.1.0
github.com/argoproj/argo-cd v1.8.7
github.com/argoproj/argo-cd/v2 v2.0.3
github.com/argoproj/gitops-engine v0.3.3
github.com/argoproj/argo-cd/v2 v2.1.0-rc1
github.com/argoproj/gitops-engine v0.3.1-0.20210709004906-a4c77d5c70fb
github.com/briandowns/spinner v1.13.0
github.com/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.3.1
Expand All @@ -19,6 +19,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.7.0
google.golang.org/grpc/examples v0.0.0-20210730002332-ea9b7a0a7651 // indirect
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/cli-runtime v0.21.1
Expand Down
Loading