feat: add v1alpha4 API version for Backstage Custom Resource - #1406
Conversation
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
…pcopy.go in v1alpha4 from v1alpha3 to v1alpha4 Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
- Create new v1alpha4 API package copied from v1alpha3 - Update all version identifiers from v1alpha3 to v1alpha4 - Register both v1alpha3 and v1alpha4 in operator scheme - Regenerate CRD manifests to serve both versions - Keep v1alpha3 as storage version, v1alpha4 as served only - Update controller to handle both API versions - No functional changes - v1alpha4 behaves identically to v1alpha3 This establishes the foundation for upcoming monitoring feature (RHIDP-5778) while maintaining backward compatibility with v1alpha3. Tests: All integration tests and unit tests pass Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
Reviewer's GuideThis PR introduces a new v1alpha4 API version for the Backstage custom resource by duplicating the existing v1alpha3 scaffolding, updating all identifiers and imports, registering v1alpha4 with the operator, and regenerating CRDs and OLM manifests. It preserves backward compatibility by keeping v1alpha3 as the storage version and making v1alpha4 served only, with no functional changes to the resource behavior. Entity relationship diagram for Backstage CRD versions (v1alpha3 and v1alpha4)erDiagram
Backstage_v1alpha3 ||--o{ BackstageStatus_v1alpha3 : has
Backstage_v1alpha4 ||--o{ BackstageStatus_v1alpha4 : has
Backstage_v1alpha3 {
string apiVersion
string kind
object metadata
BackstageSpec_v1alpha3 spec
BackstageStatus_v1alpha3 status
}
Backstage_v1alpha4 {
string apiVersion
string kind
object metadata
BackstageSpec_v1alpha4 spec
BackstageStatus_v1alpha4 status
}
BackstageSpec_v1alpha3 {
Application application
Database database
BackstageDeployment deployment
RuntimeConfig rawRuntimeConfig
}
BackstageSpec_v1alpha4 {
Application application
Database database
BackstageDeployment deployment
RuntimeConfig rawRuntimeConfig
}
BackstageStatus_v1alpha3 {
Condition[] conditions
}
BackstageStatus_v1alpha4 {
Condition[] conditions
}
Application {
AppConfig appConfig
string dynamicPluginsConfigMapName
ExtraEnvs extraEnvs
ExtraFiles extraFiles
string image
string[] imagePullSecrets
int replicas
Route route
}
Database {
string authSecretName
bool enableLocalDb
}
BackstageDeployment {
object patch
}
RuntimeConfig {
string backstageConfig
string localDbConfig
}
Condition {
string lastTransitionTime
string message
int observedGeneration
string reason
string status
string type
}
Class diagram for new Backstage v1alpha4 API typesclassDiagram
class Backstage {
+TypeMeta
+ObjectMeta
+BackstageSpec Spec
+BackstageStatus Status
}
class BackstageSpec {
+Application Application
+Database Database
+BackstageDeployment Deployment
+RuntimeConfig RawRuntimeConfig
}
class Application {
+AppConfig AppConfig
+string DynamicPluginsConfigMapName
+ExtraEnvs ExtraEnvs
+ExtraFiles ExtraFiles
+string Image
+string[] ImagePullSecrets
+int32 Replicas
+Route Route
}
class AppConfig {
+FileObjectRef[] ConfigMaps
+string MountPath
}
class ExtraEnvs {
+EnvObjectRef[] ConfigMaps
+EnvObjectRef[] Secrets
+Env[] Envs
}
class ExtraFiles {
+FileObjectRef[] ConfigMaps
+FileObjectRef[] Secrets
+PvcRef[] Pvcs
+string MountPath
}
class Database {
+string AuthSecretName
+bool EnableLocalDb
}
class BackstageDeployment {
+object Patch
}
class RuntimeConfig {
+string BackstageConfig
+string LocalDbConfig
}
class Route {
+bool Enabled
+string Host
+string Subdomain
+TLS TLS
}
class TLS {
+string CaCertificate
+string Certificate
+string ExternalCertificateSecretName
+string Key
}
class BackstageStatus {
+Condition[] Conditions
}
class Condition {
+string LastTransitionTime
+string Message
+int64 ObservedGeneration
+string Reason
+string Status
+string Type
}
Backstage --> BackstageSpec
Backstage --> BackstageStatus
BackstageSpec --> Application
BackstageSpec --> Database
BackstageSpec --> BackstageDeployment
BackstageSpec --> RuntimeConfig
Application --> AppConfig
Application --> ExtraEnvs
Application --> ExtraFiles
Application --> Route
AppConfig --> FileObjectRef
ExtraEnvs --> EnvObjectRef
ExtraEnvs --> Env
ExtraFiles --> FileObjectRef
ExtraFiles --> PvcRef
Route --> TLS
BackstageStatus --> Condition
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @Fortune-Ndlovu - I've reviewed your changes - here's some feedback:
- Consider automating CRD manifest generation (e.g. via controller-gen/make scripts) instead of manually copying that large schema block across multiple directories to reduce drift and maintenance overhead.
- Verify that the CSV’s replaces/skips settings and owned CRD entries are updated so v1alpha4 properly replaces v1alpha3 and supports a seamless operator upgrade path.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider automating CRD manifest generation (e.g. via controller-gen/make scripts) instead of manually copying that large schema block across multiple directories to reduce drift and maintenance overhead.
- Verify that the CSV’s replaces/skips settings and owned CRD entries are updated so v1alpha4 properly replaces v1alpha3 and supports a seamless operator upgrade path.
## Individual Comments
### Comment 1
<location> `integration_tests/config-refresh_test.go:19` </location>
<code_context>
"sigs.k8s.io/controller-runtime/pkg/webhook"
- bsv1 "github.com/redhat-developer/rhdh-operator/api/v1alpha3"
+ bsv1 "github.com/redhat-developer/rhdh-operator/api/v1alpha4"
"github.com/redhat-developer/rhdh-operator/internal/controller"
</code_context>
<issue_to_address>
Integration tests now import v1alpha4, but do not explicitly test v1alpha3/v1alpha4 compatibility.
Please add tests to verify that both v1alpha3 and v1alpha4 resources are accepted by the operator, ensuring backward compatibility since v1alpha3 is still the storage version.
Suggested implementation:
```golang
bsv1 "github.com/redhat-developer/rhdh-operator/api/v1alpha4"
bsv1alpha3 "github.com/redhat-developer/rhdh-operator/api/v1alpha3"
```
```golang
_, _, err = executeRemoteCommand(ctx, ns, podName, backstageContainerName(deploy), "cat /my/secret/sec11")
g.Expect(err).ShouldNot(HaveOccurred())
// --- Backward compatibility test for v1alpha3 ---
By("creating a Backstage resource using v1alpha3 API")
bsV1Alpha3 := &bsv1alpha3.Backstage{
ObjectMeta: metav1.ObjectMeta{
Name: "test-v1alpha3",
Namespace: ns,
},
Spec: bsv1alpha3.BackstageSpec{
// Fill in required fields for v1alpha3 spec
},
}
err = k8sClient.Create(ctx, bsV1Alpha3)
g.Expect(err).ShouldNot(HaveOccurred())
By("verifying the operator reconciles the v1alpha3 resource")
Eventually(func() error {
fetched := &bsv1alpha3.Backstage{}
return k8sClient.Get(ctx, types.NamespacedName{Name: "test-v1alpha3", Namespace: ns}, fetched)
}, timeout, interval).Should(Succeed())
// --- Compatibility test for v1alpha4 ---
By("creating a Backstage resource using v1alpha4 API")
bsV1Alpha4 := &bsv1.Backstage{
ObjectMeta: metav1.ObjectMeta{
Name: "test-v1alpha4",
Namespace: ns,
},
Spec: bsv1.BackstageSpec{
// Fill in required fields for v1alpha4 spec
},
}
err = k8sClient.Create(ctx, bsV1Alpha4)
g.Expect(err).ShouldNot(HaveOccurred())
By("verifying the operator reconciles the v1alpha4 resource")
Eventually(func() error {
fetched := &bsv1.Backstage{}
return k8sClient.Get(ctx, types.NamespacedName{Name: "test-v1alpha4", Namespace: ns}, fetched)
}, timeout, interval).Should(Succeed())
```
- You will need to fill in the required fields for `BackstageSpec` in both v1alpha3 and v1alpha4 resources to match your CRD requirements.
- If the test file uses a test framework like Ginkgo, ensure the new test code is placed within the appropriate test context or `It` block.
- Make sure `metav1` is imported if not already present: `metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"`.
- Adjust variable names and context as needed to fit your test structure.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…patability not my actual k8s api versions Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com>
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
|
|
Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com>
|
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gazarenkov, rm3l The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…developer#1406) Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Gennady Azarenkov <gazarenkov@gmail.com> Co-authored-by: Armel Soro <asoro@redhat.com>
…developer#1406) Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Gennady Azarenkov <gazarenkov@gmail.com> Co-authored-by: Armel Soro <asoro@redhat.com>
…developer#1406) Co-authored-by: Fortune-Ndlovu <Fortune-Ndlovu@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Gennady Azarenkov <gazarenkov@gmail.com> Co-authored-by: Armel Soro <asoro@redhat.com>
Description
This PR introduces a new API version v1alpha4 for the Backstage custom resource, establishing the foundation for upcoming features while maintaining full backward compatibility with existing versions. Essentially the entention was to:
This establishes the foundation for upcoming monitoring feature (RHIDP-5778)
while maintaining backward compatibility with v1alpha3.
Tests: All integration tests and unit tests pass
Which issue(s) does this PR fix or relate to
https://issues.redhat.com/browse/RHIDP-8248
PR acceptance criteria
How to test changes / Special notes to the reviewer
Please read my testing procedure within my latest comment here https://issues.redhat.com/browse/RHIDP-8248
Summary by Sourcery
Introduce a new v1alpha4 API version for the Backstage custom resource while preserving full backward compatibility with v1alpha3
New Features:
Enhancements:
Documentation:
Tests: