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

Go API: Get value attributes as a slice #670

Open
cueckoo opened this issue Jul 3, 2021 · 2 comments
Open

Go API: Get value attributes as a slice #670

cueckoo opened this issue Jul 3, 2021 · 2 comments
Labels
FeatureRequest New feature or request

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @verdverm in cuelang/cue#670

Is your feature request related to a problem? Please describe.

I'd like to retrieve all the attributes for a value as a slice for further processing within my application. The current API does not allow this and requires knowing the key (https://pkg.go.dev/cuelang.org/go@v0.3.0-alpha6/cue#Value.Attribute). The same applies for retrieving the key/value pairs from an attribute, which is of more interest to extract actually. The POC returns the key/value pairs for an attribute as a Go map.

My users can specify a regex so I cannot know the keys beforehand and thus the need for extra processing.

Describe the solution you'd like

cuelang/cue#529 is a POC

Describe alternatives you've considered

The API does not support this. I currently maintain a small patch to expose the above.

@cueckoo cueckoo added the FeatureRequest New feature or request label Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @verdverm in cuelang/cue#670 (comment)

@mpvl would the query proposal (#165) support searching attributes?

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#670 (comment)

@verdverm Very likely not. By doing so attributes would matter for evaluation. The whole purpose of attributes is that they are not part of the language.

The only thing imagine is that one could analyze CUE in the tooling layer, including getting attributes. But they should not influence regular evaluation.

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

No branches or pull requests

3 participants