Skip to content

feature: Add label selector for resources #3410

@mjudeikis

Description

@mjudeikis

Feature Description

Currently in the APIExports resource selector via labels DO NOT WORK.

type PermissionClaim struct {
	GroupResource `json:",inline"`

	// all claims all resources for the given group/resource.
	// This is mutually exclusive with resourceSelector.
	// +optional
	All bool `json:"all,omitempty"`

	// resourceSelector is a list of claimed resource selectors.
	//
	// +optional
	ResourceSelector []ResourceSelector `json:"resourceSelector,omitempty"`

	// This is the identity for a given APIExport that the APIResourceSchema belongs to.
	// The hash can be found on APIExport and APIResourceSchema's status.
	// It will be empty for core types.
	// Note that one must look this up for a particular KCP instance.
	// +optional
	IdentityHash string `json:"identityHash,omitempty"`
}

// +kubebuilder:validation:XValidation:rule="has(self.__namespace__) || has(self.name)",message="at least one field must be set"
type ResourceSelector struct {
	// name of an object within a claimed group/resource.
	// It matches the metadata.name field of the underlying object.
	// If namespace is unset, all objects matching that name will be claimed.
	//
	// +optional
	// +kubebuilder:validation:Pattern="^([a-z0-9][-a-z0-9_.]*)?[a-z0-9]$"
	// +kubebuilder:validation:MaxLength=253
	// +kubebuilder:validation:MinLength=1
	Name string `json:"name,omitempty"`

	// namespace containing the named object. Matches metadata.namespace field.
	// If "name" is unset, all objects from the namespace are being claimed.
	//
	// +optional
	// +kubebuilder:validation:MinLength=1
	Namespace string `json:"namespace,omitempty"`

	//
	// WARNING: If adding new fields, add them to the XValidation check!
	//

Only Name, Namespace exists.

We should add label selector:

  - resource: configMap
    group: core
    verbs: [create, delete, update, list, get]
    selector:
       labelSelector:
         owner: cert-manager.corp.foo 

More info: https://docs.google.com/document/d/1toEU8_tldfc-kIWDgKfROyPVJGhhWDrr2cU0ayRj76I/edit?tab=t.0

Proposed Solution

https://docs.google.com/document/d/1toEU8_tldfc-kIWDgKfROyPVJGhhWDrr2cU0ayRj76I/edit?tab=t.0

Alternative Solutions

No response

Want to contribute?

  • I would like to work on this issue.

Additional Context

No response

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions