Skip to content

Commit bffa2f9

Browse files
committed
add app crd
Signed-off-by: jzywieck <jzywiecki@splunk.com>
1 parent 5e97796 commit bffa2f9

16 files changed

Lines changed: 870 additions & 3 deletions

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,13 @@ resources:
150150
kind: AppSource
151151
path: github.com/splunk/splunk-operator/api/apps/v1alpha1
152152
version: v1alpha1
153+
- api:
154+
crdVersion: v1
155+
namespaced: true
156+
controller: true
157+
domain: splunk.com
158+
group: apps
159+
kind: App
160+
path: github.com/splunk/splunk-operator/api/apps/v1alpha1
161+
version: v1alpha1
153162
version: "3"

api/apps/v1alpha1/app_types.go

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
}

api/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 152 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ func main() {
326326
setupLog.Error(err, "unable to create controller", "controller", "AppSource")
327327
os.Exit(1)
328328
}
329+
if err := (&appscontroller.AppReconciler{
330+
Client: mgr.GetClient(),
331+
Scheme: mgr.GetScheme(),
332+
}).SetupWithManager(mgr); err != nil {
333+
setupLog.Error(err, "unable to create controller", "controller", "App")
334+
os.Exit(1)
335+
}
329336
//+kubebuilder:scaffold:builder
330337

331338
// Register certificate watchers with the manager

0 commit comments

Comments
 (0)