Skip to content

Commit f21d933

Browse files
committed
Use opm generate for FBC Dockerfile gen
1 parent 56478b2 commit f21d933

File tree

5 files changed

+81
-81
lines changed

5 files changed

+81
-81
lines changed

cli_reference/opm/cli-opm-ref.adoc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,19 @@ $ opm <command> [<subcommand>] [<argument>] [<flags>]
2828
|===
2929

3030
:FeatureName: The SQLite-based catalog format, including the related CLI commands,
31-
include::modules/deprecated-feature.adoc[]
31+
include::snippets/deprecated-feature.adoc[]
3232

33-
include::modules/opm-cli-ref-init.adoc[leveloffset=+1]
34-
include::modules/opm-cli-ref-render.adoc[leveloffset=+1]
35-
include::modules/opm-cli-ref-validate.adoc[leveloffset=+1]
36-
include::modules/opm-cli-ref-serve.adoc[leveloffset=+1]
37-
38-
:FeatureName: The SQLite-based catalog format, including the related CLI commands,
39-
include::modules/deprecated-feature.adoc[]
40-
41-
include::modules/opm-cli-ref-migrate.adoc[leveloffset=+1]
42-
include::modules/opm-cli-ref-index.adoc[leveloffset=+1]
4333
include::modules/opm-cli-ref-generate.adoc[leveloffset=+1]
44-
34+
include::modules/opm-cli-ref-index.adoc[leveloffset=+1]
4535
[role="_additional-resources"]
4636
.Additional resources
4737
4838
* xref:../../operators/understanding/olm-packaging-format.adoc#olm-file-based-catalogs_olm-packaging-format[Operator Framework packaging format]
4939
* xref:../../operators/admin/olm-managing-custom-catalogs.adoc#olm-managing-custom-catalogs-fb[Managing custom catalogs]
5040
* xref:../../installing/disconnected_install/installing-mirroring-disconnected.adoc#installing-mirroring-disconnected[Mirroring images for a disconnected installation using the oc-mirror plugin]
41+
42+
include::modules/opm-cli-ref-init.adoc[leveloffset=+1]
43+
include::modules/opm-cli-ref-migrate.adoc[leveloffset=+1]
44+
include::modules/opm-cli-ref-render.adoc[leveloffset=+1]
45+
include::modules/opm-cli-ref-serve.adoc[leveloffset=+1]
46+
include::modules/opm-cli-ref-validate.adoc[leveloffset=+1]

modules/olm-creating-fb-catalog-image.adoc

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
// * operators/admin/olm-managing-custom-catalogs.adoc
44

55
ifdef::openshift-origin[]
6-
:registry-image: quay.io/openshift/origin-operator-registry:4.9.0
6+
:registry-image: quay.io/operator-framework/opm:latest
77
endif::[]
88
ifndef::openshift-origin[]
9-
:registry-image: registry.redhat.io/openshift4/ose-operator-registry:v4.9
9+
:registry-image: registry.redhat.io/openshift4/ose-operator-registry:v{product-version}
1010
endif::[]
1111

1212
:_content-type: PROCEDURE
1313
[id="olm-creating-fb-catalog-image_{context}"]
1414
= Creating a file-based catalog image
1515

16-
You can create a catalog image that uses the plain text _file-based catalog_ format (JSON or YAML), which replaces the deprecated SQLite database format. The `opm` CLI provides tooling that helps initialize a catalog in the file-based format, render new records into it, and validate that the catalog is valid.
16+
You can use the `opm` CLI to create a catalog image that uses the plain text _file-based catalog_ format (JSON or YAML), which replaces the deprecated SQLite database format.
1717

1818
.Prerequisites
1919

@@ -23,47 +23,45 @@ You can create a catalog image that uses the plain text _file-based catalog_ for
2323
2424
.Procedure
2525

26-
. Initialize a catalog for a file-based catalog:
26+
. Initialize the catalog:
2727

28-
.. Create a directory for the catalog:
28+
.. Create a directory for the catalog by running the following command:
2929
+
3030
[source,terminal]
3131
----
32-
$ mkdir <operator_name>-index
32+
$ mkdir <catalog_dir>
3333
----
3434

35-
.. Create a Dockerfile that can build a catalog image:
35+
.. Generate a Dockerfile that can build a catalog image by running the `opm generate dockerfile` command:
3636
+
37-
.Example `<operator_name>-index.Dockerfile`
38-
[source,bash,subs="attributes+"]
37+
[source,terminal,subs="attributes+"]
3938
----
40-
# The base image is expected to contain
41-
# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe
42-
FROM {registry-image}
43-
44-
# Configure the entrypoint and command
45-
ENTRYPOINT ["/bin/opm"]
46-
CMD ["serve", "/configs"]
47-
48-
# Copy declarative config root into image at /configs
49-
ADD <operator_name>-index /configs
50-
51-
# Set DC-specific label for the location of the DC root directory
52-
# in the image
53-
LABEL operators.operatorframework.io.index.configs.v1=/configs
39+
ifdef::openshift-origin[]
40+
$ opm generate dockerfile <catalog_dir>
41+
endif::[]
42+
ifndef::openshift-origin[]
43+
$ opm generate dockerfile <catalog_dir> \
44+
-i {registry-image} <1>
45+
endif::[]
5446
----
47+
ifndef::openshift-origin[]
48+
<1> Specify the official Red Hat base image by using the `-i` flag, otherwise the Dockerfile uses the default upstream image.
49+
endif::[]
5550
+
5651
The Dockerfile must be in the same parent directory as the catalog directory that you created in the previous step:
5752
+
5853
.Example directory structure
5954
[source,terminal]
6055
----
61-
.
62-
├── <operator_name>-index
63-
└── <operator_name>-index.Dockerfile
56+
. <1>
57+
├── <catalog_dir> <2>
58+
└── <catalog_dir>.Dockerfile <3>
6459
----
60+
<1> Parent directory
61+
<2> Catalog directory
62+
<3> Dockerfile generated by the `opm generate dockerfile` command
6563

66-
.. Populate the catalog with your package definition:
64+
.. Populate the catalog with the package definition for your Operator by running the `opm init` command:
6765
+
6866
[source,terminal]
6967
----
@@ -72,36 +70,34 @@ $ opm init <operator_name> \ <1>
7270
--description=./README.md \ <3>
7371
--icon=./operator-icon.svg \ <4>
7472
--output yaml \ <5>
75-
> <operator_name>-index/index.yaml <6>
76-
----
77-
<1> Operator, or package, name.
78-
<2> Channel that subscription will default to if unspecified.
79-
<3> Path to the Operator's `README.md` or other documentation.
80-
<4> Path to the Operator's icon.
81-
<5> Output format: JSON or YAML.
82-
<6> Path for creating the catalog configuration file.
73+
> <catalog_dir>/index.yaml <6>
74+
----
75+
<1> Operator, or package, name
76+
<2> Channel that subscriptions default to if unspecified
77+
<3> Path to the Operator's `README.md` or other documentation
78+
<4> Path to the Operator's icon
79+
<5> Output format: JSON or YAML
80+
<6> Path for creating the catalog configuration file
8381
+
8482
This command generates an `olm.package` declarative config blob in the specified catalog configuration file.
8583

86-
. Add a bundle to the catalog:
84+
. Add a bundle to the catalog by running the `opm render` command:
8785
+
8886
[source,terminal]
8987
----
9088
$ opm render <registry>/<namespace>/<bundle_image_name>:<tag> \ <1>
9189
--output=yaml \
92-
>> <operator_name>-index/index.yaml <2>
90+
>> <catalog_dir>/index.yaml <2>
9391
----
94-
<1> Pull spec for the bundle image.
95-
<2> Path to the catalog configuration file.
96-
+
97-
The `opm render` command generates a declarative config blob from the provided catalog images and bundle images.
92+
<1> Pull spec for the bundle image
93+
<2> Path to the catalog configuration file
9894
+
9995
[NOTE]
10096
====
10197
Channels must contain at least one bundle.
10298
====
10399

104-
. Add a channel entry for the bundle. For example, modify the following example to your specifications, and add it to your `<operator_name>-index/index.yaml` file:
100+
. Add a channel entry for the bundle. For example, modify the following example to your specifications, and add it to your `<catalog_dir>/index.yaml` file:
105101
+
106102
.Example channel entry
107103
[source,yaml]
@@ -113,15 +109,15 @@ name: preview
113109
entries:
114110
- name: <operator_name>.v0.1.0 <1>
115111
----
116-
<1> Ensure that you include the period (`.`) after `<operator_name>` but before the `v` in the version. Otherwise, the entry will fail to pass the `opm validate` command.
112+
<1> Ensure that you include the period (`.`) after `<operator_name>` but before the `v` in the version. Otherwise, the entry fails to pass the `opm validate` command.
117113
118114
. Validate the file-based catalog:
119115
120116
.. Run the `opm validate` command against the catalog directory:
121117
+
122118
[source,terminal]
123119
----
124-
$ opm validate <operator_name>-index
120+
$ opm validate <catalog_dir>
125121
----
126122
127123
.. Check that the error code is `0`:
@@ -137,25 +133,25 @@ $ echo $?
137133
0
138134
----
139135
140-
. Build the catalog image:
136+
. Build the catalog image by running the `podman build` command:
141137
+
142138
[source,terminal]
143139
----
144140
$ podman build . \
145-
-f <operator_name>-index.Dockerfile \
141+
-f <catalog_dir>.Dockerfile \
146142
-t <registry>/<namespace>/<catalog_image_name>:<tag>
147143
----
148144
149145
. Push the catalog image to a registry:
150146
151-
.. If required, authenticate with your target registry:
147+
.. If required, authenticate with your target registry by running the `podman login` command:
152148
+
153149
[source,terminal]
154150
----
155151
$ podman login <registry>
156152
----
157153
158-
.. Push the catalog image:
154+
.. Push the catalog image by running the `podman push` command:
159155
+
160156
[source,terminal]
161157
----

modules/opm-cli-ref-generate.adoc

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
//Module included in the following assemblies:
1+
// Module included in the following assemblies:
22
//
3-
//*cli_reference/opm/cli-opm-ref.adoc
3+
// * cli_reference/opm/cli-opm-ref.adoc
44

55
[id="opm-cli-ref-generate_{Context}"]
66
= generate
77

88
Generate various artifacts for declarative config indexes.
99

10-
.Command syntax
11-
[source,terminal]
12-
----
13-
$ opm generate [command]
14-
----
15-
16-
.`generate` flags
17-
[options="header",cols="1,3"]
18-
|===
19-
|Flags |Description
20-
21-
|`-h`, `--help`
22-
|Help for generate.
23-
24-
|===
25-
2610
.Command syntax
2711
[source,terminal]
2812
----
@@ -36,25 +20,35 @@ $ opm generate <subcommand> [<flags>]
3620

3721
|`dockerfile`
3822
|Generate a Dockerfile for a declarative config index.
23+
|===
24+
25+
.`generate` flags
26+
[options="header",cols="1,3"]
27+
|===
28+
|Flags |Description
29+
30+
|`-h`, `--help`
31+
|Help for generate.
3932

4033
|===
4134

35+
4236
[id="opm-cli-ref-generate-dockerfile_{context}"]
4337
== dockerfile
4438

4539
Generate a Dockerfile for a declarative config index.
4640

4741
[IMPORTANT]
4842
====
49-
This command creates a Dockerfile in the same directory as the <dcRootDir> (named <dcDirName>.Dockerfile) that is used to build the index. If a Dockerfile with the same name already exists, this command fails.
43+
This command creates a Dockerfile in the same directory as the `<dcRootDir>` (named `<dcDirName>.Dockerfile`) that is used to build the index. If a Dockerfile with the same name already exists, this command fails.
5044
5145
When specifying extra labels, if duplicate keys exist, only the last value of each duplicate key gets added to the generated Dockerfile.
5246
====
5347

5448
.Command syntax
5549
[source,terminal]
5650
----
57-
$ opm generate dockerfile <dcRootDir> [flags]
51+
$ opm generate dockerfile <dcRootDir> [<flags>]
5852
----
5953

6054
.`generate dockerfile` flags
@@ -71,4 +65,11 @@ $ opm generate dockerfile <dcRootDir> [flags]
7165
|`-h`, `--help`
7266
|Help for Dockerfile.
7367

74-
|===
68+
|===
69+
70+
ifndef::openshift-origin[]
71+
[NOTE]
72+
====
73+
To build with the official Red Hat image, use the `registry.redhat.io/openshift4/ose-operator-registry:v{product-version}` value with the `-i` flag.
74+
====
75+
endif::[]

modules/opm-cli-ref-migrate.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
Migrate a SQLite database format index image or database file to a file-based catalog.
99

10+
:FeatureName: The SQLite-based catalog format, including the related CLI commands,
11+
include::snippets/deprecated-feature.adoc[]
12+
1013
.Command syntax
1114
[source,terminal]
1215
----

operators/admin/olm-managing-custom-catalogs.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Many of the `opm` subcommands and flags for working with the SQLite database for
4040
====
4141

4242
include::modules/olm-creating-fb-catalog-image.adoc[leveloffset=+2]
43+
[role="_additional-resources"]
44+
.Additional resources
45+
46+
* xref:../../cli_reference/opm/cli-opm-ref.adoc#cli-opm-ref[`opm` CLI reference]
4347

4448
[id="olm-managing-custom-catalogs-sqlite"]
4549
== SQLite-based catalogs

0 commit comments

Comments
 (0)