Skip to content

add olm.search.metadata property and FBC filtering library #1705

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joelanford
Copy link
Member

@joelanford joelanford commented Jun 25, 2025

Signed-off-by: Joe Lanford [email protected]

Caution

The code in this PR was almost entirely generated by Cursor, where I was acting as a supervisor and prodding the agent to make changes necessary to fulfill my design intent. I manually changed agent-generated code in a few places in order to help instruct the agent of my intentions. The PR description was also authored by Cursor. I reviewed the PR description before submitting. I have not yet fully reviewed the code.

Description

This PR introduces a new olm.search.metadata property type that enables operators to include searchable metadata in their bundles. It also provides a filtering library to query File-Based Catalogs (FBC) based on this metadata.

Key Features

Search Metadata Property Type

  • Supports three metadata types: String, ListString, and MapStringBoolean
  • Includes comprehensive validation with duplicate name prevention
  • Integrates seamlessly with existing property system

Filtering Library (alpha/declcfg/filter)

  • Flexible filtering API with HasAny() and HasAll() criteria
  • Configurable match logic (All, Any, or custom functions)
  • Works with declcfg.Meta objects for FBC integration
  • Type-safe property extraction and validation

Example Usage

package main

import (
	"encoding/json"
	"fmt"

	"github.com/operator-framework/operator-registry/alpha/declcfg"
	"github.com/operator-framework/operator-registry/alpha/declcfg/filter"
	"github.com/operator-framework/operator-registry/alpha/property"
)

func main() {
	// Create search metadata property
	seaerchMetadata := property.SearchMetadata{
		{Name: "Maturity", Type: "String", Value: "stable"},
		{Name: "Keywords", Type: "ListString", Value: []string{"database", "storage", "sql"}},
		{Name: "Features", Type: "MapStringBoolean", Value: map[string]bool{"backup": true, "monitoring": false}},
	}

	// Create a Meta object with properties
	properties := []property.Property{
		property.MustBuildSearchMetadata(searchMetadata),
		// ... other properties like packages, GVKs, etc.
	}

	// Create the Meta blob
	metaBlob := struct {
		Properties []property.Property `json:"properties,omitempty"`
	}{
		Properties: properties,
	}

	blobBytes, _ := json.Marshal(metaBlob)

	meta := declcfg.Meta{
		Schema: "olm.bundle",
		Name:   "my-operator.v1.0.0",
		Blob:   json.RawMessage(blobBytes),
	}

	// Create and use filter
	f := filter.New(filter.All). // All individual filter criteria must match
					HasAny("Maturity", "stable", "alpha"). // The "Maturity" filter must match "stable" or "alpha"
					HasAll("Keywords", "database", "sql")  // The "Keywords" filter must match "database" and "sql"

	matches, err := f.MatchMeta(meta)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Meta matches filter: %t\n", matches) // Output: Meta matches filter: true
}

Motivation

This enables rich search and discovery capabilities for operator catalogs, allowing users to find operators based on maturity level, feature sets, keywords, and other custom metadata. The implementation provides a foundation for enhanced catalog browsing and filtering experiences in operator marketplaces and CLI tools.


Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

@openshift-ci openshift-ci bot requested review from ankitathomas and oceanc80 June 25, 2025 21:26
Copy link
Contributor

openshift-ci bot commented Jun 25, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign oceanc80 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@joelanford joelanford changed the title add olm.filterMetadata property and FBC filtering library add olm.search.metadata property and FBC filtering library Jun 26, 2025
@joelanford joelanford marked this pull request as draft June 26, 2025 11:51
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 26, 2025
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 77.24359% with 71 lines in your changes missing coverage. Please review.

Project coverage is 55.53%. Comparing base (ef3bfdf) to head (845e150).
Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
alpha/declcfg/filter/tryit/main.go 0.00% 38 Missing ⚠️
alpha/declcfg/filter/filter.go 80.45% 19 Missing and 7 partials ⚠️
alpha/property/property.go 94.96% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1705      +/-   ##
==========================================
+ Coverage   55.17%   55.53%   +0.36%     
==========================================
  Files         136      138       +2     
  Lines       15918    16187     +269     
==========================================
+ Hits         8783     8990     +207     
- Misses       5982     6036      +54     
- Partials     1153     1161       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joelanford
Copy link
Member Author

While this may be useful on its own, it actually grows the size of the existing blobs, which runs counter to a competing desire to decompose the data model. So I'm not sure if we should go quite in this direction.

A couple of other options:

  1. Move the search metadata to its own schema and have a field for the referent.
  2. Stop trying to decompose the data model: instead build query APIs that make it easy to return just client-requested subfields.

Relates to #1679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant