Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0dd2305
Update catalog-queries.md (#1385)
m1kola Oct 17, 2024
79f42d5
Address goreleaser deprecated flags (#1386)
perdasilva Oct 17, 2024
8ae6ca0
🌱 Use catalog availability (#1359)
bentito Oct 17, 2024
3083879
:seedling: Bump mkdocs-material from 9.5.40 to 9.5.41 (#1381)
dependabot[bot] Oct 17, 2024
33dc638
Merge branch 'main' into synchronize
Oct 18, 2024
ed4d16d
UPSTREAM: <carry>: Add OpenShift specific files
dtfranz Oct 26, 2023
4bb4ca8
UPSTREAM: <carry>: Drop commitchecker
awgreene Nov 3, 2023
9727356
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Dec 16, 2023
a4bc97d
UPSTREAM: <carry>: update owners
Mar 27, 2024
1fd1b29
UPSTREAM: <carry>: Add pointer to tooling README
bentito Apr 1, 2024
351fbe6
UPSTREAM: <carry>: Disable Validating Admission Policy APIs downstream
Apr 26, 2024
7aa1fa9
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Mar 27, 2024
0dfc437
UPSTREAM: <carry>: Enable Validating Admission Policy APIs downstream
Apr 30, 2024
914f009
UPSTREAM: <carry>: manifests: set required-scc for openshift workloads
liouk May 2, 2024
1d5b91b
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
May 25, 2024
6a40484
UPSTREAM: <carry>: add everettraven to approvers+reviewers
everettraven Jun 24, 2024
d0e44d3
UPSTREAM: <carry>: add openshift kustomize overlay
everettraven Jul 9, 2024
79a9267
UPSTREAM: <carry>: Add tmshort to approvers
tmshort Sep 11, 2024
3592af8
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Sep 18, 2024
2bb4a27
UPSTREAM: <carry>: Properly copy and call kustomize
tmshort Sep 23, 2024
bbc76f5
UPSTREAM: <carry>: manifests: add hostPath mount for /etc/containers
joelanford Sep 20, 2024
3e8ff2e
UPSTREAM: <carry>: Add test-e2e target for downstream Makefile to be …
dtfranz Sep 26, 2024
f953cbe
UPSTREAM: <carry>: Add downstream verify makefile target
dtfranz Sep 27, 2024
c77d51c
UPSTREAM: <carry>: openshift: template log verbosity to be managed by…
joelanford Sep 28, 2024
e3d6679
UPSTREAM: <carry>: Add global-pull-secret flag
Oct 8, 2024
143d521
UPSTREAM: <drop>: go mod vendor
Oct 18, 2024
87c619f
UPSTREAM: <drop>: remove upstream GitHub configuration
Oct 18, 2024
dc213b3
UPSTREAM: <drop>: configure the commit-checker
Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commitchecker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
expectedMergeBase: 8e0efaa757200f136f533b0b05b27ebc10686575
expectedMergeBase: 30838799bbe2fd9bce61a359a291d653a1990c90
upstreamBranch: main
upstreamOrg: operator-framework
upstreamRepo: operator-controller
1 change: 1 addition & 0 deletions docs/api-reference/catalogd-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ _Appears in:_
| --- | --- | --- | --- |
| `source` _[CatalogSource](#catalogsource)_ | source is a required field that allows the user to define the source of a Catalog that contains catalog metadata in the File-Based Catalog (FBC) format.<br /><br />Below is a minimal example of a ClusterCatalogSpec that sources a catalog from an image:<br /><br /> source:<br /> type: Image<br /> image:<br /> ref: quay.io/operatorhubio/catalog:latest<br /><br />For more information on FBC, see https://olm.operatorframework.io/docs/reference/file-based-catalogs/#docs | | |
| `priority` _integer_ | priority is an optional field that allows the user to define a priority for a ClusterCatalog.<br />A ClusterCatalog's priority is used by clients as a tie-breaker between ClusterCatalogs that meet the client's requirements.<br />For example, in the case where multiple ClusterCatalogs provide the same bundle.<br />A higher number means higher priority. Negative numbers are also accepted.<br />When omitted, the default priority is 0. | 0 | |
| `availability` _string_ | Availability is an optional field that allows users to define whether the ClusterCatalog is utilized by the operator-controller.<br /><br />Allowed values are : ["Enabled", "Disabled"].<br />If set to "Enabled", the catalog will be used for updates, serving contents, and package installations.<br /><br />If set to "Disabled", catalogd will stop serving the catalog and the cached data will be removed.<br /><br />If unspecified, the default value is "Enabled" | Enabled | Enum: [Disabled Enabled] <br /> |


#### ClusterCatalogStatus
Expand Down
2 changes: 1 addition & 1 deletion docs/howto/catalog-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ curl -k https://localhost:8443/catalogs/operatorhubio/all.json | <query>
Available packages in a catalog
:
``` terminal
jq -s '.[] | select( .schema == "olm.package")
jq -s '.[] | select( .schema == "olm.package")'
```

Packages that support `AllNamespaces` install mode and do not use webhooks
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/onsi/gomega v1.34.2
github.com/opencontainers/go-digest v1.0.0
github.com/operator-framework/api v0.27.0
github.com/operator-framework/catalogd v0.32.0
github.com/operator-framework/catalogd v0.33.0
github.com/operator-framework/helm-operator-plugins v0.5.0
github.com/operator-framework/operator-registry v1.47.0
github.com/spf13/pflag v1.0.5
Expand Down Expand Up @@ -179,7 +179,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/proglottis/gpgme v0.1.3 // indirect
github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand Down Expand Up @@ -251,5 +251,3 @@ require (
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace github.com/operator-framework/catalogd => github.com/openshift/operator-framework-catalogd v0.0.0-20241016150055-953b8f848c9f
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,10 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11 h1:eTNDkNRNV5lZvUbVM9Nop0lBcljSnA8rZX6yQPZ0ZnU=
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11/go.mod h1:EmVJt97N+pfWFsli/ipXTBZqSG5F5KGQhm3c3IsGq1o=
github.com/openshift/operator-framework-catalogd v0.0.0-20241016150055-953b8f848c9f h1:Sz/vgzXZVyH0tD/4qk88WWcn8suDYqEoccUedh+PMis=
github.com/openshift/operator-framework-catalogd v0.0.0-20241016150055-953b8f848c9f/go.mod h1:FrFSCwRXr4aPslcXIv48dan5AdM37k/B9tK/RpdvZCU=
github.com/operator-framework/api v0.27.0 h1:OrVaGKZJvbZo58HTv2guz7aURkhVKYhFqZ/6VpifiXI=
github.com/operator-framework/api v0.27.0/go.mod h1:lg2Xx+S8NQWGYlEOvFwQvH46E5EK5IrAIL7HWfAhciM=
github.com/operator-framework/catalogd v0.33.0 h1:hnLIFykO1FkjOAUFRPuYRIHQTE0oBF9jkGmWjKhxniQ=
github.com/operator-framework/catalogd v0.33.0/go.mod h1:anZurjcFMBvbkuyqlJ98v9z+yjniPKqmhlyitk9DuBQ=
github.com/operator-framework/helm-operator-plugins v0.5.0 h1:qph2OoECcI9mpuUBtOsWOMgvpx52mPTTSvzVxICsT04=
github.com/operator-framework/helm-operator-plugins v0.5.0/go.mod h1:yVncrZ/FJNqedMil+055fk6sw8aMKRrget/AqGM0ig0=
github.com/operator-framework/operator-lib v0.15.0 h1:0QeRM4PMtThqINpcFGCEBnIV3Z8u7/8fYLEx6mUtdcM=
Expand Down Expand Up @@ -569,8 +569,8 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down
20 changes: 19 additions & 1 deletion internal/resolve/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"

catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
"github.com/operator-framework/operator-registry/alpha/declcfg"
Expand Down Expand Up @@ -231,20 +232,37 @@ func isDeprecated(bundle declcfg.Bundle, deprecation *declcfg.Deprecation) bool

type CatalogWalkFunc func(context.Context, *catalogd.ClusterCatalog, *declcfg.DeclarativeConfig, error) error

func CatalogWalker(listCatalogs func(context.Context, ...client.ListOption) ([]catalogd.ClusterCatalog, error), getPackage func(context.Context, *catalogd.ClusterCatalog, string) (*declcfg.DeclarativeConfig, error)) func(ctx context.Context, packageName string, f CatalogWalkFunc, catalogListOpts ...client.ListOption) error {
func CatalogWalker(
listCatalogs func(context.Context, ...client.ListOption) ([]catalogd.ClusterCatalog, error),
getPackage func(context.Context, *catalogd.ClusterCatalog, string) (*declcfg.DeclarativeConfig, error),
) func(ctx context.Context, packageName string, f CatalogWalkFunc, catalogListOpts ...client.ListOption) error {
return func(ctx context.Context, packageName string, f CatalogWalkFunc, catalogListOpts ...client.ListOption) error {
l := log.FromContext(ctx)
catalogs, err := listCatalogs(ctx, catalogListOpts...)
if err != nil {
return fmt.Errorf("error listing catalogs: %w", err)
}

// Remove disabled catalogs from consideration
catalogs = slices.DeleteFunc(catalogs, func(c catalogd.ClusterCatalog) bool {
if c.Spec.Availability == "Disabled" {
l.Info("excluding ClusterCatalog from resolution process since it is disabled", "catalog", c.Name)
return true
}
return false
})

for i := range catalogs {
cat := &catalogs[i]

// process enabled catalogs
fbc, fbcErr := getPackage(ctx, cat, packageName)

if walkErr := f(ctx, cat, fbc, fbcErr); walkErr != nil {
return walkErr
}
}

return nil
}
}
72 changes: 72 additions & 0 deletions internal/resolve/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,75 @@ func TestMultipleChannels(t *testing.T) {
assert.Equal(t, bsemver.MustParse("2.0.0"), *gotVersion)
assert.Equal(t, ptr.To(packageDeprecation(pkgName)), gotDeprecation)
}

func TestAllCatalogsDisabled(t *testing.T) {
pkgName := randPkg()
listCatalogs := func(ctx context.Context, options ...client.ListOption) ([]catalogd.ClusterCatalog, error) {
return []catalogd.ClusterCatalog{
{
Spec: catalogd.ClusterCatalogSpec{
Availability: "Disabled",
},
},
{
Spec: catalogd.ClusterCatalogSpec{
Availability: "Disabled",
},
},
}, nil
}

getPackage := func(ctx context.Context, cat *catalogd.ClusterCatalog, packageName string) (*declcfg.DeclarativeConfig, error) {
panic("getPackage should never be called when all catalogs are disabled")
}

r := CatalogResolver{
WalkCatalogsFunc: CatalogWalker(listCatalogs, getPackage),
}

ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided)
_, _, _, err := r.Resolve(context.Background(), ce, nil)
require.Error(t, err)
assert.Contains(t, err.Error(), "no bundles found for package")
}

func TestSomeCatalogsDisabled(t *testing.T) {
pkgName := randPkg()
listCatalogs := func(ctx context.Context, options ...client.ListOption) ([]catalogd.ClusterCatalog, error) {
return []catalogd.ClusterCatalog{
{
ObjectMeta: metav1.ObjectMeta{
Name: "enabledCatalog",
},
Spec: catalogd.ClusterCatalogSpec{
Priority: 1, // Higher priority
Availability: "Enabled",
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "disabledCatalog",
},
Spec: catalogd.ClusterCatalogSpec{
Priority: 0, // Lower priority (but disabled)
Availability: "Disabled",
},
},
}, nil
}

getPackage := func(ctx context.Context, cat *catalogd.ClusterCatalog, packageName string) (*declcfg.DeclarativeConfig, error) {
// Only enabled catalog should be processed
return genPackage(pkgName), nil
}

r := CatalogResolver{
WalkCatalogsFunc: CatalogWalker(listCatalogs, getPackage),
}

ce := buildFooClusterExtension(pkgName, []string{}, ">=1.0.0", ocv1alpha1.UpgradeConstraintPolicyCatalogProvided)
gotBundle, gotVersion, _, err := r.Resolve(context.Background(), ce, nil)
require.NoError(t, err)
require.NotNil(t, gotBundle)
require.Equal(t, bsemver.MustParse("3.0.0"), *gotVersion)
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ markdown2==2.5.1
MarkupSafe==2.1.5
mergedeep==1.3.4
mkdocs==1.6.1
mkdocs-material==9.5.40
mkdocs-material==9.5.41
mkdocs-material-extensions==1.3.1
packaging==24.1
paginate==0.5.7
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ github.com/operator-framework/api/pkg/validation
github.com/operator-framework/api/pkg/validation/errors
github.com/operator-framework/api/pkg/validation/interfaces
github.com/operator-framework/api/pkg/validation/internal
# github.com/operator-framework/catalogd v0.32.0 => github.com/openshift/operator-framework-catalogd v0.0.0-20241016150055-953b8f848c9f
# github.com/operator-framework/catalogd v0.33.0
## explicit; go 1.22.5
github.com/operator-framework/catalogd/api/core/v1alpha1
# github.com/operator-framework/helm-operator-plugins v0.5.0
Expand Down Expand Up @@ -858,7 +858,7 @@ github.com/pmezard/go-difflib/difflib
# github.com/proglottis/gpgme v0.1.3
## explicit; go 1.11
github.com/proglottis/gpgme
# github.com/prometheus/client_golang v1.20.4
# github.com/prometheus/client_golang v1.20.5
## explicit; go 1.20
github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil
github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header
Expand Down Expand Up @@ -2103,4 +2103,3 @@ sigs.k8s.io/structured-merge-diff/v4/value
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
sigs.k8s.io/yaml/goyaml.v3
# github.com/operator-framework/catalogd => github.com/openshift/operator-framework-catalogd v0.0.0-20241016150055-953b8f848c9f