Skip to content

Commit bfa0435

Browse files
authored
updated to use catalogd v0.34.0 (#1396)
see [catalogd v0.34.0 release notes](https://github.com/operator-framework/catalogd/releases/tag/v0.34.0) for more details Signed-off-by: Jordan Keister <[email protected]>
1 parent 8a0f25d commit bfa0435

File tree

10 files changed

+63
-25
lines changed

10 files changed

+63
-25
lines changed

docs/api-reference/catalogd-api-reference.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,26 @@ _Appears in:_
116116
| --- | --- | --- | --- |
117117
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#condition-v1-meta) array_ | conditions is a representation of the current state for this ClusterCatalog.<br />The status is represented by a set of "conditions".<br /><br />Each condition is generally structured in the following format:<br /> - Type: a string representation of the condition type. More or less the condition "name".<br /> - Status: a string representation of the state of the condition. Can be one of ["True", "False", "Unknown"].<br /> - Reason: a string representation of the reason for the current state of the condition. Typically useful for building automation around particular Type+Reason combinations.<br /> - Message: a human-readable message that further elaborates on the state of the condition.<br /><br />The current set of condition types are:<br /> - "Serving", which represents whether or not the contents of the catalog are being served via the HTTP(S) web server.<br /> - "Progressing", which represents whether or not the ClusterCatalog is progressing towards a new state.<br /><br />The current set of reasons are:<br /> - "Succeeded", this reason is set on the "Progressing" condition when progressing to a new state is successful.<br /> - "Blocked", this reason is set on the "Progressing" condition when the ClusterCatalog controller has encountered an error that requires manual intervention for recovery.<br /> - "Retrying", this reason is set on the "Progressing" condition when the ClusterCatalog controller has encountered an error that might be resolvable on subsequent reconciliation attempts.<br /> - "Available", this reason is set on the "Serving" condition when the contents of the ClusterCatalog are being served via an endpoint on the HTTP(S) web server.<br /> - "Unavailable", this reason is set on the "Serving" condition when there is not an endpoint on the HTTP(S) web server that is serving the contents of the ClusterCatalog. | | |
118118
| `resolvedSource` _[ResolvedCatalogSource](#resolvedcatalogsource)_ | resolvedSource contains information about the resolved source based on the source type.<br /><br />Below is an example of a resolved source for an image source:<br />resolvedSource:<br /><br /> image:<br /> lastSuccessfulPollAttempt: "2024-09-10T12:22:13Z"<br /> ref: quay.io/operatorhubio/catalog@sha256:c7392b4be033da629f9d665fec30f6901de51ce3adebeff0af579f311ee5cf1b<br /> type: Image | | |
119-
| `contentURL` _string_ | contentURL is a cluster-internal URL from which on-cluster components<br />can read the content of a catalog | | |
119+
| `urls` _[ClusterCatalogURLs](#clustercatalogurls)_ | urls contains the URLs that can be used to access the catalog. | | |
120120
| `lastUnpacked` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#time-v1-meta)_ | lastUnpacked represents the time when the<br />ClusterCatalog object was last unpacked successfully. | | |
121121

122122

123+
#### ClusterCatalogURLs
124+
125+
126+
127+
ClusterCatalogURLs contains the URLs that can be used to access the catalog.
128+
129+
130+
131+
_Appears in:_
132+
- [ClusterCatalogStatus](#clustercatalogstatus)
133+
134+
| Field | Description | Default | Validation |
135+
| --- | --- | --- | --- |
136+
| `base` _string_ | base is a required cluster-internal URL which provides API access for this ClusterCatalog.<br />A suffix API access path can be added to retrieve catalog data for the ClusterCatalog.<br />Currently, a 'v1' API access provides complete FBC retrival via the path "/api/v1/all", with the general form `\{base\}/api/v1/all`. | | Required: \{\} <br /> |
137+
138+
123139
#### ImageSource
124140

125141

docs/api-reference/catalogd-webserver.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
[Catalogd](https://github.com/operator-framework/catalogd), the OLM v1 component for making catalog contents available on cluster, includes
44
a web server that serves catalog contents to clients via an HTTP(S) endpoint.
55

6-
The endpoint to retrieve this information is provided in the `.status.contentURL` of a `ClusterCatalog` resource.
7-
As an example:
6+
The endpoint to retrieve this information can be composed from the `.status.urls.base` of a `ClusterCatalog` resource with the selected access API path.
7+
As an example, to access the full FBC via the v1 API endpoint (indicated by path `api/v1/all`) where `.status.urls.base` is
88

99
```yaml
10-
contentURL: https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio/all.json
10+
urls:
11+
base: https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio
1112
```
1213
14+
the URL to access the service would be `https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio/api/v1/all`
15+
1316
!!! note
1417

15-
The value of the `.status.contentURL` field in a `ClusterCatalog` resource is an arbitrary string value and can change at any time.
16-
While there are no guarantees on the exact value of this field, it will always be a URL that resolves successfully for clients using
17-
it to make a request from within the cluster.
18+
The values of the `.status.urls` field in a `ClusterCatalog` resource are arbitrary string values and can change at any time.
19+
While there are no guarantees on the exact value of this field, it will always contain catalog-specific API endpoints for use
20+
by clients to make a request from within the cluster.
1821

1922
## Interacting With the Server
2023

docs/howto/catalog-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The following examples will show this default behavior, but for simplicity's sak
77
You can use the `curl` command with `jq` to query catalogs that are installed on your cluster.
88

99
``` terminal title="Query syntax"
10-
curl -k https://localhost:8443/catalogs/operatorhubio/all.json | <query>
10+
curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | <query>
1111
```
1212

1313
## Package queries

docs/tutorials/add-catalog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ This catalog is distributed as an image [quay.io/operatorhubio/catalog](https://
126126
Reason: Available
127127
Status: True
128128
Type: Serving
129-
Content URL: https://catalogd-server.olmv1-system.svc/catalogs/operatorhubio/all.json
129+
URLs:
130+
Base: https://catalogd-server.olmv1-system.svc/catalogs/operatorhubio
130131
Last Unpacked: 2024-03-12T19:35:34Z
131132
Resolved Source:
132133
Image:

docs/tutorials/explore-available-content.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ The following examples will show this default behavior, but for simplicity's sak
2424
kubectl -n olmv1-system port-forward svc/catalogd-service 8443:443
2525
```
2626
27-
2. Return a list of all the extensions in a catalog:
27+
2. Return a list of all the extensions in a catalog via the v1 API endpoint:
2828
``` terminal
29-
curl -k https://localhost:8443/catalogs/operatorhubio/all.json | jq -s '.[] | select(.schema == "olm.package") | .name'
29+
curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | jq -s '.[] | select(.schema == "olm.package") | .name'
3030
```
3131
3232
??? success
@@ -96,7 +96,7 @@ The following examples will show this default behavior, but for simplicity's sak
9696
* Return list of packages that support `AllNamespaces` install mode and do not use webhooks:
9797
9898
``` terminal
99-
curl -k https://localhost:8443/catalogs/operatorhubio/all.json | jq -c 'select(.schema == "olm.bundle") | {"package":.package, "version":.properties[] | select(.type == "olm.bundle.object").value.data | @base64d | fromjson | select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | select(.type == "AllNamespaces" and .supported == true) != null) and .spec.webhookdefinitions == null).spec.version}'
99+
curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | jq -c 'select(.schema == "olm.bundle") | {"package":.package, "version":.properties[] | select(.type == "olm.bundle.object").value.data | @base64d | fromjson | select(.kind == "ClusterServiceVersion" and (.spec.installModes[] | select(.type == "AllNamespaces" and .supported == true) != null) and .spec.webhookdefinitions == null).spec.version}'
100100
```
101101
102102
??? success
@@ -127,7 +127,7 @@ The following examples will show this default behavior, but for simplicity's sak
127127
3. Inspect the contents of an extension's metadata:
128128
129129
``` terminal
130-
curl -k https://localhost:8443/catalogs/operatorhubio/all.json | jq -s '.[] | select( .schema == "olm.package") | select( .name == "<package_name>")'
130+
curl -k https://localhost:8443/catalogs/operatorhubio/api/v1/all | jq -s '.[] | select( .schema == "olm.package") | select( .name == "<package_name>")'
131131
```
132132
133133
`package_name`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/onsi/gomega v1.34.2
1818
github.com/opencontainers/go-digest v1.0.0
1919
github.com/operator-framework/api v0.27.0
20-
github.com/operator-framework/catalogd v0.33.0
20+
github.com/operator-framework/catalogd v0.34.0
2121
github.com/operator-framework/helm-operator-plugins v0.5.0
2222
github.com/operator-framework/operator-registry v1.47.0
2323
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11 h1:eT
535535
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11/go.mod h1:EmVJt97N+pfWFsli/ipXTBZqSG5F5KGQhm3c3IsGq1o=
536536
github.com/operator-framework/api v0.27.0 h1:OrVaGKZJvbZo58HTv2guz7aURkhVKYhFqZ/6VpifiXI=
537537
github.com/operator-framework/api v0.27.0/go.mod h1:lg2Xx+S8NQWGYlEOvFwQvH46E5EK5IrAIL7HWfAhciM=
538-
github.com/operator-framework/catalogd v0.33.0 h1:hnLIFykO1FkjOAUFRPuYRIHQTE0oBF9jkGmWjKhxniQ=
539-
github.com/operator-framework/catalogd v0.33.0/go.mod h1:anZurjcFMBvbkuyqlJ98v9z+yjniPKqmhlyitk9DuBQ=
538+
github.com/operator-framework/catalogd v0.34.0 h1:zzCUTVrRJ4oCnjvAdairEWbUejLUnYRVsvAyhfREpyU=
539+
github.com/operator-framework/catalogd v0.34.0/go.mod h1:anZurjcFMBvbkuyqlJ98v9z+yjniPKqmhlyitk9DuBQ=
540540
github.com/operator-framework/helm-operator-plugins v0.5.0 h1:qph2OoECcI9mpuUBtOsWOMgvpx52mPTTSvzVxICsT04=
541541
github.com/operator-framework/helm-operator-plugins v0.5.0/go.mod h1:yVncrZ/FJNqedMil+055fk6sw8aMKRrget/AqGM0ig0=
542542
github.com/operator-framework/operator-lib v0.15.0 h1:0QeRM4PMtThqINpcFGCEBnIV3Z8u7/8fYLEx6mUtdcM=

hack/tools/catalogs/download-catalog

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ if [ "$UNPACKED_CONDITION" != "True" ]; then
5353
exit 1
5454
fi
5555

56-
# Get the contentURL
57-
CONTENT_URL=$(echo "$CLUSTER_CATALOG" | jq -r '.status.contentURL')
58-
if [ -z "$CONTENT_URL" ]; then
59-
echo "Content URL not found for ClusterCatalog $CATALOG_NAME."
56+
# Construct the API URL from the ClusterCatalog status
57+
CATALOG_API_URL=$(echo "$CLUSTER_CATALOG" | jq -r '.status.urls.base')
58+
if [ -z "$CATALOG_API_URL" ]; then
59+
echo "ClusterCatalog $CATALOG_NAME does not express API endpoint in '.status.urls.base'."
6060
exit 1
6161
fi
62+
# Assemble the v1 API URL from the base endpoint
63+
CATALOG_CONTENT_URL="${CATALOG_API_URL}/api/v1/all"
6264

6365
# Start port forwarding
6466
echo "Starting kubectl port-forward to $CATALOGD_SERVICE_NAME on port $CATALOGD_LOCAL_SERVICE_PORT..."
@@ -77,9 +79,9 @@ while ! curl -s "http://localhost:${CATALOGD_LOCAL_SERVICE_PORT}" >/dev/null; do
7779
sleep 1
7880
done
7981

80-
# Modify the contentURL to hit localhost:<port>
81-
LOCAL_CONTENT_URL=${CONTENT_URL//https:\/\/$CATALOGD_SERVICE_NAME.$CATALOGD_CATALOGD_SERVICE_NAMESPACE.svc/https:\/\/localhost:$CATALOGD_LOCAL_SERVICE_PORT}
82-
echo "Found content URL: $CONTENT_URL"
82+
# Modify the catalogd service endpoint URL to hit localhost:<port>
83+
LOCAL_CONTENT_URL=${CATALOG_CONTENT_URL//https:\/\/$CATALOGD_SERVICE_NAME.$CATALOGD_CATALOGD_SERVICE_NAMESPACE.svc/https:\/\/localhost:$CATALOGD_LOCAL_SERVICE_PORT}
84+
echo "Calculated catalogd API pathcontent URL: $CATALOG_CONTENT_URL"
8385
echo "Using local port: $CATALOGD_LOCAL_SERVICE_PORT"
8486
echo "Using local content URL: $LOCAL_CONTENT_URL"
8587

internal/catalogmetadata/client/client.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"io/fs"
99
"net/http"
10+
"net/url"
1011

1112
"k8s.io/apimachinery/pkg/api/meta"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -15,6 +16,10 @@ import (
1516
"github.com/operator-framework/operator-registry/alpha/declcfg"
1617
)
1718

19+
const (
20+
clusterCatalogV1ApiURL = "api/v1/all"
21+
)
22+
1823
type Cache interface {
1924
// Get returns cache for a specified catalog name and version (resolvedRef).
2025
//
@@ -113,7 +118,16 @@ func (c *Client) PopulateCache(ctx context.Context, catalog *catalogd.ClusterCat
113118
}
114119

115120
func (c *Client) doRequest(ctx context.Context, catalog *catalogd.ClusterCatalog) (*http.Response, error) {
116-
req, err := http.NewRequestWithContext(ctx, http.MethodGet, catalog.Status.ContentURL, nil)
121+
if catalog.Status.URLs == nil {
122+
return nil, fmt.Errorf("error: catalog %q has a nil status.urls value", catalog.Name)
123+
}
124+
125+
catalogdURL, err := url.JoinPath(catalog.Status.URLs.Base, clusterCatalogV1ApiURL)
126+
if err != nil {
127+
return nil, fmt.Errorf("error forming catalogd API endpoint: %v", err)
128+
}
129+
130+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, catalogdURL, nil)
117131
if err != nil {
118132
return nil, fmt.Errorf("error forming request: %v", err)
119133
}

internal/catalogmetadata/client/client_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func defaultCatalog() *catalogd.ClusterCatalog {
2828
ResolvedSource: &catalogd.ResolvedCatalogSource{Image: &catalogd.ResolvedImageSource{
2929
Ref: "fake/catalog@sha256:fakesha",
3030
}},
31-
ContentURL: "https://fake-url.svc.local/all.json",
31+
URLs: &catalogd.ClusterCatalogURLs{
32+
Base: "https://fake-url.svc.local/catalogs/catalog-1",
33+
},
3234
},
3335
}
3436
}

0 commit comments

Comments
 (0)