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

Ignore CEL expressions for CRDs #46

Merged
merged 1 commit into from
Oct 7, 2024
Merged

Ignore CEL expressions for CRDs #46

merged 1 commit into from
Oct 7, 2024

Conversation

michaelhtm
Copy link
Contributor

Description of changes:
We are deciding to ignore CEL expressions for CRDs
for now, since CRDs get some variables injected
by kubernetes that don't have specific types.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and TiberiuGC October 5, 2024 00:54
@ack-prow ack-prow bot added the approved label Oct 5, 2024
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thank you michael! I had few nits below~

// TODO(michaelhtm): CRDs are not supported for extraction currently
// implement new logic specific to CRDs
if gvk.Kind == "CustomResourceDefinition" {
emulatedResource, err := parser.ParseSchemalessResource(unstructuredResource)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
emulatedResource, err := parser.ParseSchemalessResource(unstructuredResource)
celExpressions, err := parser.ParseSchemalessResource(unstructuredResource)

Comment on lines 134 to 136
if emulatedResource != nil {
return nil, fmt.Errorf("failed, CEL expressions are not supported for CRDs, resource %s", rgResource.Name)
}
Copy link
Member

Choose a reason for hiding this comment

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

slices can be non-nil and contain 0 elements

Suggested change
if emulatedResource != nil {
return nil, fmt.Errorf("failed, CEL expressions are not supported for CRDs, resource %s", rgResource.Name)
}
if len(emulatedResource) > 0 {
return nil, fmt.Errorf("failed, CEL expressions are not supported for CRDs, resource %s", rgResource.Name)
}

if err != nil {
return nil, fmt.Errorf("failed to extract CEL expressions from schema for resource %s: %w", rgResource.Name, err)
}
resourceVariables = []*ResourceVariable{}
Copy link
Member

Choose a reason for hiding this comment

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

resourceVariable is already redeclared in L125

})
// TODO(michaelhtm): CRDs are not supported for extraction currently
// implement new logic specific to CRDs
if gvk.Kind == "CustomResourceDefinition" {
Copy link
Member

Choose a reason for hiding this comment

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

Should we check for the full GVK instead of just the Kind name?

We are deciding to ignore CEL expressions for CRDs
for now, since CRDs get some variables injected
by kubernetes that don't have specific types.
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

First code contribution to symphony :) 🚀
/lgtm

@ack-prow ack-prow bot added the lgtm label Oct 7, 2024
Copy link

ack-prow bot commented Oct 7, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, michaelhtm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [a-hilaly,michaelhtm]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@a-hilaly a-hilaly merged commit 8b899c1 into main Oct 7, 2024
3 of 4 checks passed
@a-hilaly a-hilaly deleted the support-crd branch October 8, 2024 04:54
a-hilaly added a commit that referenced this pull request Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants