Skip to content

Commit b8573f3

Browse files
committed
chore(crds): add crds and manifests make rule to generate them
1 parent e97a435 commit b8573f3

11 files changed

+11208
-1
lines changed

Makefile

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ endif
1919
REPO = github.com/operator-framework/api
2020
BUILD_PATH = $(REPO)/cmd/operator-verify
2121
PKGS = $(shell go list ./... | grep -v /vendor/)
22+
YQ_INTERNAL := $(Q) go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v2/
2223

2324
.PHONY: help
2425
help: ## Show this help screen
@@ -57,7 +58,78 @@ clean: ## Clean up the build artifacts
5758
$(Q)rm -rf build
5859

5960
generate: controller-gen ## Generate code
60-
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
61+
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./...
62+
63+
manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc
64+
@# Handle >v1 APIs
65+
$(CONTROLLER_GEN) crd paths=./pkg/operators/v2alpha1... output:crd:dir=./crds
66+
67+
@# Handle <=v1 APIs
68+
$(CONTROLLER_GEN) schemapatch:manifests=./crds output:dir=./crds paths=./pkg/operators/...
69+
70+
@# Preserve unknown fields on the CSV spec (prevents install strategy from being pruned)
71+
$(YQ_INTERNAL) w --inplace ./crds/operators.coreos.com_clusterserviceversions.yaml spec.validation.openAPIV3Schema.properties.spec.properties.install.properties.spec.properties.deployments.items.properties.spec.properties.template.properties.metadata.x-kubernetes-preserve-unknown-fields true
72+
73+
# Generate deepcopy, conversion, clients, listers, and informers
74+
codegen:
75+
# Deepcopy
76+
$(CONTROLLER_GEN) object:headerFile=./boilerplate.go.txt paths=./pkg/api/apis/operators/...i
77+
# Conversion, clients, listers, and informers
78+
$(CODEGEN)
79+
80+
# Generate mock types.
81+
mockgen:
82+
$(MOCKGEN)
83+
84+
# Generates everything.
85+
gen-all: codegen mockgen manifests
86+
87+
diff:
88+
git diff --exit-code
89+
90+
verify-codegen: codegen diff
91+
verify-mockgen: mockgen diff
92+
verify-manifests: manifests diff
93+
verify: verify-codegen verify-mockgen verify-manifests
94+
95+
96+
# before running release, bump the version in OLM_VERSION and push to master,
97+
# then tag those builds in quay with the version in OLM_VERSION
98+
release: ver=$(shell cat OLM_VERSION)
99+
release:
100+
docker pull quay.io/operator-framework/olm:$(ver)
101+
$(MAKE) target=upstream ver=$(ver) quickstart=true package
102+
$(MAKE) target=ocp ver=$(ver) package
103+
rm -rf manifests
104+
mkdir manifests
105+
cp -R deploy/ocp/manifests/$(ver)/. manifests
106+
# requires gnu sed if on mac
107+
find ./manifests -type f -exec sed -i "/^#/d" {} \;
108+
find ./manifests -type f -exec sed -i "1{/---/d}" {} \;
109+
110+
verify-release: release diff
111+
112+
package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' quay.io/operator-framework/olm:$(ver))
113+
package:
114+
ifndef target
115+
$(error target is undefined)
116+
endif
117+
ifndef ver
118+
$(error ver is undefined)
119+
endif
120+
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml olm.image.ref $(olmref)
121+
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml catalog.image.ref $(olmref)
122+
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml package.image.ref $(olmref)
123+
./scripts/package_release.sh $(ver) deploy/$(target)/manifests/$(ver) deploy/$(target)/values.yaml
124+
ln -sfFn ./$(ver) deploy/$(target)/manifests/latest
125+
ifeq ($(quickstart), true)
126+
./scripts/package_quickstart.sh deploy/$(target)/manifests/$(ver) deploy/$(target)/quickstart/olm.yaml deploy/$(target)/quickstart/crds.yaml deploy/$(target)/quickstart/install.sh
127+
endif
128+
129+
.PHONY: run-console-local
130+
run-console-local:
131+
@echo Running script to run the OLM console locally:
132+
. ./scripts/run_console_local.sh
61133

62134
# Static tests.
63135
.PHONY: test test-unit

crds/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package crds contains CustomResourceDefinition manifests for operator-framework APIs.
2+
package crds
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: catalogsources.operators.coreos.com
5+
annotations:
6+
displayName: CatalogSource
7+
description: A source configured to find packages and updates.
8+
spec:
9+
group: operators.coreos.com
10+
version: v1alpha1
11+
versions:
12+
- name: v1alpha1
13+
served: true
14+
storage: true
15+
preserveUnknownFields: false
16+
scope: Namespaced
17+
names:
18+
plural: catalogsources
19+
singular: catalogsource
20+
kind: CatalogSource
21+
listKind: CatalogSourceList
22+
shortNames:
23+
- catsrc
24+
categories:
25+
- olm
26+
additionalPrinterColumns:
27+
- name: Display
28+
type: string
29+
description: The pretty name of the catalog
30+
JSONPath: .spec.displayName
31+
- name: Type
32+
type: string
33+
description: The type of the catalog
34+
JSONPath: .spec.sourceType
35+
- name: Publisher
36+
type: string
37+
description: The publisher of the catalog
38+
JSONPath: .spec.publisher
39+
- name: Age
40+
type: date
41+
JSONPath: .metadata.creationTimestamp
42+
subresources:
43+
# status enables the status subresource.
44+
status: {}
45+
validation:
46+
openAPIV3Schema:
47+
description: CatalogSource is a repository of CSVs, CRDs, and operator packages.
48+
type: object
49+
required:
50+
- metadata
51+
- spec
52+
properties:
53+
apiVersion:
54+
description: 'APIVersion defines the versioned schema of this representation
55+
of an object. Servers should convert recognized schemas to the latest
56+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
57+
type: string
58+
kind:
59+
description: 'Kind is a string value representing the REST resource this
60+
object represents. Servers may infer this from the endpoint the client
61+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
62+
type: string
63+
metadata:
64+
type: object
65+
spec:
66+
type: object
67+
required:
68+
- sourceType
69+
properties:
70+
address:
71+
description: 'Address is a host that OLM can use to connect to a pre-existing
72+
registry. Format: <registry-host or ip>:<port> Only used when SourceType
73+
= SourceTypeGrpc. Ignored when the Image field is set.'
74+
type: string
75+
configMap:
76+
description: ConfigMap is the name of the ConfigMap to be used to back
77+
a configmap-server registry. Only used when SourceType = SourceTypeConfigmap
78+
or SourceTypeInternal.
79+
type: string
80+
description:
81+
type: string
82+
displayName:
83+
description: Metadata
84+
type: string
85+
icon:
86+
type: object
87+
required:
88+
- base64data
89+
- mediatype
90+
properties:
91+
base64data:
92+
type: string
93+
mediatype:
94+
type: string
95+
image:
96+
description: Image is an operator-registry container image to instantiate
97+
a registry-server with. Only used when SourceType = SourceTypeGrpc.
98+
If present, the address field is ignored.
99+
type: string
100+
publisher:
101+
type: string
102+
secrets:
103+
description: Secrets represent set of secrets that can be used to access
104+
the contents of the catalog. It is best to keep this list small, since
105+
each will need to be tried for every catalog entry.
106+
type: array
107+
items:
108+
type: string
109+
sourceType:
110+
description: SourceType is the type of source
111+
type: string
112+
updateStrategy:
113+
description: UpdateStrategy defines how updated catalog source images
114+
can be discovered Consists of an interval that defines polling duration
115+
and an embedded strategy type
116+
type: object
117+
properties:
118+
registryPoll:
119+
type: object
120+
properties:
121+
interval:
122+
description: Interval is used to determine the time interval
123+
between checks of the latest catalog source version. The catalog
124+
operator polls to see if a new version of the catalog source
125+
is available. If available, the latest image is pulled and
126+
gRPC traffic is directed to the latest catalog source.
127+
type: string
128+
status:
129+
type: object
130+
properties:
131+
configMapReference:
132+
type: object
133+
required:
134+
- name
135+
- namespace
136+
properties:
137+
lastUpdateTime:
138+
type: string
139+
format: date-time
140+
name:
141+
type: string
142+
namespace:
143+
type: string
144+
resourceVersion:
145+
type: string
146+
uid:
147+
description: UID is a type that holds unique ID values, including
148+
UUIDs. Because we don't ONLY use UUIDs, this is an alias to string. Being
149+
a type captures intent and helps make sure that UIDs and names
150+
do not get conflated.
151+
type: string
152+
connectionState:
153+
type: object
154+
required:
155+
- lastObservedState
156+
properties:
157+
address:
158+
type: string
159+
lastConnect:
160+
type: string
161+
format: date-time
162+
lastObservedState:
163+
type: string
164+
latestImageRegistryPoll:
165+
description: The last time the CatalogSource image registry has been
166+
polled to ensure the image is up-to-date
167+
type: string
168+
format: date-time
169+
message:
170+
description: A human readable message indicating details about why the
171+
ClusterServiceVersion is in this condition.
172+
type: string
173+
reason:
174+
description: Reason is the reason the Subscription was transitioned
175+
to its current state.
176+
type: string
177+
registryService:
178+
type: object
179+
properties:
180+
createdAt:
181+
type: string
182+
format: date-time
183+
port:
184+
type: string
185+
protocol:
186+
type: string
187+
serviceName:
188+
type: string
189+
serviceNamespace:
190+
type: string

0 commit comments

Comments
 (0)