apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: "A list of JSON6902 patch to selected target"
  name: kustomize-json-patch
  namespace: vela-system
spec:
  schematic:
    cue:
      template: |
        patch: {
        	spec: {
        		patchesJson6902: parameter.patchesJson
        	}
        }

        parameter: {
        	// +usage=A list of JSON6902 patch.
        	patchesJson: [...#jsonPatchItem]
        }

        // +usage=Contains a JSON6902 patch
        #jsonPatchItem: {
        	target: #selector
        	patch: [...{
        		// +usage=operation to perform
        		op: string | "add" | "remove" | "replace" | "move" | "copy" | "test"
        		// +usage=operate path e.g. /foo/bar
        		path: string
        		// +usage=specify source path when op is copy/move
        		from?:  string
        		// +usage=specify opraation value when op is test/add/replace
        		value?: string
        	}]
        }

        // +usage=Selector specifies a set of resources
        #selector: {
        	group?:              string
        	version?:            string
        	kind?:               string
        	namespace?:          string
        	name?:               string
        	annotationSelector?: string
        	labelSelector?:      string
        }
