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

WIP: Add support for Kustomize Patches #210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 39 additions & 0 deletions apis/applications/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,18 @@ type ApplicationSourceKustomize struct {
CommonAnnotationsEnvsubst *bool `json:"commonAnnotationsEnvsubst,omitempty" protobuf:"bytes,10,opt,name=commonAnnotationsEnvsubst"`
// Replicas is a list of Kustomize Replicas override specifications
Replicas KustomizeReplicas `json:"replicas,omitempty" protobuf:"bytes,11,opt,name=replicas"`
// Patches is a list of Kustomize patches
Patches KustomizePatches `json:"patches,omitempty" protobuf:"bytes,12,opt,name=patches"`
// Components specifies a list of kustomize components to add to the kustomization before building
Components []string `json:"components,omitempty" protobuf:"bytes,13,rep,name=components"`
// LabelWithoutSelector specifies whether to apply common labels to resource selectors or not
LabelWithoutSelector bool `json:"labelWithoutSelector,omitempty" protobuf:"bytes,14,opt,name=labelWithoutSelector"`
// KubeVersion specifies the Kubernetes API version to pass to Helm when templating manifests. By default, Argo CD
// uses the Kubernetes version of the target cluster.
// KubeVersion string `json:"kubeVersion,omitempty" protobuf:"bytes,15,opt,name=kubeVersion"`
// APIVersions specifies the Kubernetes resource API versions to pass to Helm when templating manifests. By default,
// Argo CD uses the API versions of the target cluster. The format is [group/]version/kind.
// APIVersions []string `json:"apiVersions,omitempty" protobuf:"bytes,16,opt,name=apiVersions"`
}

// KustomizeReplica override specifications
Expand All @@ -274,6 +286,33 @@ type Info struct {
Value string `json:"value" protobuf:"bytes,2,name=value"`
}

type KustomizePatches []KustomizePatch

type KustomizePatch struct {
Path string `json:"path,omitempty" yaml:"path,omitempty" protobuf:"bytes,1,opt,name=path"`
Patch string `json:"patch,omitempty" yaml:"patch,omitempty" protobuf:"bytes,2,opt,name=patch"`
Target *KustomizeSelector `json:"target,omitempty" yaml:"target,omitempty" protobuf:"bytes,3,opt,name=target"`
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty" protobuf:"bytes,4,opt,name=options"`
}

type KustomizeSelector struct {
KustomizeResId `json:",inline,omitempty" yaml:",inline,omitempty" protobuf:"bytes,1,opt,name=resId"`
AnnotationSelector string `json:"annotationSelector,omitempty" yaml:"annotationSelector,omitempty" protobuf:"bytes,2,opt,name=annotationSelector"`
LabelSelector string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty" protobuf:"bytes,3,opt,name=labelSelector"`
}

type KustomizeResId struct {
KustomizeGvk `json:",inline,omitempty" yaml:",inline,omitempty" protobuf:"bytes,1,opt,name=gvk"`
Name string `json:"name,omitempty" yaml:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`
}

type KustomizeGvk struct {
Group string `json:"group,omitempty" yaml:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
Version string `json:"version,omitempty" yaml:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"`
}

// SyncOptions provide per-sync sync-options, e.g. Validate=false
type SyncOptions []string

Expand Down
107 changes: 107 additions & 0 deletions apis/applications/v1alpha1/zz_generated.deepcopy.go

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

38 changes: 38 additions & 0 deletions apis/applicationsets/v1alpha1/application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ type ApplicationSourceKustomize struct {
CommonAnnotationsEnvsubst *bool `json:"commonAnnotationsEnvsubst,omitempty" protobuf:"bytes,10,opt,name=commonAnnotationsEnvsubst"`
// Replicas is a list of Kustomize Replicas override specifications
Replicas KustomizeReplicas `json:"replicas,omitempty" protobuf:"bytes,11,opt,name=replicas"`
// Patches is a list of Kustomize patches
Patches KustomizePatches `json:"patches,omitempty" protobuf:"bytes,12,opt,name=patches"`
// Components specifies a list of kustomize components to add to the kustomization before building
Components []string `json:"components,omitempty" protobuf:"bytes,13,rep,name=components"`
// LabelWithoutSelector specifies whether to apply common labels to resource selectors or not
LabelWithoutSelector bool `json:"labelWithoutSelector,omitempty" protobuf:"bytes,14,opt,name=labelWithoutSelector"`
// KubeVersion specifies the Kubernetes API version to pass to Helm when templating manifests. By default, Argo CD
// uses the Kubernetes version of the target cluster.
//KubeVersion string `json:"kubeVersion,omitempty" protobuf:"bytes,15,opt,name=kubeVersion"`
// APIVersions specifies the Kubernetes resource API versions to pass to Helm when templating manifests. By default,
// Argo CD uses the API versions of the target cluster. The format is [group/]version/kind.
//APIVersions []string `json:"apiVersions,omitempty" protobuf:"bytes,16,opt,name=apiVersions"`
}

// KustomizeReplica override specifications
Expand All @@ -227,6 +239,32 @@ type Info struct {
Name string `json:"name" protobuf:"bytes,1,name=name"`
Value string `json:"value" protobuf:"bytes,2,name=value"`
}
type KustomizePatches []KustomizePatch

type KustomizePatch struct {
Path string `json:"path,omitempty" yaml:"path,omitempty" protobuf:"bytes,1,opt,name=path"`
Patch string `json:"patch,omitempty" yaml:"patch,omitempty" protobuf:"bytes,2,opt,name=patch"`
Target *KustomizeSelector `json:"target,omitempty" yaml:"target,omitempty" protobuf:"bytes,3,opt,name=target"`
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty" protobuf:"bytes,4,opt,name=options"`
}

type KustomizeSelector struct {
KustomizeResId `json:",inline,omitempty" yaml:",inline,omitempty" protobuf:"bytes,1,opt,name=resId"`
AnnotationSelector string `json:"annotationSelector,omitempty" yaml:"annotationSelector,omitempty" protobuf:"bytes,2,opt,name=annotationSelector"`
LabelSelector string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty" protobuf:"bytes,3,opt,name=labelSelector"`
}

type KustomizeResId struct {
KustomizeGvk `json:",inline,omitempty" yaml:",inline,omitempty" protobuf:"bytes,1,opt,name=gvk"`
Name string `json:"name,omitempty" yaml:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`
}

type KustomizeGvk struct {
Group string `json:"group,omitempty" yaml:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
Version string `json:"version,omitempty" yaml:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"`
}

// SyncOptions provide per-sync sync-options, e.g. Validate=false
type SyncOptions []string
Expand Down
46 changes: 45 additions & 1 deletion apis/applicationsets/v1alpha1/status.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
import (
"github.com/argoproj/gitops-engine/pkg/health"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ArgoApplicationSetStatus are the observable fields of a ApplicationSet.
type ArgoApplicationSetStatus struct {
Conditions []ApplicationSetCondition `json:"conditions,omitempty" protobuf:"bytes,1,name=conditions"`
ApplicationStatus []ApplicationSetApplicationStatus `json:"applicationStatus,omitempty" protobuf:"bytes,2,name=applicationStatus"`
// Resources is a list of Applications resources managed by this application set.
Resources []ResourceStatus `json:"resources,omitempty" protobuf:"bytes,3,opt,name=resources"`
}

// ResourceStatus holds the current sync and health status of a resource
// TODO: describe members of this type
type ResourceStatus struct {
Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
Kind string `json:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"`
Namespace string `json:"namespace,omitempty" protobuf:"bytes,4,opt,name=namespace"`
Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"`
Status SyncStatusCode `json:"status,omitempty" protobuf:"bytes,6,opt,name=status"`
Health *HealthStatus `json:"health,omitempty" protobuf:"bytes,7,opt,name=health"`
Hook bool `json:"hook,omitempty" protobuf:"bytes,8,opt,name=hook"`
RequiresPruning bool `json:"requiresPruning,omitempty" protobuf:"bytes,9,opt,name=requiresPruning"`
SyncWave int64 `json:"syncWave,omitempty" protobuf:"bytes,10,opt,name=syncWave"`
//RequiresDeletionConfirmation bool `json:"requiresDeletionConfirmation,omitempty" protobuf:"bytes,11,opt,name=requiresDeletionConfirmation"`
}

// SyncStatusCode is a type which represents possible comparison results
type SyncStatusCode string

// Possible comparison results
const (
// SyncStatusCodeUnknown indicates that the status of a sync could not be reliably determined
SyncStatusCodeUnknown SyncStatusCode = "Unknown"
// SyncStatusCodeSynced indicates that desired and live states match
SyncStatusCodeSynced SyncStatusCode = "Synced"
// SyncStatusCodeOutOfSync indicates that there is a drift between desired and live states
SyncStatusCodeOutOfSync SyncStatusCode = "OutOfSync"
)

// HealthStatus contains information about the currently observed health state of an application or resource
type HealthStatus struct {
// Status holds the status code of the application or resource
Status health.HealthStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
// Message is a human-readable informational message describing the health status
Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

// ApplicationSetCondition contains details about an applicationset condition, which is usually an error or warning
Expand Down Expand Up @@ -34,6 +76,8 @@ type ApplicationSetApplicationStatus struct {
Status string `json:"status" protobuf:"bytes,4,opt,name=status"`
// Step tracks which step this Application should be updated in
Step string `json:"step" protobuf:"bytes,5,opt,name=step"`
// TargetRevision tracks the desired revisions the Application should be synced to.
TargetRevisions []string `json:"targetRevisions" protobuf:"bytes,6,opt,name=targetrevisions"`
}

// ApplicationSetConditionStatus is a type which represents possible comparison results
Expand Down
32 changes: 31 additions & 1 deletion apis/applicationsets/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ type ApplicationSetParameters struct {
PreservedFields *ApplicationPreservedFields `json:"preservedFields,omitempty" protobuf:"bytes,6,opt,name=preservedFields"`
GoTemplateOptions []string `json:"goTemplateOptions,omitempty" protobuf:"bytes,7,opt,name=goTemplateOptions"`
// ApplyNestedSelectors enables selectors defined within the generators of two level-nested matrix or merge generators
ApplyNestedSelectors bool `json:"applyNestedSelectors,omitempty" protobuf:"bytes,8,name=applyNestedSelectors"`
ApplyNestedSelectors bool `json:"applyNestedSelectors,omitempty" protobuf:"bytes,8,name=applyNestedSelectors"`
IgnoreApplicationDifferences ApplicationSetIgnoreDifferences `json:"ignoreApplicationDifferences,omitempty" protobuf:"bytes,9,name=ignoreApplicationDifferences"`
TemplatePatch *string `json:"templatePatch,omitempty" protobuf:"bytes,10,name=templatePatch"`
}

// ApplicationPreservedFields ApplicationSetObservation are the preseverable fields on an Application
type ApplicationPreservedFields struct {
Annotations []string `json:"annotations,omitempty" protobuf:"bytes,1,name=annotations"`
Labels []string `json:"labels,omitempty" protobuf:"bytes,2,name=labels"`
}

// ApplicationSetStrategy configures how generated Applications are updated in sequence.
Expand Down Expand Up @@ -97,6 +100,21 @@ type ApplicationSetSyncPolicy struct {
ApplicationsSync *ApplicationsSyncPolicy `json:"applicationsSync,omitempty" protobuf:"bytes,2,opt,name=applicationsSync,casttype=ApplicationsSyncPolicy"`
}

// ApplicationSetIgnoreDifferences configures how the ApplicationSet controller will ignore differences in live
// applications when applying changes from generated applications.
type ApplicationSetIgnoreDifferences []ApplicationSetResourceIgnoreDifferences

// ApplicationSetResourceIgnoreDifferences configures how the ApplicationSet controller will ignore differences in live
// applications when applying changes from generated applications.
type ApplicationSetResourceIgnoreDifferences struct {
// Name is the name of the application to ignore differences for. If not specified, the rule applies to all applications.
Name string `json:"name,omitempty" protobuf:"bytes,1,name=name"`
// JSONPointers is a list of JSON pointers to fields to ignore differences for.
JSONPointers []string `json:"jsonPointers,omitempty" protobuf:"bytes,2,name=jsonPointers"`
// JQPathExpressions is a list of JQ path expressions to fields to ignore differences for.
JQPathExpressions []string `json:"jqPathExpressions,omitempty" protobuf:"bytes,3,name=jqExpressions"`
}

// ApplicationsSyncPolicy representation
// "create-only" means applications are only created. If the generator's result contains update, applications won't be updated
// "create-update" means applications are only created/Updated. If the generator's result contains update, applications will be updated, but not deleted
Expand Down Expand Up @@ -309,6 +327,12 @@ type SCMProviderGeneratorGitlab struct {
AllBranches bool `json:"allBranches,omitempty" protobuf:"varint,5,opt,name=allBranches"`
// Skips validating the SCM provider's TLS certificate - useful for self-signed certificates.; default: false
Insecure bool `json:"insecure,omitempty" protobuf:"varint,6,opt,name=insecure"`
// When recursing through subgroups, also include shared Projects (true) or scan only the subgroups under same path (false). Defaults to "true"
IncludeSharedProjects *bool `json:"includeSharedProjects,omitempty" protobuf:"varint,7,opt,name=includeSharedProjects"`
// Filter repos list based on Gitlab Topic.
Topic string `json:"topic,omitempty" protobuf:"bytes,8,opt,name=topic"`
// ConfigMap key holding the trusted certificates
// CARef *ConfigMapKeyRef `json:"caRef,omitempty" protobuf:"bytes,9,opt,name=caRef"`
}

// SCMProviderGeneratorBitbucket defines connection info specific to Bitbucket Cloud (API version 2).
Expand Down Expand Up @@ -518,6 +542,12 @@ type SecretRef struct {
Key string `json:"key" protobuf:"bytes,2,opt,name=key"`
}

// Utility struct for a reference to a configmap key.
type ConfigMapKeyRef struct {
ConfigMapName string `json:"configMapName" protobuf:"bytes,1,opt,name=configMapName"`
Key string `json:"key" protobuf:"bytes,2,opt,name=key"`
}

// PluginConfigMapRef defines a reference to a ConfigMap containing a plugin.
type PluginConfigMapRef struct {
// Name of the ConfigMap
Expand Down
Loading
Loading