-
Notifications
You must be signed in to change notification settings - Fork 277
Add item list CRD Spec #1
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
*~ |
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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
VERSION?=$(shell cat VERSION) | ||
IMAGE_TAG?=v$(VERSION) | ||
IMAGE_PREFIX?=registry.cn-hangzhou.aliyuncs.com/appcenter | ||
DOCKER_PUSH?=true | ||
|
||
.PHONY: build | ||
build: | ||
CGO_ENABLED=0 go build -ldflags="-w -s" -o ./dist/argocd-aplicationset . | ||
|
||
.PHONY: image | ||
image: | ||
docker build -t registry.cn-hangzhou.aliyuncs.com/appcenter/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 ./... |
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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
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 ApplicationSetGenerators `json:"generators"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per spec, it should be an array of ApplicationSetGenerator: spec:
generators:
- clusters: {} Generators []ApplicationSetGenerator `json:"generators"` |
||
Template ApplicationSetTemplate `json:"template"` | ||
Operation *v1alpha1.SyncOperation `json:"operation,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the
So with the above, I think we should leave out operation, until we think about how we want to do operations (if at all). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree |
||
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"` | ||
InitialSync bool `json:"initialSync,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking the word spec:
syncPolicy:
automated:
prune: true
initial: true Let's also comment this to explain what this option is for:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
|
||
// ApplicationSetTemplate represents argocd ApplicationSpec | ||
type ApplicationSetTemplate struct { | ||
metav1.ObjectMeta `json:"metadata"` | ||
TemplateSpec v1alpha1.ApplicationSpec `json:"spec"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the field name needs to be named |
||
} | ||
|
||
// ApplicationSetGenerators include list item info | ||
type ApplicationSetGenerators struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should remove type ApplicationSetGenerator struct {
List *ListGenerator `json:"list, omitempty"`
} Also, we should remove s from |
||
List GeneratorsList `json:"list, omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels like this should be *GeneratorsList as it is optional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
} | ||
|
||
// GeneratorsList include items info | ||
type GeneratorsList struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GeneratorsList implies this is a list of all generators, what do you think about ListGenerator to more clearly indicate what this is? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree |
||
Items GeneratorsItems `json:"items"` | ||
} | ||
|
||
// GeneratorsItems include cluster and url info | ||
type GeneratorsItems struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest ListGeneratorItem |
||
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{}) | ||
} |
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 | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make the registry configurable as well, $IMAGE perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Can make it such that it builds a local image (without a registry), but will prepend
IMAGE_PREFIX
if it is defined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done