diff --git a/channels/pkg/api/channel.go b/channels/pkg/api/channel.go index 97c0850815..61657f5ea8 100644 --- a/channels/pkg/api/channel.go +++ b/channels/pkg/api/channel.go @@ -70,18 +70,32 @@ type AddonSpec struct { Version string `json:"version,omitempty"` + // PruneSpec specifies how old objects should be removed (pruned). Prune *PruneSpec `json:"prune,omitempty"` } +// PruneSpec specifies how old objects should be removed (pruned). type PruneSpec struct { + // Kinds specifies the objects to be pruned, by Kind. Kinds []PruneKindSpec `json:"kinds,omitempty"` } +// PruneKindSpec specifies pruning for a particular Kind of object. type PruneKindSpec struct { - Group string `json:"group,omitempty"` - Kind string `json:"kind,omitempty"` - Namespaces []string `json:"namespaces,omitempty"` - LabelSelector string `json:"labelSelector,omitempty"` + // Group specifies the object Group to be pruned (required). + Group string `json:"group,omitempty"` + // Kind specifies the object Kind to be pruned (required). + Kind string `json:"kind,omitempty"` + + // Namespaces limits pruning only to objects in certain namespaces. + Namespaces []string `json:"namespaces,omitempty"` + + // LabelSelector limits pruning only to objects matching the specified labels. + LabelSelector string `json:"labelSelector,omitempty"` + + // FieldSelector allows pruning only of objects matching the field selector. + // (This isn't currently used, but adding it now lets us start without worrying about version skew) + FieldSelector string `json:"fieldSelector,omitempty"` } func (a *Addons) Verify() error { diff --git a/channels/pkg/channels/prune.go b/channels/pkg/channels/prune.go index 5e6bd404a3..33c35bb4d6 100644 --- a/channels/pkg/channels/prune.go +++ b/channels/pkg/channels/prune.go @@ -83,6 +83,7 @@ func (p *Pruner) pruneObjectsOfKind(ctx context.Context, gk schema.GroupKind, sp var listOptions v1.ListOptions listOptions.LabelSelector = spec.LabelSelector + listOptions.FieldSelector = spec.FieldSelector baseResource := p.Client.Resource(gvr) if len(spec.Namespaces) == 0 {