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

bug: manifest parser sees spaces in comments as multiple results #25

Open
lander2k2 opened this issue Jun 10, 2022 · 1 comment
Open

Comments

@lander2k2
Copy link
Contributor

Consider the following manifest:

---
# +operator-builder:resource:collectionField=provider,value="aws",include
apiVersion: v1
kind: ConfigMap
metadata:
  name: contour-config-test-collection-field
  namespace: ingress-system  # +operator-builder:field:name=namespace,default=ingress-system,type=string
data:
  this: "serves no purpose other than to test resource markers on collection fields"
---
# +operator-builder:resource:collectionField=provider,value="aws",include
# Note: Comments with spaces can cause problems with parsing.  Leave this here 
# for functional testing purposes.

# The space above is actually what causes the problem.
apiVersion: v1
kind: ConfigMap
metadata:
  name: contour-config-test-parse-comment
  namespace: ingress-system  # +operator-builder:field:name=namespace,default=ingress-system,type=string
data:
  this: "serves no purpose other than to test comment spaces for resource markers on collection fields"

With a space in the comment, this will actually return multiple marker results for the contour-config-test-parse-comment ConfigMap. While this is not necessarily an issue if we handle the result properly, the marker package should only return one result as there is only one marker.

UPDATE: this is actually in the manifest parser, not the marker parser, as the static content while parsing looks like this:

(this is from a debug console)

"\n# +operator-builder:resource:collectionField=provider,value=\"aws\",include\napiVersion: v1\nkind: ConfigMap\nmetadata:\n    name: contour-config-test-collection-field\n    namespace: !!var parent.Spec.Namespace # controlled by field: namespace\ndata:\n    this: \"serves no purpose other than to test resource markers on collection fields\"\n\n# +operator-builder:resource:collectionField=provider,value=\"aws\",include\n# Note: Comments with spaces can cause problems with parsing.  Leave this here \n# for functional testing purposes."
@lander2k2
Copy link
Contributor Author

Original issue:
vmware-archive/operator-builder#271

scottd018 pushed a commit that referenced this issue Jun 14, 2022
* Use collection variables in resource definitions

* fixed missing commas in multi-line function

Signed-off-by: Dustin Scott <sdustin@vmware.com>

* fixed problem with multi-line function call

Signed-off-by: Dustin Scott <sdustin@vmware.com>

* corrected linting problem and multiple return statements

Signed-off-by: Dustin Scott <sdustin@vmware.com>

* Fix syntax error

Co-authored-by: Dustin Scott <sdustin@vmware.com>
Signed-off-by: Jeff Davis <jeffda@vmware.com>
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

No branches or pull requests

1 participant