Introduce kustomization API
This commit is contained in:
parent
3df6bfebfa
commit
a3d9a8876a
|
@ -56,9 +56,15 @@ const (
|
|||
// InitializingReason represents the fact that a given kustomization is being initialized.
|
||||
InitializingReason string = "Initializing"
|
||||
|
||||
// ApplySucceedReason represents the fact that the kustomization apply succeed.
|
||||
ApplySucceedReason string = "ApplySucceed"
|
||||
|
||||
// ApplyFailedReason represents the fact that the kustomization apply failed.
|
||||
ApplyFailedReason string = "ApplyFailed"
|
||||
|
||||
// BuildFailedReason represents the fact that the kustomize build command failed.
|
||||
BuildFailedReason string = "BuildFailed"
|
||||
|
||||
// ArtifactFailedReason represents the fact that the artifact download failed.
|
||||
ArtifactFailedReason string = "ArtifactFailed"
|
||||
)
|
||||
|
|
|
@ -21,31 +21,75 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// KustomizationSpec defines the desired state of a kustomization
|
||||
// KustomizationSpec defines the desired state of a kustomization.
|
||||
type KustomizationSpec struct {
|
||||
// Path to a source directory where the kustomization file is.
|
||||
// Path to the directory containing the kustomization file.
|
||||
// +kubebuilder:validation:Pattern="^\\./"
|
||||
// +required
|
||||
Path string `json:"path"`
|
||||
|
||||
// Label used for prune operations.
|
||||
// Label selector used for prune operations, e.g. env=staging.
|
||||
// +kubebuilder:validation:Pattern="^.*=.*$"
|
||||
// +optional
|
||||
Label string `json:"label,omitempty"`
|
||||
Prune string `json:"prune,omitempty"`
|
||||
|
||||
// Reference of the GitRepository where the kustomization source is.
|
||||
// Reference of the Git repository where the kustomization source is.
|
||||
// +required
|
||||
GitRepositoryRef corev1.LocalObjectReference `json:"gitRepositoryRef"`
|
||||
|
||||
// The interval at which to apply the kustomization.
|
||||
// +required
|
||||
Interval metav1.Duration `json:"interval"`
|
||||
}
|
||||
|
||||
// KustomizationStatus defines the observed state of a kustomization
|
||||
// KustomizationStatus defines the observed state of a kustomization.
|
||||
type KustomizationStatus struct {
|
||||
// +optional
|
||||
Conditions []Condition `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
func KustomizationReady(kustomization Kustomization, reason, message string) Kustomization {
|
||||
kustomization.Status.Conditions = []Condition{
|
||||
{
|
||||
Type: ReadyCondition,
|
||||
Status: corev1.ConditionTrue,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
},
|
||||
}
|
||||
return kustomization
|
||||
}
|
||||
|
||||
// Kustomization is the Schema for the kustomizations API
|
||||
func KustomizationNotReady(kustomization Kustomization, reason, message string) Kustomization {
|
||||
kustomization.Status.Conditions = []Condition{
|
||||
{
|
||||
Type: ReadyCondition,
|
||||
Status: corev1.ConditionFalse,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
Reason: reason,
|
||||
Message: message,
|
||||
},
|
||||
}
|
||||
return kustomization
|
||||
}
|
||||
|
||||
func KustomizationReadyMessage(kustomization Kustomization) string {
|
||||
for _, condition := range kustomization.Status.Conditions {
|
||||
if condition.Type == ReadyCondition {
|
||||
return condition.Message
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
|
||||
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
|
||||
|
||||
// Kustomization is the Schema for the kustomizations API.
|
||||
type Kustomization struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
@ -56,7 +100,7 @@ type Kustomization struct {
|
|||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// KustomizationList contains a list of Kustomization
|
||||
// KustomizationList contains a list of kustomizations.
|
||||
type KustomizationList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
|
|
@ -103,6 +103,7 @@ func (in *KustomizationList) DeepCopyObject() runtime.Object {
|
|||
func (in *KustomizationSpec) DeepCopyInto(out *KustomizationSpec) {
|
||||
*out = *in
|
||||
out.GitRepositoryRef = in.GitRepositoryRef
|
||||
out.Interval = in.Interval
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KustomizationSpec.
|
||||
|
|
|
@ -8,6 +8,16 @@ metadata:
|
|||
creationTimestamp: null
|
||||
name: kustomizations.kustomize.fluxcd.io
|
||||
spec:
|
||||
additionalPrinterColumns:
|
||||
- JSONPath: .status.conditions[?(@.type=="Ready")].status
|
||||
name: Ready
|
||||
type: string
|
||||
- JSONPath: .status.conditions[?(@.type=="Ready")].message
|
||||
name: Status
|
||||
type: string
|
||||
- JSONPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
group: kustomize.fluxcd.io
|
||||
names:
|
||||
kind: Kustomization
|
||||
|
@ -15,9 +25,11 @@ spec:
|
|||
plural: kustomizations
|
||||
singular: kustomization
|
||||
scope: Namespaced
|
||||
subresources:
|
||||
status: {}
|
||||
validation:
|
||||
openAPIV3Schema:
|
||||
description: Kustomization is the Schema for the kustomizations API
|
||||
description: Kustomization is the Schema for the kustomizations API.
|
||||
properties:
|
||||
apiVersion:
|
||||
description: 'APIVersion defines the versioned schema of this representation
|
||||
|
@ -32,10 +44,10 @@ spec:
|
|||
metadata:
|
||||
type: object
|
||||
spec:
|
||||
description: KustomizationSpec defines the desired state of a kustomization
|
||||
description: KustomizationSpec defines the desired state of a kustomization.
|
||||
properties:
|
||||
gitRepositoryRef:
|
||||
description: Reference of the GitRepository where the kustomization
|
||||
description: Reference of the Git repository where the kustomization
|
||||
source is.
|
||||
properties:
|
||||
name:
|
||||
|
@ -43,20 +55,24 @@ spec:
|
|||
TODO: Add other useful fields. apiVersion, kind, uid?'
|
||||
type: string
|
||||
type: object
|
||||
label:
|
||||
description: Label used for prune operations.
|
||||
interval:
|
||||
description: The interval at which to apply the kustomization.
|
||||
type: string
|
||||
path:
|
||||
description: Path to a source directory where the kustomization file
|
||||
is.
|
||||
description: Path to the directory containing the kustomization file.
|
||||
pattern: ^\./
|
||||
type: string
|
||||
prune:
|
||||
description: Label selector used for prune operations, e.g. env=staging.
|
||||
pattern: ^.*=.*$
|
||||
type: string
|
||||
required:
|
||||
- gitRepositoryRef
|
||||
- interval
|
||||
- path
|
||||
type: object
|
||||
status:
|
||||
description: KustomizationStatus defines the observed state of a kustomization
|
||||
description: KustomizationStatus defines the observed state of a kustomization.
|
||||
properties:
|
||||
conditions:
|
||||
items:
|
||||
|
|
Loading…
Reference in New Issue