Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Add item list CRD Spec #1

Merged
merged 5 commits into from
Jun 12, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin
vendor

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build the binary
FROM golang:1.14.1 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY . .

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o applicationset-controller main.go

# Use distroless as minimal base image to package the manager binary
FROM debian:10-slim
WORKDIR /
COPY --from=builder /workspace/applicationset-controller /usr/local/bin/
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
VERSION?=$(shell cat VERSION)
IMAGE_TAG?=v$(VERSION)
IMAGE_PREFIX?=argoprojlabs
DOCKER_PUSH?=true

.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags="-w -s" -o ./dist/argocd-aplicationset .

.PHONY: image
image:
docker build -t $(IMAGE_PREFIX)/argocd-aplicationset:$(IMAGE_TAG) .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)/argocd-aplicationset:$(IMAGE_TAG) ; fi

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests:
controller-gen paths=./api/... crd:trivialVersions=true output:dir=./manifests/crds/
controller-gen object paths=./api/...

# Run go fmt against code
fmt:
go fmt ./...

# Run go vet against code
vet:
go vet ./...
6 changes: 6 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repo: github.com/argoproj-labs/applicationset
resources:
- group: argoproj.io
kind: ApplicationSet
version: v1alpha1
version: "1"
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
73 changes: 73 additions & 0 deletions api/v1alpha1/applicationset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package v1alpha1

import (
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ApplicationSet is a set of Application resources
// +kubebuilder:object:root=true
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ApplicationSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec ApplicationSetSpec `json:"spec"`
}

// ApplicationSetSpec represents a class of application set state.
type ApplicationSetSpec struct {
Generators []ApplicationSetGenerator `json:"generators"`
Template ApplicationSetTemplate `json:"template"`
SyncPolicy *ApplicationSetSyncPolicy `json:"syncPolicy,omitempty"`
}

// ApplicationSetSyncPolicy will provide a syncPolicy similar to Applications
type ApplicationSetSyncPolicy struct {
// Automated will keep an application synced to the target revision
Automated *SyncPolicyAutomated `json:"automated,omitempty"`
}

// SyncPolicyAutomated
type SyncPolicyAutomated struct {
// Prune will prune resources automatically as part of automated sync (default: false)
Prune bool `json:"prune,omitempty"`
// Initial will perform an initial sync for any newly created Applications which do not have automated sync turned on.
Initial bool `json:"initial,omitempty"`
}

// ApplicationSetTemplate represents argocd ApplicationSpec
type ApplicationSetTemplate struct {
metav1.ObjectMeta `json:"metadata"`
Spec v1alpha1.ApplicationSpec `json:"spec"`
}

// ApplicationSetGenerator include list item info
type ApplicationSetGenerator struct {
List *ListGenerator `json:"list, omitempty"`
}

// ListGenerator include items info
type ListGenerator struct {
Items []ListGeneratorItem `json:"items"`
}

// ListGeneratorItem include cluster and url info
type ListGeneratorItem struct {
Cluster string `json:"cluster"`
Url string `json:"url"`
}

// +kubebuilder:object:root=true

// ApplicationSetList contains a list of ApplicationSet
type ApplicationSetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ApplicationSet `json:"items"`
}

func init() {
SchemeBuilder.Register(&ApplicationSet{}, &ApplicationSetList{})
}
20 changes: 20 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Package v1alpha1 contains API Schema definitions for the argoproj.io v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=argoproj.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "argoproj.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
202 changes: 202 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
url: https://9.8.7.6
template:
metadata:
name: '{{name}}-guestbook'
name: '{{cluster}}-guestbook'
spec:
source:
repoURL: https://github.com/infra-team/cluster-deployments.git
Expand Down