Skip to content

Commit 116d6c0

Browse files
gazarenkovgithub-actions[bot]rm3l
authored
restore v1alpha1, v1alpha2 and move v1alpha6 to v1alpha5 (#2727)
* restore v1alpha1, v1alpha2, move v1alpha6 to v1alpha5 * Regenerate bundle/installer manifests Co-authored-by: gazarenkov <gazarenkov@users.noreply.github.com> * make bundle * Regenerate bundle/installer manifests Co-authored-by: gazarenkov <gazarenkov@users.noreply.github.com> * fix test, remove v1alpha6 occurence --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: gazarenkov <gazarenkov@users.noreply.github.com> Co-authored-by: Armel Soro <asoro@redhat.com>
1 parent b673391 commit 116d6c0

55 files changed

Lines changed: 2741 additions & 1063 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rhdh/docs/airgap.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ On a vanilla Kubernetes, you can create a Custom Resource (CR) using `kubectl`,
225225
[source,yaml]
226226
----
227227
cat <<EOF | kubectl -n rhdh-operator apply -f -
228-
apiVersion: rhdh.redhat.com/v1alpha6
228+
apiVersion: rhdh.redhat.com/v1alpha5
229229
kind: Backstage
230230
metadata:
231231
name: developer-hub

.rhdh/scripts/install-rhdh-catalog-source.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ if [[ "${IS_OPENSHIFT}" = "true" ]]; then
862862
fi
863863
CR_EXAMPLE="
864864
cat <<EOF | ${CLI_TOOL} apply -f -
865-
apiVersion: rhdh.redhat.com/v1alpha6
865+
apiVersion: rhdh.redhat.com/v1alpha5
866866
kind: Backstage
867867
metadata:
868868
name: developer-hub

.rhdh/scripts/prepare-restricted-environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ if [[ -n "${TO_REGISTRY}" ]]; then
13091309
fi
13101310
CR_EXAMPLE="
13111311
cat <<EOF | ${CLI_TOOL} -n ${NAMESPACE_OPERATOR} apply -f -
1312-
apiVersion: rhdh.redhat.com/v1alpha6
1312+
apiVersion: rhdh.redhat.com/v1alpha5
13131313
kind: Backstage
13141314
metadata:
13151315
name: developer-hub

PROJECT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ resources:
1717
controller: true
1818
domain: rhdh.redhat.com
1919
kind: Backstage
20-
path: github.com/redhat-developer/rhdh-operator/api/v1alpha6
21-
version: v1alpha6
20+
path: github.com/redhat-developer/rhdh-operator/api/v1alpha5
21+
version: v1alpha5
2222
version: "3"

api/current-types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package api
22

33
import (
4-
bsv1 "github.com/redhat-developer/rhdh-operator/api/v1alpha6"
4+
bsv1 "github.com/redhat-developer/rhdh-operator/api/v1alpha5"
55
)
66

77
// Type aliases to decouple application code from specific API versions.

api/v1alpha1/backstage_types.go

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/utils/ptr"
6+
)
7+
8+
type BackstageConditionReason string
9+
10+
type BackstageConditionType string
11+
12+
const (
13+
BackstageConditionTypeDeployed BackstageConditionType = "Deployed"
14+
15+
BackstageConditionReasonDeployed BackstageConditionReason = "Deployed"
16+
BackstageConditionReasonFailed BackstageConditionReason = "DeployFailed"
17+
BackstageConditionReasonInProgress BackstageConditionReason = "DeployInProgress"
18+
)
19+
20+
// BackstageSpec defines the desired state of Backstage
21+
type BackstageSpec struct {
22+
// Configuration for Backstage. Optional.
23+
Application *Application `json:"application,omitempty"`
24+
25+
// Raw Runtime RuntimeObjects configuration. For Advanced scenarios.
26+
RawRuntimeConfig *RuntimeConfig `json:"rawRuntimeConfig,omitempty"`
27+
28+
// Configuration for database access. Optional.
29+
Database *Database `json:"database,omitempty"`
30+
}
31+
32+
type RuntimeConfig struct {
33+
// Name of ConfigMap containing Backstage runtime objects configuration
34+
BackstageConfigName string `json:"backstageConfig,omitempty"`
35+
// Name of ConfigMap containing LocalDb (PostgreSQL) runtime objects configuration
36+
LocalDbConfigName string `json:"localDbConfig,omitempty"`
37+
}
38+
39+
type Database struct {
40+
// Control the creation of a local PostgreSQL DB. Set to false if using for example an external Database for Backstage.
41+
// +optional
42+
//+kubebuilder:default=true
43+
EnableLocalDb *bool `json:"enableLocalDb,omitempty"`
44+
45+
// Name of the secret for database authentication. Optional.
46+
// For a local database deployment (EnableLocalDb=true), a secret will be auto generated if it does not exist.
47+
// The secret shall include information used for the database access.
48+
// An example for PostgreSQL DB access:
49+
// "POSTGRES_PASSWORD": "rl4s3Fh4ng3M4"
50+
// "POSTGRES_PORT": "5432"
51+
// "POSTGRES_USER": "postgres"
52+
// "POSTGRESQL_ADMIN_PASSWORD": "rl4s3Fh4ng3M4"
53+
// "POSTGRES_HOST": "backstage-psql-bs1" # For local database, set to "backstage-psql-<CR name>".
54+
AuthSecretName string `json:"authSecretName,omitempty"`
55+
}
56+
57+
type Application struct {
58+
// References to existing app-configs ConfigMap objects, that will be mounted as files in the specified mount path.
59+
// Each element can be a reference to any ConfigMap or Secret,
60+
// and will be mounted inside the main application container under a specified mount directory.
61+
// Additionally, each file will be passed as a `--config /mount/path/to/configmap/key` to the
62+
// main container args in the order of the entries defined in the AppConfigs list.
63+
// But bear in mind that for a single ConfigMap element containing several filenames,
64+
// the order in which those files will be appended to the main container args cannot be guaranteed.
65+
// So if you want to pass multiple app-config files, it is recommended to pass one ConfigMap per app-config file.
66+
// +optional
67+
AppConfig *AppConfig `json:"appConfig,omitempty"`
68+
69+
// Reference to an existing ConfigMap for Dynamic Plugins.
70+
// A new one will be generated with the default config if not set.
71+
// The ConfigMap object must have an existing key named: 'dynamic-plugins.yaml'.
72+
// +optional
73+
DynamicPluginsConfigMapName string `json:"dynamicPluginsConfigMapName,omitempty"`
74+
75+
// References to existing Config objects to use as extra config files.
76+
// They will be mounted as files in the specified mount path.
77+
// Each element can be a reference to any ConfigMap or Secret.
78+
// +optional
79+
ExtraFiles *ExtraFiles `json:"extraFiles,omitempty"`
80+
81+
// Extra environment variables
82+
// +optional
83+
ExtraEnvs *ExtraEnvs `json:"extraEnvs,omitempty"`
84+
85+
// Number of desired replicas to set in the Backstage Deployment.
86+
// Defaults to 1.
87+
// +optional
88+
//+kubebuilder:default=1
89+
Replicas *int32 `json:"replicas,omitempty"`
90+
91+
// Custom image to use in all containers (including Init Containers).
92+
// It is your responsibility to make sure the image is from trusted sources and has been validated for security compliance
93+
// +optional
94+
Image *string `json:"image,omitempty"`
95+
96+
// Image Pull Secrets to use in all containers (including Init Containers)
97+
// +optional
98+
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
99+
100+
// Route configuration. Used for OpenShift only.
101+
Route *Route `json:"route,omitempty"`
102+
}
103+
104+
type AppConfig struct {
105+
// Mount path for all app-config files listed in the ConfigMapRefs field
106+
// +optional
107+
// +kubebuilder:default=/opt/app-root/src
108+
MountPath string `json:"mountPath,omitempty"`
109+
110+
// List of ConfigMaps storing the app-config files. Will be mounted as files under the MountPath specified.
111+
// For each item in this array, if a key is not specified, it means that all keys in the ConfigMap will be mounted as files.
112+
// Otherwise, only the specified key will be mounted as a file.
113+
// Bear in mind not to put sensitive data in those ConfigMaps. Instead, your app-config content can reference
114+
// environment variables (which you can set with the ExtraEnvs field) and/or include extra files (see the ExtraFiles field).
115+
// More details on https://backstage.io/docs/conf/writing/.
116+
// +optional
117+
ConfigMaps []ObjectKeyRef `json:"configMaps,omitempty"`
118+
}
119+
120+
type ExtraFiles struct {
121+
// Mount path for all extra configuration files listed in the Items field
122+
// +optional
123+
// +kubebuilder:default=/opt/app-root/src
124+
MountPath string `json:"mountPath,omitempty"`
125+
126+
// List of references to ConfigMaps objects mounted as extra files under the MountPath specified.
127+
// For each item in this array, if a key is not specified, it means that all keys in the ConfigMap will be mounted as files.
128+
// Otherwise, only the specified key will be mounted as a file.
129+
// +optional
130+
ConfigMaps []ObjectKeyRef `json:"configMaps,omitempty"`
131+
132+
// List of references to Secrets objects mounted as extra files under the MountPath specified.
133+
// For each item in this array, a key must be specified that will be mounted as a file.
134+
// +optional
135+
Secrets []ObjectKeyRef `json:"secrets,omitempty"`
136+
}
137+
138+
type ExtraEnvs struct {
139+
// List of references to ConfigMaps objects to inject as additional environment variables.
140+
// For each item in this array, if a key is not specified, it means that all keys in the ConfigMap will be injected as additional environment variables.
141+
// Otherwise, only the specified key will be injected as an additional environment variable.
142+
// +optional
143+
ConfigMaps []ObjectKeyRef `json:"configMaps,omitempty"`
144+
145+
// List of references to Secrets objects to inject as additional environment variables.
146+
// For each item in this array, if a key is not specified, it means that all keys in the Secret will be injected as additional environment variables.
147+
// Otherwise, only the specified key will be injected as environment variable.
148+
// +optional
149+
Secrets []ObjectKeyRef `json:"secrets,omitempty"`
150+
151+
// List of name and value pairs to add as environment variables.
152+
// +optional
153+
Envs []Env `json:"envs,omitempty"`
154+
}
155+
156+
type ObjectKeyRef struct {
157+
// Name of the object
158+
// We support only ConfigMaps and Secrets.
159+
//+kubebuilder:validation:Required
160+
Name string `json:"name"`
161+
162+
// Key in the object
163+
// +optional
164+
Key string `json:"key,omitempty"`
165+
}
166+
167+
type Env struct {
168+
// Name of the environment variable
169+
//+kubebuilder:validation:Required
170+
Name string `json:"name"`
171+
172+
// Value of the environment variable
173+
//+kubebuilder:validation:Required
174+
Value string `json:"value"`
175+
}
176+
177+
// BackstageStatus defines the observed state of Backstage
178+
type BackstageStatus struct {
179+
// Conditions is the list of conditions describing the state of the runtime
180+
// +optional
181+
Conditions []metav1.Condition `json:"conditions,omitempty"`
182+
}
183+
184+
//+kubebuilder:unservedversion
185+
//+kubebuilder:deprecatedversion:warning="v1alpha1 is not served"
186+
//+kubebuilder:object:root=true
187+
//+kubebuilder:subresource:status
188+
// +operator-sdk:csv:customresourcedefinitions:displayName="Red Hat Developer Hub"
189+
190+
// Backstage is the Schema for the Red Hat Developer Hub backstages API.
191+
// It comes with pre-built plug-ins, configuration settings, and deployment mechanisms,
192+
// which can help streamline the process of setting up a self-managed internal
193+
// developer portal for adopters who are just starting out.
194+
type Backstage struct {
195+
metav1.TypeMeta `json:",inline"`
196+
metav1.ObjectMeta `json:"metadata,omitempty"`
197+
198+
Spec BackstageSpec `json:"spec,omitempty"`
199+
Status BackstageStatus `json:"status,omitempty"`
200+
}
201+
202+
//+kubebuilder:object:root=true
203+
204+
// BackstageList contains a list of Backstage
205+
type BackstageList struct {
206+
metav1.TypeMeta `json:",inline"`
207+
metav1.ListMeta `json:"metadata,omitempty"`
208+
Items []Backstage `json:"items"`
209+
}
210+
211+
// Route specifies configuration parameters for OpenShift Route for Backstage.
212+
// Only a secured edge route is supported for Backstage.
213+
type Route struct {
214+
// Control the creation of a Route on OpenShift.
215+
// +optional
216+
//+kubebuilder:default=true
217+
Enabled *bool `json:"enabled,omitempty"`
218+
219+
// Host is an alias/DNS that points to the service. Optional.
220+
// Ignored if Enabled is false.
221+
// If not specified a route name will typically be automatically
222+
// chosen. Must follow DNS952 subdomain conventions.
223+
// +optional
224+
// +kubebuilder:validation:MaxLength=253
225+
// +kubebuilder:validation:Pattern=`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`
226+
Host string `json:"host,omitempty" protobuf:"bytes,1,opt,name=host"`
227+
228+
// Subdomain is a DNS subdomain that is requested within the ingress controller's
229+
// domain (as a subdomain).
230+
// Ignored if Enabled is false.
231+
// Example: subdomain `frontend` automatically receives the router subdomain
232+
// `apps.mycluster.com` to have a full hostname `frontend.apps.mycluster.com`.
233+
// +optional
234+
// +kubebuilder:validation:MaxLength=253
235+
// +kubebuilder:validation:Pattern=`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`
236+
Subdomain string `json:"subdomain,omitempty"`
237+
238+
// The tls field provides the ability to configure certificates for the route.
239+
// Ignored if Enabled is false.
240+
// +optional
241+
TLS *TLS `json:"tls,omitempty"`
242+
}
243+
244+
type TLS struct {
245+
// certificate provides certificate contents. This should be a single serving certificate, not a certificate
246+
// chain. Do not include a CA certificate.
247+
Certificate string `json:"certificate,omitempty"`
248+
249+
// ExternalCertificateSecretName provides certificate contents as a secret reference.
250+
// This should be a single serving certificate, not a certificate
251+
// chain. Do not include a CA certificate. The secret referenced should
252+
// be present in the same namespace as that of the Route.
253+
// Forbidden when `certificate` is set.
254+
// Note that securing Routes with external certificates in TLS secrets is a Technology Preview feature in OpenShift,
255+
// and requires enabling the `RouteExternalCertificate` OpenShift Feature Gate and might not be functionally complete.
256+
// +optional
257+
ExternalCertificateSecretName string `json:"externalCertificateSecretName,omitempty"`
258+
259+
// key provides key file contents
260+
Key string `json:"key,omitempty"`
261+
262+
// caCertificate provides the cert authority certificate contents
263+
CACertificate string `json:"caCertificate,omitempty"`
264+
}
265+
266+
func init() {
267+
SchemeBuilder.Register(&Backstage{}, &BackstageList{})
268+
}
269+
270+
// IsLocalDbEnabled returns true if Local database is configured and enabled
271+
func (s *BackstageSpec) IsLocalDbEnabled() bool {
272+
if s.Database == nil {
273+
return true
274+
}
275+
return ptr.Deref(s.Database.EnableLocalDb, true)
276+
}
277+
278+
// IsRouteEnabled returns value of Application.Route.Enabled if defined or true by default
279+
func (s *BackstageSpec) IsRouteEnabled() bool {
280+
if s.Application != nil && s.Application.Route != nil {
281+
return ptr.Deref(s.Application.Route.Enabled, true)
282+
}
283+
return true
284+
}
285+
286+
func (s *BackstageSpec) IsAuthSecretSpecified() bool {
287+
return s.Database != nil && s.Database.AuthSecretName != ""
288+
}
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)