Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/k8s.io/kubectl-0.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ATGardner authored Aug 3, 2021
2 parents ee4310f + a849534 commit fa80266
Show file tree
Hide file tree
Showing 22 changed files with 321 additions and 169 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog:

# v0.2.13

### New Features:
* Allow installation of Argo-CD in `insecure` mode (useful when you want the SSL termination to happen in the ingress controller)[#144](https://github.com/argoproj-labs/argocd-autopilot/issues/144)

### Breaking Changes:
* Removed the `--namespaced` option from `repo bootstrap`. Installing argo-cd in namespaced mode cannot be used for bootstraping as the bootstrap installation contains CRDs, which are cluster scoped resources, which cannot be created by argo-cd in namespaced mode. Bottom line: it was never useable.

# v0.2.12

### New Features:
* Allow sending extra key-value pairs to app create [138](https://github.com/argoproj-labs/argocd-autopilot/issues/138)

### Documentation fixes:
* update url path to core_concepts docs [#141](https://github.com/argoproj-labs/argocd-autopilot/pull/141)

# v0.2.11

### Bug fixes:
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
VERSION=v0.2.11
VERSION=v0.2.13
OUT_DIR=dist

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
4 changes: 0 additions & 4 deletions build/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ steps:
title: linux_s390x
environment:
- TARGET=linux-s390x
linux_ppc64le:
title: linux_ppc64le
environment:
- TARGET=linux-ppc64le
windows_amd64:
title: windows_amd64
environment:
Expand Down
6 changes: 6 additions & 0 deletions cmd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type (
AppOpts *application.CreateOptions
KubeFactory kube.Factory
Timeout time.Duration
Labels map[string]string
}

AppDeleteOptions struct {
Expand Down Expand Up @@ -217,6 +218,7 @@ func RunAppCreate(ctx context.Context, opts *AppCreateOptions) error {

log.G(ctx).WithField("timeout", opts.Timeout).Infof("Waiting for '%s' to finish syncing", opts.AppOpts.AppName)
fullName := fmt.Sprintf("%s-%s", opts.ProjectName, opts.AppOpts.AppName)

// wait for argocd to be ready before applying argocd-apps
stop := util.WithSpinner(ctx, fmt.Sprintf("waiting for '%s' to be ready", fullName))
if err = waitAppSynced(ctx, opts.KubeFactory, opts.Timeout, fullName, namespace, revision, true); err != nil {
Expand Down Expand Up @@ -245,6 +247,10 @@ var setAppOptsDefaults = func(ctx context.Context, repofs fs.FS, opts *AppCreate
opts.AppOpts.DestNamespace = "default"
}

if opts.AppOpts.Labels == nil {
opts.AppOpts.Labels = opts.Labels
}

if opts.AppOpts.AppType != "" {
return nil
}
Expand Down
20 changes: 16 additions & 4 deletions cmd/commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type (
DestKubeContext string
DryRun bool
AddCmd argocd.AddClusterCmd
Labels map[string]string
}

ProjectDeleteOptions struct {
Expand All @@ -55,6 +56,7 @@ type (
RepoURL string
Revision string
InstallationPath string
Labels map[string]string
}
)

Expand Down Expand Up @@ -171,6 +173,7 @@ func RunProjectCreate(ctx context.Context, opts *ProjectCreateOptions) error {
InstallationPath: opts.CloneOpts.Path(),
DefaultDestServer: destServer,
DefaultDestContext: opts.DestKubeContext,
Labels: opts.Labels,
})
if err != nil {
return fmt.Errorf("failed to generate project resources: %w", err)
Expand Down Expand Up @@ -280,10 +283,7 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
destNamespace: "{{ destNamespace }}",
prune: true,
preserveResourcesOnDeletion: false,
appLabels: map[string]string{
store.Default.LabelKeyAppManagedBy: store.Default.LabelValueManagedBy,
"app.kubernetes.io/name": "{{ appName }}",
},
appLabels: getDefaultAppLabels(o.Labels),
generators: []appset.ApplicationSetGenerator{
{
Git: &appset.GitGenerator{
Expand Down Expand Up @@ -315,6 +315,18 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
return
}

func getDefaultAppLabels(labels map[string]string) map[string]string {
res := map[string]string{
store.Default.LabelKeyAppManagedBy: store.Default.LabelValueManagedBy,
store.Default.LabelKeyAppName: "{{ appName }}",
}
for k, v := range labels {
res[k] = v
}

return res
}

func NewProjectListCommand(cloneOpts *git.CloneOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "list ",
Expand Down
61 changes: 60 additions & 1 deletion cmd/commands/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestRunProjectCreate(t *testing.T) {
}
}

func Test_generateProject(t *testing.T) {
func Test_generateProjectManifests(t *testing.T) {
tests := map[string]struct {
o *GenerateProjectOptions
wantName string
Expand All @@ -168,6 +168,7 @@ func Test_generateProject(t *testing.T) {
wantDefaultDestServer string
wantProject string
wantContextName string
wantLabels map[string]string
}{
"should generate project and appset with correct values": {
o: &GenerateProjectOptions{
Expand All @@ -178,6 +179,9 @@ func Test_generateProject(t *testing.T) {
RepoURL: "repoUrl",
Revision: "revision",
InstallationPath: "some/path",
Labels: map[string]string{
"some-key": "some-value",
},
},
wantName: "name",
wantNamespace: "namespace",
Expand All @@ -186,6 +190,11 @@ func Test_generateProject(t *testing.T) {
wantRevision: "revision",
wantDefaultDestServer: "defaultDestServer",
wantContextName: "some-context-name",
wantLabels: map[string]string{
"some-key": "some-value",
store.Default.LabelKeyAppManagedBy: store.Default.LabelValueManagedBy,
store.Default.LabelKeyAppName: "{{ appName }}",
},
},
}
for ttname, tt := range tests {
Expand Down Expand Up @@ -647,3 +656,53 @@ func TestRunProjectDelete(t *testing.T) {
})
}
}

func Test_getDefaultAppLabels(t *testing.T) {
tests := map[string]struct {
labels map[string]string
want map[string]string
}{
"Should return the default map when sending nil": {
labels: nil,
want: map[string]string{
store.Default.LabelKeyAppManagedBy: store.Default.LabelValueManagedBy,
store.Default.LabelKeyAppName: "{{ appName }}",
},
},
"Should contain any additional labels sent": {
labels: map[string]string{
"something": "or the other",
},
want: map[string]string{
"something": "or the other",
store.Default.LabelKeyAppManagedBy: store.Default.LabelValueManagedBy,
store.Default.LabelKeyAppName: "{{ appName }}",
},
},
"Should overwrite the default managed by": {
labels: map[string]string{
store.Default.LabelKeyAppManagedBy: "someone else",
},
want: map[string]string{
store.Default.LabelKeyAppManagedBy: "someone else",
store.Default.LabelKeyAppName: "{{ appName }}",
},
},
"Should overwrite the default app name": {
labels: map[string]string{
store.Default.LabelKeyAppName: "another name",
},
want: map[string]string{
store.Default.LabelKeyAppManagedBy: store.Default.LabelValueManagedBy,
store.Default.LabelKeyAppName: "another name",
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
if got := getDefaultAppLabels(tt.labels); !reflect.DeepEqual(got, tt.want) {
t.Errorf("getDefaultAppLabels() = %v, want %v", got, tt.want)
}
})
}
}
17 changes: 9 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,7 @@ func setBootstrapOptsDefaults(opts RepoBootstrapOptions) (*RepoBootstrapOptions,
}

if opts.AppSpecifier == "" {
opts.AppSpecifier = getBootstrapAppSpecifier(opts.Namespaced)
opts.AppSpecifier = getBootstrapAppSpecifier(opts.Insecure)
}

if _, err := os.Stat(opts.AppSpecifier); err == nil {
Expand Down Expand Up @@ -478,9 +479,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
14 changes: 7 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,24 @@ 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)
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion docs/Getting-Started.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started

This guide assumes you are familiar with Argo CD and its basic concepts. See the [Argo CD documentation](https://argoproj.github.io/Argo CD/core_concepts/) for more information.
This guide assumes you are familiar with Argo CD and its basic concepts. See the [Argo CD documentation](https://argoproj.github.io/argo-cd/core_concepts/) for more information.

## Before you Begin
### Requirements
Expand Down
Loading

0 comments on commit fa80266

Please sign in to comment.