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

Allow nested short hand for lists #1603

Open
mattklein123 opened this issue Mar 29, 2022 · 2 comments
Open

Allow nested short hand for lists #1603

mattklein123 opened this issue Mar 29, 2022 · 2 comments
Labels
FeatureRequest New feature or request

Comments

@mattklein123
Copy link

mattklein123 commented Mar 29, 2022

Is your feature request related to a problem? Please describe.
Short hand notation for structs (no braces for internal references) is a very nice feature. I find myself wanting this same capability for lists to reduce verbosity.

Describe the solution you'd like

Take a config like this:

cds.#cluster & {
		name: "foo"
		load_assignment: endpoints: [{
			lb_endpoints: [{
				endpoint: address: socket_address: {
					address:    "foo.svc.cluster.local"
					port_value: 8088
				}
			}]
		}]
	}

And allow it to be written as:

cds.#cluster & {
		name: "foo"
		load_assignment: endpoints[0]: lb_endpoints[0]: endpoint: address: socket_address: {
			address:    "foo.svc.cluster.local"
			port_value: 8088
		}
	}

Describe alternatives you've considered
Write it out more verbosely per above.

Additional context
None. I tried to look for an existing issue on this and could't find one. Sorry if I missed it. Thank you for a great tool!

@mattklein123 mattklein123 added FeatureRequest New feature or request Triage Requires triage/attention labels Mar 29, 2022
@mpvl
Copy link
Member

mpvl commented Mar 29, 2022

The query proposal (#165) alludes to allowing the following shorthand:

load_assignment: endpoints: 0: lb_endpoints: 0: endpoint: address: socket_address: {
			address:    "foo.svc.cluster.local"
			port_value: 8088
		}

The intention is to do this at some point. Note that this would seemingly be ambiguous to allowing integer maps as well. However, CUE internally lists and maps are treated identically, so a list would just be a constraint on the "totalness" of the map. So, technically, in the above example one would still need to define somewhere that the endpoints fields are lists. Presumably that is done in cds.#cluster already though.

So it is these details that need to be worked out to make that work, but basically this is being considered.

@mattklein123
Copy link
Author

So it is these details that need to be worked out to make that work, but basically this is being considered.

Awesome thank you!

@rogpeppe rogpeppe removed the Triage Requires triage/attention label Apr 14, 2022
@myitcv myitcv added the zGarden label Jun 13, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
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

5 participants