Skip to content

There should be a way to filter out resources from the final output #91

@sudohikumar

Description

@sudohikumar

The way cue handles exports using -e flag to just give output of specific element, cuestomize should also provide a way to filter out resources from the final output.

Use case

Suppose we have 1 resource that needs to be created beforehand as part of bootstrap. Then we can apply other resources on the cluster.
outputs dumps all the resources in 1 single file by default.
Currently, the way to do using cuestomize are the following

  • yq split and search and write our own custom logic for that filtering
  • slice all the resources in a folder and again write logic to filter out specific resources
  • Have multiple modules exported separately based on the usecase. (I think this adds additional files but cleaner than above 2).

Suppose we have main.cue as follows

...
outputs: {
	cm: #ConfigMap
	deployment: #Deployment 
         ....
}
...

I can simply do this via vanilla cue cli

cue export -e outputs.cm --out yaml
cue export -e outputs.deployment--out yaml

Similar thing is not possible currently here.

Proposals

I propose 2 types of solutions. Both has pros and cons. But it makes filtering easier.

  1. Output multiple outputs as keys than can be used to filter out on client side.
    Example:
outputs: {
	controllerResources: {
		cm: #ConfigMap
		deployment: #Deployment 
	}
	baseResources: {
		sa: #SA
		role: #Role
	}
}

This can be further refined if accepted.
2. Similar to includes feature, we also have filter spec than can filter out fields to give final output.
Example:

apiVersion: cuestomize.dev/v1alpha1
kind: Cuestomization
...
filter:
  - group: apps
    version: v1
    kind: Deployment
    name: manager
    namespace: default

This will only give deployment spec with that filter match. This will be client side filtering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions