|
| 1 | +// Copyright (c) 2018-2026 Splunk Inc. All rights reserved. |
| 2 | + |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package v1alpha1 |
| 16 | + |
| 17 | +import ( |
| 18 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 19 | +) |
| 20 | + |
| 21 | +const ( |
| 22 | + // AppPausedAnnotation is the annotation that pauses the reconciliation (triggers |
| 23 | + // an immediate requeue) |
| 24 | + AppPausedAnnotation = "app.enterprise.splunk.com/paused" |
| 25 | +) |
| 26 | + |
| 27 | +// AppTargetRef defines the target environment the app should bind to. |
| 28 | +type AppTargetRef struct { |
| 29 | + // +kubebuilder:validation:Required |
| 30 | + // +kubebuilder:validation:MinLength=1 |
| 31 | + Kind string `json:"kind"` |
| 32 | + |
| 33 | + // +kubebuilder:validation:Required |
| 34 | + // +kubebuilder:validation:MinLength=1 |
| 35 | + Name string `json:"name"` |
| 36 | +} |
| 37 | + |
| 38 | +// AppPackageSpec defines the package location within the source. |
| 39 | +type AppPackageSpec struct { |
| 40 | + // +kubebuilder:validation:Required |
| 41 | + // +kubebuilder:validation:MinLength=1 |
| 42 | + Path string `json:"path"` |
| 43 | +} |
| 44 | + |
| 45 | +// AppSpec defines the desired state of App. |
| 46 | +type AppSpec struct { |
| 47 | + // +kubebuilder:validation:Required |
| 48 | + // +kubebuilder:validation:MinLength=1 |
| 49 | + AppID string `json:"appID"` |
| 50 | + |
| 51 | + // +kubebuilder:validation:Required |
| 52 | + // +kubebuilder:validation:MinLength=1 |
| 53 | + Version string `json:"version"` |
| 54 | + |
| 55 | + // +kubebuilder:validation:Required |
| 56 | + TargetRef AppTargetRef `json:"targetRef"` |
| 57 | + |
| 58 | + // +kubebuilder:validation:Required |
| 59 | + SourceRef AppSource `json:"sourceRef"` |
| 60 | + |
| 61 | + // +kubebuilder:validation:Required |
| 62 | + Package AppPackageSpec `json:"package"` |
| 63 | + |
| 64 | + // +kubebuilder:validation:Required |
| 65 | + // +kubebuilder:validation:MinLength=1 |
| 66 | + Scope string `json:"scope"` |
| 67 | +} |
| 68 | + |
| 69 | +// AppStatus defines the observed state of App. |
| 70 | +type AppStatus struct { |
| 71 | + // Phase of the app resource |
| 72 | + Phase string `json:"phase,omitempty"` |
| 73 | + |
| 74 | + // Auxillary message describing CR status |
| 75 | + Message string `json:"message,omitempty"` |
| 76 | + |
| 77 | + // InstalledVersion is the app version installed on target |
| 78 | + InstalledVersion string `json:"installedVersion,omitempty"` |
| 79 | + |
| 80 | + // Artifact tracks the resolved app package details |
| 81 | + Artifact *AppArtifactStatus `json:"artifact,omitempty"` |
| 82 | + |
| 83 | + // ObservedGeneration tracks the latest reconciled generation |
| 84 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 85 | + |
| 86 | + // Conditions represent the latest available observations of the app |
| 87 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 88 | +} |
| 89 | + |
| 90 | +// AppArtifactStatus defines resolved app artifact details. |
| 91 | +type AppArtifactStatus struct { |
| 92 | + // ResolvedPath is the resolved artifact path within the source |
| 93 | + ResolvedPath string `json:"resolvedPath,omitempty"` |
| 94 | + |
| 95 | + // Etag is the artifact hash or ETag used for change detection |
| 96 | + Etag string `json:"etag,omitempty"` |
| 97 | + |
| 98 | + // LastFetchedTime is the last time the artifact was fetched |
| 99 | + LastFetchedTime metav1.Time `json:"lastFetchedTime,omitempty"` |
| 100 | +} |
| 101 | + |
| 102 | +// +kubebuilder:object:root=true |
| 103 | +// +kubebuilder:subresource:status |
| 104 | + |
| 105 | +// App is the Schema for the apps API. |
| 106 | +// +k8s:openapi-gen=true |
| 107 | +// +kubebuilder:resource:path=apps,scope=Namespaced |
| 108 | +// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Status of app" |
| 109 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age of app resource" |
| 110 | +// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message",description="Auxillary message describing CR status" |
| 111 | +// +kubebuilder:storageversion |
| 112 | +type App struct { |
| 113 | + metav1.TypeMeta `json:",inline"` |
| 114 | + metav1.ObjectMeta `json:"metadata,omitempty,omitzero"` |
| 115 | + |
| 116 | + Spec AppSpec `json:"spec"` |
| 117 | + Status AppStatus `json:"status,omitempty,omitzero"` |
| 118 | +} |
| 119 | + |
| 120 | +// +kubebuilder:object:root=true |
| 121 | + |
| 122 | +// AppList contains a list of App. |
| 123 | +type AppList struct { |
| 124 | + metav1.TypeMeta `json:",inline"` |
| 125 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 126 | + Items []App `json:"items"` |
| 127 | +} |
| 128 | + |
| 129 | +func init() { |
| 130 | + SchemeBuilder.Register(&App{}, &AppList{}) |
| 131 | +} |
0 commit comments