Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/expose versions properties #36

Conversation

jehadnasser
Copy link
Contributor

Description of your changes

What happened?

The generated XRD always ends up having referenceable: false:

versions:
  - name: v1alpha1
    referenceable: false

which leads to a CRD with storage: false:

versions:
  - additionalPrinterColumns:
    # ...
    name: v1alpha1
    schema:
    # ...
    served: true
    storage: false

which causing the following error during the applying of the CRD:

cannot establish control of object: admission webhook "compositeresourcedefinitions.apiextensions.crossplane.io" denied the request: invalid CRD generated for CompositeResourceDefinition: CustomResourceDefinition.apiextensions.k8s.io "compositedbclusters.rds.aws.xxx.cloud" is invalid: [spec.versions: Invalid value: []apiextensions.CustomResourceDefinitionVersion{apiextensions.CustomResourceDefinitionVersion{Name:"v1alpha1", Served:true, Storage:false, Deprecated:false, DeprecationWarning:(*string)(nil), Schema:(*apiextensions.CustomResourceValidation)(nil), Subresources:(*apiextensions.CustomResourceSubresources)(nil), AdditionalPrinterColumns:[]apiextensions.CustomResourceColumnDefinition(nil)}}: must have exactly one version marked as storage version, status.storedVersions: Invalid value: []string(nil): must have at least one stored version]

How I solved the issue locally?

  • I passed the versions details in the generate.yaml file:
versions:
  - name: v1alpha1
    served: true
    referenceable: true
  • then I used the passed values in the generator
    Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Versions: []c.CompositeResourceDefinitionVersion{
{
Name: g.Version,
Referenceable: version.Storage,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we have multiple versions in provider crds we cannot use version.Storage and version.Served because we generating only one version in xrd so we need to set here true / true

diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go
index 63e2281..2ef9218 100644
--- a/pkg/generator/generator.go
+++ b/pkg/generator/generator.go
@@ -115,8 +115,8 @@ func (g *XGenerator) GenerateXRD() (*c.CompositeResourceDefinition, error) {
                        Versions: []c.CompositeResourceDefinitionVersion{
                                {
                                        Name:          g.Version,
-                                       Referenceable: version.Storage,
-                                       Served:        version.Served,
+                                       Referenceable: true,
+                                       Served:        true,
                                        Schema: &c.CompositeResourceValidation{
                                                OpenAPIV3Schema: runtime.RawExtension{
                                                        Object: &unstructured.Unstructured{

we don't need an configuration option for generate.yaml because we have only one version

@haarchri
Copy link
Member

@jehadnasser please update the PR and please sign DCO thanks

@jehadnasser
Copy link
Contributor Author

suggested alternative fix by @haarchri is in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants