Skip to content

Commit e40e797

Browse files
Merge pull request openshift#294 from tmshort/synchronize
NO-ISSUE: Synchronize From Upstream Repositories through PR1871
2 parents 282f56c + 4edaab6 commit e40e797

File tree

376 files changed

+2810
-68594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

376 files changed

+2810
-68594
lines changed

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,9 @@ generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyI
151151
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
152152

153153
.PHONY: verify
154-
verify: tidy fmt generate manifests crd-ref-docs update-k8s-values #HELP Verify all generated code is up-to-date.
154+
verify: tidy fmt generate manifests crd-ref-docs #HELP Verify all generated code is up-to-date.
155155
git diff --exit-code
156156

157-
.PHONY: update-k8s-values # HELP Update PSA labels in config manifests with Kubernetes version
158-
update-k8s-values:
159-
find config -type f -name '*.yaml' -exec \
160-
sed -i.bak -E 's/(pod-security.kubernetes.io\/[a-zA-Z-]+-version:).*/\1 "v$(K8S_VERSION)"/g' {} +;
161-
find config -type f -name '*.yaml.bak' -delete
162-
163157
.PHONY: fix-lint
164158
fix-lint: $(GOLANGCI_LINT) #EXHELP Fix lint issues
165159
$(GOLANGCI_LINT) run --fix --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
@@ -303,10 +297,15 @@ kind-clean: $(KIND) #EXHELP Delete the kind cluster.
303297

304298
#SECTION Build
305299

306-
ifeq ($(origin VERSION), undefined)
300+
# attempt to generate the VERSION attribute for certificates
301+
# fail if it is unset afterwards, since the side effects are indirect
302+
ifeq ($(strip $(VERSION)),)
307303
VERSION := $(shell git describe --tags --always --dirty)
308304
endif
309305
export VERSION
306+
ifeq ($(strip $(VERSION)),)
307+
$(error undefined VERSION; resulting certs will be invalid)
308+
endif
310309

311310
ifeq ($(origin CGO_ENABLED), undefined)
312311
CGO_ENABLED := 0

api/v1/clustercatalog_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ const (
3434

3535
AvailabilityModeAvailable AvailabilityMode = "Available"
3636
AvailabilityModeUnavailable AvailabilityMode = "Unavailable"
37+
38+
// Condition types
39+
TypeServing = "Serving"
40+
41+
// Serving Reasons
42+
ReasonAvailable = "Available"
43+
ReasonUnavailable = "Unavailable"
44+
ReasonUserSpecifiedUnavailable = "UserSpecifiedUnavailable"
3745
)
3846

3947
//+kubebuilder:object:root=true

api/v1/clusterextension_types_test.go

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"go/ast"
66
"go/parser"
77
"go/token"
8-
"io/fs"
98
"strconv"
109
"strings"
1110
"testing"
@@ -52,49 +51,47 @@ func TestClusterExtensionReasonRegistration(t *testing.T) {
5251
}
5352
}
5453

55-
// parseConstants parses the values of the top-level constants in the current
56-
// directory whose names start with the given prefix. When running as part of a
57-
// test, the current directory is the directory of the file that contains the
58-
// test in which this function is called.
54+
// parseConstants parses the values of the top-level constants that start with the given prefix,
55+
// in the files clusterextension_types.go and common_types.go.
5956
func parseConstants(prefix string) ([]string, error) {
6057
fset := token.NewFileSet()
61-
// ParseDir returns a map of package name to package ASTs. An AST is a representation of the source code
62-
// that can be traversed to extract information. The map is keyed by the package name.
63-
pkgs, err := parser.ParseDir(fset, ".", func(info fs.FileInfo) bool {
64-
return !strings.HasSuffix(info.Name(), "_test.go")
65-
}, 0)
66-
if err != nil {
67-
return nil, err
58+
// An AST is a representation of the source code that can be traversed to extract information.
59+
// Converting files to AST representation to extract information.
60+
parseFiles, astFiles := []string{"clusterextension_types.go", "common_types.go"}, []*ast.File{}
61+
for _, file := range parseFiles {
62+
p, err := parser.ParseFile(fset, file, nil, 0)
63+
if err != nil {
64+
return nil, err
65+
}
66+
astFiles = append(astFiles, p)
6867
}
6968

7069
var constValues []string
7170

72-
// Iterate all of the top-level declarations in each package's files,
73-
// looking for constants that start with the prefix. When we find one,
74-
// add its value to the constValues list.
75-
for _, pkg := range pkgs {
76-
for _, f := range pkg.Files {
77-
for _, d := range f.Decls {
78-
genDecl, ok := d.(*ast.GenDecl)
79-
if !ok {
71+
// Iterate all of the top-level declarations in each file, looking
72+
// for constants that start with the prefix. When we find one, add
73+
// its value to the constValues list.
74+
for _, f := range astFiles {
75+
for _, d := range f.Decls {
76+
genDecl, ok := d.(*ast.GenDecl)
77+
if !ok {
78+
continue
79+
}
80+
for _, s := range genDecl.Specs {
81+
valueSpec, ok := s.(*ast.ValueSpec)
82+
if !ok || len(valueSpec.Names) != 1 || valueSpec.Names[0].Obj.Kind != ast.Con || !strings.HasPrefix(valueSpec.Names[0].String(), prefix) {
8083
continue
8184
}
82-
for _, s := range genDecl.Specs {
83-
valueSpec, ok := s.(*ast.ValueSpec)
84-
if !ok || len(valueSpec.Names) != 1 || valueSpec.Names[0].Obj.Kind != ast.Con || !strings.HasPrefix(valueSpec.Names[0].String(), prefix) {
85+
for _, val := range valueSpec.Values {
86+
lit, ok := val.(*ast.BasicLit)
87+
if !ok || lit.Kind != token.STRING {
8588
continue
8689
}
87-
for _, val := range valueSpec.Values {
88-
lit, ok := val.(*ast.BasicLit)
89-
if !ok || lit.Kind != token.STRING {
90-
continue
91-
}
92-
v, err := strconv.Unquote(lit.Value)
93-
if err != nil {
94-
return nil, fmt.Errorf("unquote literal string %s: %v", lit.Value, err)
95-
}
96-
constValues = append(constValues, v)
90+
v, err := strconv.Unquote(lit.Value)
91+
if err != nil {
92+
return nil, fmt.Errorf("unquote literal string %s: %v", lit.Value, err)
9793
}
94+
constValues = append(constValues, v)
9895
}
9996
}
10097
}

api/v1/common_types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1
1919
const (
2020
TypeInstalled = "Installed"
2121
TypeProgressing = "Progressing"
22-
TypeServing = "Serving"
2322

2423
// Progressing reasons
2524
ReasonSucceeded = "Succeeded"
@@ -29,9 +28,4 @@ const (
2928
// Terminal reasons
3029
ReasonDeprecated = "Deprecated"
3130
ReasonFailed = "Failed"
32-
33-
// Serving reasons
34-
ReasonAvailable = "Available"
35-
ReasonUnavailable = "Unavailable"
36-
ReasonUserSpecifiedUnavailable = "UserSpecifiedUnavailable"
3731
)

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: 7fc18c64660c97c70e4c6704147a746f657543f4
1+
expectedMergeBase: ef348ee326375febc7571a4c640646e2f752811c
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

config/base/common/namespace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ metadata:
44
labels:
55
app.kubernetes.io/part-of: olm
66
pod-security.kubernetes.io/enforce: restricted
7-
pod-security.kubernetes.io/enforce-version: "v1.32"
7+
pod-security.kubernetes.io/enforce-version: latest
88
name: system
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Catalogd web server
2+
3+
[Catalogd](https://github.com/operator-framework/operator-controller/tree/main/catalogd), the OLM v1 component for making catalog contents available on cluster, includes
4+
a web server that serves catalog contents to clients via HTTP(S) endpoints.
5+
6+
The endpoints to retrieve information about installable clusterextentions can be composed from the `.status.urls.base` of a `ClusterCatalog` resource with the selected access API path.
7+
8+
Currently, there are two API endpoints:
9+
10+
1. `api/v1/all` endpoint that provides access to the FBC metadata in entirety.
11+
12+
As an example, to access the full FBC via the v1 API endpoint (indicated by path `api/v1/all`) where `.status.urls.base` is
13+
14+
```yaml
15+
urls:
16+
base: https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio
17+
```
18+
19+
the URL to access the service would be `https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio/api/v1/all`
20+
21+
2. `api/v1/metas` endpoint that allows clients to retrieve filtered portions of the FBC.
22+
23+
The metas endpoint accepts parameters which are one of the sub-types of the `Meta` [definition](https://github.com/operator-framework/operator-registry/blob/e15668c933c03e229b6c80025fdadb040ab834e0/alpha/declcfg/declcfg.go#L111-L114), following the pattern `/api/v1/metas?<parameter>[&<parameter>...]`.
24+
25+
As an example, to access only the [package schema](https://olm.operatorframework.io/docs/reference/file-based-catalogs/#olmpackage-1) blobs of the FBC via the `api/v1/metas` endpoint where `.status.urls.base` is
26+
27+
```yaml
28+
urls:
29+
base: https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio
30+
```
31+
32+
the URL to access the service would be `https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio/api/v1/metas?schema=olm.package`
33+
34+
For more examples of valid queries that can be made to the `api/v1/metas` service endpoint, please see [Catalog Queries](../howto/catalog-queries.md).
35+
36+
!!! note
37+
38+
The values of the `.status.urls` field in a `ClusterCatalog` resource are arbitrary string values and can change at any time.
39+
While there are no guarantees on the exact value of this field, it will always contain catalog-specific API endpoints for use
40+
by clients to make a request from within the cluster.
41+
42+
## Interacting With the Server
43+
44+
### Supported HTTP Methods
45+
46+
The HTTP request methods supported by the catalogd web server are:
47+
48+
- [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET)
49+
- [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD)
50+
51+
### Response Format
52+
53+
Responses are encoded as a [JSON Lines](https://jsonlines.org/) stream of [File-Based Catalog](https://olm.operatorframework.io/docs/reference/file-based-catalogs) (FBC) [Meta](https://olm.operatorframework.io/docs/reference/file-based-catalogs/#schema) objects delimited by newlines.
54+
55+
??? example "Example JSON-encoded FBC snippet"
56+
57+
```json
58+
{
59+
"schema": "olm.package",
60+
"name": "cockroachdb",
61+
"defaultChannel": "stable-v6.x",
62+
}
63+
{
64+
"schema": "olm.channel",
65+
"name": "stable-v6.x",
66+
"package": "cockroachdb",
67+
"entries": [
68+
{
69+
"name": "cockroachdb.v6.0.0",
70+
"skipRange": "<6.0.0"
71+
}
72+
]
73+
}
74+
{
75+
"schema": "olm.bundle",
76+
"name": "cockroachdb.v6.0.0",
77+
"package": "cockroachdb",
78+
"image": "quay.io/openshift-community-operators/cockroachdb@sha256:d3016b1507515fc7712f9c47fd9082baf9ccb070aaab58ed0ef6e5abdedde8ba",
79+
"properties": [
80+
{
81+
"type": "olm.package",
82+
"value": {
83+
"packageName": "cockroachdb",
84+
"version": "6.0.0"
85+
}
86+
},
87+
],
88+
}
89+
```
90+
91+
Corresponding JSON lines response:
92+
```jsonlines
93+
{"schema":"olm.package","name":"cockroachdb","defaultChannel":"stable-v6.x"}
94+
{"schema":"olm.channel","name":"stable-v6.x","package":"cockroachdb","entries":[{"name":"cockroachdb.v6.0.0","skipRange":"<6.0.0"}]}
95+
{"schema":"olm.bundle","name":"cockroachdb.v6.0.0","package":"cockroachdb","image":"quay.io/openshift-community-operators/cockroachdb@sha256:d3016b1507515fc7712f9c47fd9082baf9ccb070aaab58ed0ef6e5abdedde8ba","properties":[{"type":"olm.package","value":{"packageName":"cockroachdb","version":"6.0.0"}}]}
96+
```
97+
98+
### Compression Support
99+
100+
The `catalogd` web server supports gzip compression of responses, which can significantly reduce associated network traffic. In order to signal that the client handles compressed responses, the client must include `Accept-Encoding: gzip` as a header in the HTTP request.
101+
102+
The web server will include a `Content-Encoding: gzip` header in compressed responses.
103+
104+
!!! note
105+
106+
Only catalogs whose uncompressed response body would result in a response size greater than 1400 bytes will be compressed.
107+
108+
### Cache Header Support
109+
110+
For clients interested in caching the information returned from the `catalogd` web server, the `Last-Modified` header is set
111+
on responses and the `If-Modified-Since` header is supported for requests.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Catalog queries
2+
3+
After you [add a catalog of extensions](../tutorials/add-catalog.md) to your cluster, you must port forward your catalog as a service.
4+
Then you can query the catalog by using `curl` commands and the `jq` CLI tool to find extensions to install.
5+
6+
## Prerequisites
7+
8+
* You have added a ClusterCatalog of extensions, such as [OperatorHub.io](https://operatorhub.io), to your cluster.
9+
* You have installed the `jq` CLI tool.
10+
11+
!!! note
12+
By default, Catalogd is installed with TLS enabled for the catalog webserver.
13+
The following examples will show this default behavior, but for simplicity's sake will ignore TLS verification in the curl commands using the `-k` flag.
14+
15+
!!! note
16+
While using the `/api/v1/metas` endpoint shown in the below examples, it is important to note that the metas endpoint accepts parameters which are one of the sub-types of the `Meta` [definition](https://github.com/operator-framework/operator-registry/blob/e15668c933c03e229b6c80025fdadb040ab834e0/alpha/declcfg/declcfg.go#L111-L114), following the pattern `/api/v1/metas?<parameter>[&<parameter>...]`. e.g. `schema=<schema_name>&package=<package_name>`, `schema=<schema_name>&name=<name>`, and `package=<package_name>&name=<name>` are all valid parameter combinations. However `schema=<schema_name>&version=<version_string>` is not a valid parameter combination, since version is not a first class FBC meta field.
17+
18+
You also need to port forward the catalog server service:
19+
20+
``` terminal
21+
kubectl -n olmv1-system port-forward svc/catalogd-service 8443:443
22+
```
23+
24+
Now you can use the `curl` command with `jq` to query catalogs that are installed on your cluster.
25+
26+
## Package queries
27+
28+
* Available packages in a catalog:
29+
``` terminal
30+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?schema=olm.package'
31+
```
32+
33+
* Packages that support `AllNamespaces` install mode and do not use webhooks:
34+
``` terminal
35+
jq -cs '[.[] | select(.schema == "olm.bundle" and (.properties[] | select(.type == "olm.csv.metadata").value.installModes[] | select(.type == "AllNamespaces" and .supported == true)) and .spec.webhookdefinitions == null) | .package] | unique[]'
36+
```
37+
38+
* Package metadata:
39+
``` terminal
40+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?schema=olm.package&name=<package_name>'
41+
```
42+
43+
`<package_name>`
44+
: Name of the package from the catalog you are querying.
45+
46+
* Blobs that belong to a package (that are not schema=olm.package):
47+
``` terminal
48+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?package=<package_name>'
49+
```
50+
51+
`<package_name>`
52+
: Name of the package from the catalog you are querying.
53+
54+
Note: the `olm.package` schema blob does not have the `package` field set. In other words, to get all the blobs that belong to a package, along with the olm.package blob for that package, a combination of both of the above queries need to be used.
55+
56+
## Channel queries
57+
58+
* Channels in a package:
59+
``` terminal
60+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?schema=olm.channel&package=<package_name>'
61+
```
62+
63+
`<package_name>`
64+
: Name of the package from the catalog you are querying.
65+
66+
* Versions in a channel:
67+
``` terminal
68+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?schema=olm.channel&package=zoperator&name=alpha' | jq -s '.[] | .entries | .[] | .name'
69+
```
70+
71+
`<package_name>`
72+
: Name of the package from the catalog you are querying.
73+
74+
`<channel_name>`
75+
: Name of the channel for a given package.
76+
77+
## Bundle queries
78+
79+
* Bundles in a package:
80+
``` terminal
81+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?schema=olm.bundle&package=<package_name>'
82+
```
83+
84+
`<package_name>`
85+
: Name of the package from the catalog you are querying.
86+
87+
* Bundle dependencies and available APIs:
88+
``` terminal
89+
curl -k 'https://localhost:8443/catalogs/operatorhubio/api/v1/metas?schema=olm.bundle&name=<bundle_name>' | jq -s '.[] | .properties[] | select(.type=="olm.gvk")'
90+
```
91+
92+
`<bundle_name>`
93+
: Name of the bundle for a given package.

0 commit comments

Comments
 (0)