Skip to content

Commit

Permalink
updated argocd + golang
Browse files Browse the repository at this point in the history
  • Loading branch information
ATGardner committed Nov 17, 2022
1 parent d8820f2 commit 559c773
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 248 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ USER 999
WORKDIR /home/autopilot

### Build
FROM docker.io/library/golang:1.17 as build
FROM docker.io/library/golang:1.19 as build

WORKDIR /go/src/github.com/argoproj-labs/argocd-autopilot

Expand Down
17 changes: 8 additions & 9 deletions cmd/commands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/argoproj-labs/argocd-autopilot/pkg/store"
"github.com/argoproj-labs/argocd-autopilot/pkg/util"

appset "github.com/argoproj/applicationset/api/v1alpha1"
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/ghodss/yaml"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -179,7 +178,7 @@ type createAppSetOptions struct {
preserveResourcesOnDeletion bool
appLabels map[string]string
appAnnotations map[string]string
generators []appset.ApplicationSetGenerator
generators []argocdv1alpha1.ApplicationSetGenerator
}

func createAppSet(o *createAppSetOptions) ([]byte, error) {
Expand All @@ -199,10 +198,10 @@ func createAppSet(o *createAppSetOptions) ([]byte, error) {
}
}

appSet := &appset.ApplicationSet{
appSet := &argocdv1alpha1.ApplicationSet{
TypeMeta: metav1.TypeMeta{
Kind: "ApplicationSet",
APIVersion: appset.GroupVersion.String(),
Kind: argocdv1alpha1.ApplicationSetSchemaGroupVersionKind.Kind,
APIVersion: argocdv1alpha1.ApplicationSetSchemaGroupVersionKind.GroupVersion().String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: o.name,
Expand All @@ -211,10 +210,10 @@ func createAppSet(o *createAppSetOptions) ([]byte, error) {
"argocd.argoproj.io/sync-wave": "0",
},
},
Spec: appset.ApplicationSetSpec{
Spec: argocdv1alpha1.ApplicationSetSpec{
Generators: o.generators,
Template: appset.ApplicationSetTemplate{
ApplicationSetTemplateMeta: appset.ApplicationSetTemplateMeta{
Template: argocdv1alpha1.ApplicationSetTemplate{
ApplicationSetTemplateMeta: argocdv1alpha1.ApplicationSetTemplateMeta{
Namespace: o.appNamespace,
Name: o.appName,
Labels: o.appLabels,
Expand Down Expand Up @@ -249,7 +248,7 @@ func createAppSet(o *createAppSetOptions) ([]byte, error) {
},
},
},
SyncPolicy: &appset.ApplicationSetSyncPolicy{
SyncPolicy: &argocdv1alpha1.ApplicationSetSyncPolicy{
PreserveResourcesOnDeletion: o.preserveResourcesOnDeletion,
},
},
Expand Down
17 changes: 8 additions & 9 deletions cmd/commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/argoproj-labs/argocd-autopilot/pkg/store"
"github.com/argoproj-labs/argocd-autopilot/pkg/util"

appset "github.com/argoproj/applicationset/api/v1alpha1"
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/ghodss/yaml"
"github.com/go-git/go-billy/v5/memfs"
Expand Down Expand Up @@ -300,12 +299,12 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
preserveResourcesOnDeletion: false,
appLabels: getDefaultAppLabels(o.Labels),
appAnnotations: o.Annotations,
generators: []appset.ApplicationSetGenerator{
generators: []argocdv1alpha1.ApplicationSetGenerator{
{
Git: &appset.GitGenerator{
Git: &argocdv1alpha1.GitGenerator{
RepoURL: o.RepoURL,
Revision: o.Revision,
Files: []appset.GitFileGeneratorItem{
Files: []argocdv1alpha1.GitFileGeneratorItem{
{
Path: filepath.Join(o.InstallationPath, store.Default.AppsDir, "**", o.Name, "config.json"),
},
Expand All @@ -314,16 +313,16 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
},
},
{
Git: &appset.GitGenerator{
Git: &argocdv1alpha1.GitGenerator{
RepoURL: o.RepoURL,
Revision: o.Revision,
Files: []appset.GitFileGeneratorItem{
Files: []argocdv1alpha1.GitFileGeneratorItem{
{
Path: filepath.Join(o.InstallationPath, store.Default.AppsDir, "**", o.Name, "config_dir.json"),
},
},
RequeueAfterSeconds: &DefaultApplicationSetGeneratorInterval,
Template: appset.ApplicationSetTemplate{
Template: argocdv1alpha1.ApplicationSetTemplate{
Spec: argocdv1alpha1.ApplicationSpec{
Source: argocdv1alpha1.ApplicationSource{
Directory: &argocdv1alpha1.ApplicationSourceDirectory{
Expand Down Expand Up @@ -432,9 +431,9 @@ func RunProjectList(ctx context.Context, opts *ProjectListOptions) error {
return nil
}

var getProjectInfoFromFile = func(repofs fs.FS, name string) (*argocdv1alpha1.AppProject, *appset.ApplicationSet, error) {
var getProjectInfoFromFile = func(repofs fs.FS, name string) (*argocdv1alpha1.AppProject, *argocdv1alpha1.ApplicationSet, error) {
proj := &argocdv1alpha1.AppProject{}
appSet := &appset.ApplicationSet{}
appSet := &argocdv1alpha1.ApplicationSet{}
if err := repofs.ReadYamls(name, proj, appSet); err != nil {
return nil, nil, err
}
Expand Down
9 changes: 4 additions & 5 deletions cmd/commands/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/argoproj-labs/argocd-autopilot/pkg/store"
"github.com/argoproj-labs/argocd-autopilot/pkg/util"

appset "github.com/argoproj/applicationset/api/v1alpha1"
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/ghodss/yaml"
"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -204,7 +203,7 @@ func Test_generateProjectManifests(t *testing.T) {
t.Run(ttname, func(t *testing.T) {
assert := assert.New(t)
gotProject := &argocdv1alpha1.AppProject{}
gotAppSet := &appset.ApplicationSet{}
gotAppSet := &argocdv1alpha1.ApplicationSet{}
gotClusterResConf := &application.ClusterResConfig{}
gotProjectYAML, gotAppSetYAML, _, gotClusterResConfigYAML, _ := generateProjectManifests(tt.o)
assert.NoError(yaml.Unmarshal(gotProjectYAML, gotProject))
Expand Down Expand Up @@ -324,7 +323,7 @@ func Test_getProjectInfoFromFile(t *testing.T) {
Namespace: "ns",
},
}
appSet := appset.ApplicationSet{}
appSet := argocdv1alpha1.ApplicationSet{}
_ = repofs.WriteYamls("prod.yaml", appProj, appSet)
},
want: &argocdv1alpha1.AppProject{
Expand Down Expand Up @@ -360,7 +359,7 @@ func TestRunProjectList(t *testing.T) {
opts *ProjectListOptions
wantErr string
prepareRepo func(ctx context.Context, cloneOpts *git.CloneOptions, projectName string) (git.Repository, fs.FS, error)
getProjectInfoFromFile func(repofs fs.FS, name string) (*argocdv1alpha1.AppProject, *appset.ApplicationSet, error)
getProjectInfoFromFile func(repofs fs.FS, name string) (*argocdv1alpha1.AppProject, *argocdv1alpha1.ApplicationSet, error)
assertFn func(t *testing.T, out io.Writer)
}{
"should print to table": {
Expand All @@ -373,7 +372,7 @@ func TestRunProjectList(t *testing.T) {
_ = billyUtils.WriteFile(memfs, "projects/prod.yaml", []byte{}, 0666)
return nil, fs.Create(memfs), nil
},
getProjectInfoFromFile: func(_ fs.FS, _ string) (*argocdv1alpha1.AppProject, *appset.ApplicationSet, error) {
getProjectInfoFromFile: func(_ fs.FS, _ string) (*argocdv1alpha1.AppProject, *argocdv1alpha1.ApplicationSet, error) {
appProj := &argocdv1alpha1.AppProject{
ObjectMeta: v1.ObjectMeta{
Name: "prod",
Expand Down
8 changes: 4 additions & 4 deletions cmd/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/argoproj-labs/argocd-autopilot/pkg/store"
"github.com/argoproj-labs/argocd-autopilot/pkg/util"

appset "github.com/argoproj/applicationset/api/v1alpha1"
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
argocdcommon "github.com/argoproj/argo-cd/v2/common"
argocdsettings "github.com/argoproj/argo-cd/v2/util/settings"
"github.com/ghodss/yaml"
Expand Down Expand Up @@ -595,12 +595,12 @@ func buildBootstrapManifests(namespace, appSpecifier string, cloneOpts *git.Clon
prune: false,
preserveResourcesOnDeletion: true,
srcPath: filepath.Join(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ClusterResourcesDir, "{{name}}"),
generators: []appset.ApplicationSetGenerator{
generators: []argocdv1alpha1.ApplicationSetGenerator{
{
Git: &appset.GitGenerator{
Git: &argocdv1alpha1.GitGenerator{
RepoURL: cloneOpts.URL(),
Revision: cloneOpts.Revision(),
Files: []appset.GitFileGeneratorItem{
Files: []argocdv1alpha1.GitFileGeneratorItem{
{
Path: filepath.Join(
cloneOpts.Path(),
Expand Down
113 changes: 59 additions & 54 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module github.com/argoproj-labs/argocd-autopilot

go 1.17
go 1.19

require (
code.gitea.io/sdk/gitea v0.15.1
github.com/argoproj/applicationset v0.4.1
github.com/argoproj/argo-cd/v2 v2.4.6
github.com/argoproj/gitops-engine v0.7.0
github.com/argoproj/argo-cd/v2 v2.5.2
github.com/argoproj/gitops-engine v0.7.1-0.20221004132320-98ccd3d43fd9
github.com/briandowns/spinner v1.18.1
github.com/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.3.1
Expand All @@ -16,16 +15,16 @@ require (
github.com/ktrysmt/go-bitbucket v0.9.49
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.10.1
github.com/stretchr/testify v1.8.0
github.com/xanzy/go-gitlab v0.71.0
k8s.io/api v0.23.3
k8s.io/apimachinery v0.23.3
k8s.io/cli-runtime v0.23.1
k8s.io/client-go v0.23.3
k8s.io/kubectl v0.23.1
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/cli-runtime v0.24.2
k8s.io/client-go v0.24.2
k8s.io/kubectl v0.24.2
sigs.k8s.io/kustomize/api v0.11.4
sigs.k8s.io/kustomize/kyaml v0.13.6
)
Expand Down Expand Up @@ -56,7 +55,7 @@ require (
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/alicebob/miniredis/v2 v2.14.2 // indirect
github.com/antonmedv/expr v1.8.9 // indirect
github.com/argoproj/notifications-engine v0.3.1-0.20220430155844-567361917320 // indirect
github.com/argoproj/notifications-engine v0.3.1-0.20220812180936-4d8552b0775f // indirect
github.com/argoproj/pkg v0.11.1-0.20211203175135-36c59d8fafe0 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -66,12 +65,12 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 // indirect
github.com/coreos/go-oidc v2.2.1+incompatible // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
Expand Down Expand Up @@ -105,14 +104,14 @@ require (
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-github/v41 v41.0.0 // indirect
github.com/google/go-jsonnet v0.18.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gregdel/pushover v1.1.0 // indirect
Expand Down Expand Up @@ -149,10 +148,11 @@ require (
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.0.0-20210610120745-9d4ed1856297 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opsgenie/opsgenie-go-sdk-v2 v1.0.5 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
Expand All @@ -161,10 +161,10 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.28.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/r3labs/diff v1.1.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rs/cors v1.8.0 // indirect
Expand All @@ -178,6 +178,8 @@ require (
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
github.com/vmihailenco/go-tinylfu v0.2.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand Down Expand Up @@ -214,18 +216,18 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.23.1 // indirect
k8s.io/apiserver v0.23.1 // indirect
k8s.io/component-base v0.23.1 // indirect
k8s.io/component-helpers v0.23.1 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-aggregator v0.23.1 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/kubernetes v1.23.1 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
k8s.io/apiextensions-apiserver v0.24.2 // indirect
k8s.io/apiserver v0.24.2 // indirect
k8s.io/component-base v0.24.2 // indirect
k8s.io/component-helpers v0.24.2 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
k8s.io/kube-aggregator v0.24.2 // indirect
k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 // indirect
k8s.io/kubernetes v1.24.2 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
layeh.com/gopher-json v0.0.0-20190114024228-97fed8db8427 // indirect
sigs.k8s.io/controller-runtime v0.11.0 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Expand All @@ -239,30 +241,33 @@ replace (
github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/improbable-eng/grpc-web => github.com/improbable-eng/grpc-web v0.0.0-20181111100011-16092bd1d58a

// Avoid CVE-2022-28948
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1

// https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-505627280
k8s.io/api => k8s.io/api v0.23.1
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.23.1
k8s.io/apimachinery => k8s.io/apimachinery v0.23.1
k8s.io/apiserver => k8s.io/apiserver v0.23.1
k8s.io/cli-runtime => k8s.io/cli-runtime v0.23.1
k8s.io/client-go => k8s.io/client-go v0.23.1
k8s.io/cloud-provider => k8s.io/cloud-provider v0.23.1
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.23.1
k8s.io/code-generator => k8s.io/code-generator v0.23.1
k8s.io/component-base => k8s.io/component-base v0.23.1
k8s.io/component-helpers => k8s.io/component-helpers v0.23.1
k8s.io/controller-manager => k8s.io/controller-manager v0.23.1
k8s.io/cri-api => k8s.io/cri-api v0.23.1
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.23.1
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.23.1
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.23.1
k8s.io/kube-proxy => k8s.io/kube-proxy v0.23.1
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.23.1
k8s.io/kubectl => k8s.io/kubectl v0.23.1
k8s.io/kubelet => k8s.io/kubelet v0.23.1
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.23.1
k8s.io/metrics => k8s.io/metrics v0.23.1
k8s.io/mount-utils => k8s.io/mount-utils v0.23.1
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.23.1
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.23.1
k8s.io/api => k8s.io/api v0.24.2
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.2
k8s.io/apimachinery => k8s.io/apimachinery v0.24.2
k8s.io/apiserver => k8s.io/apiserver v0.24.2
k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.2
k8s.io/client-go => k8s.io/client-go v0.24.2
k8s.io/cloud-provider => k8s.io/cloud-provider v0.24.2
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.24.2
k8s.io/code-generator => k8s.io/code-generator v0.24.2
k8s.io/component-base => k8s.io/component-base v0.24.2
k8s.io/component-helpers => k8s.io/component-helpers v0.24.2
k8s.io/controller-manager => k8s.io/controller-manager v0.24.2
k8s.io/cri-api => k8s.io/cri-api v0.24.2
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.24.2
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.24.2
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.24.2
k8s.io/kube-proxy => k8s.io/kube-proxy v0.24.2
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.24.2
k8s.io/kubectl => k8s.io/kubectl v0.24.2
k8s.io/kubelet => k8s.io/kubelet v0.24.2
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.24.2
k8s.io/metrics => k8s.io/metrics v0.24.2
k8s.io/mount-utils => k8s.io/mount-utils v0.24.2
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.24.2
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.2
)
Loading

0 comments on commit 559c773

Please sign in to comment.