operator-framework / olm-docs

Hugo doc site for https://github.com/operator-framework/operator-lifecycle-manager
10 stars 79 forks source link

Creating a Catalog of operators #233

Open thomassuedbroecker opened 2 years ago

thomassuedbroecker commented 2 years ago

Version

I have the same behavior on both OS.

opm version
Version: version.Version{OpmVersion:"v1.21.0", GitCommit:"9999f796", BuildDate:"2022-03-03T21:23:12Z", GoOs:"linux", GoArch:"amd64"}
go version                   
go version go1.17.6 darwin/amd64
opm version
Version: version.Version{OpmVersion:"v1.21.0", GitCommit:"9999f796", BuildDate:"2022-03-03T21:23:12Z", GoOs:"linux", GoArch:"amd64"}
go version
go version go1.17.8 linux/amd64

Situation

I try follow the instruction to create a catalog in the OLM documention

Initialize the catalog (https://olm.operatorframework.io/docs/tasks/creating-a-catalog/#initialize-the-catalog)

This are the steps to reproduce:

Step 1: Execute opm alpha generate

opm alpha generate dockerfile frontend-catalog

The creation of the dockerfile doesn't work

Run an alpha subcommand

Usage:
  opm alpha [command]

Available Commands:
  bundle      Operator bundle commands
  diff        Diff old and new catalog references into a declarative config
  list        List contents of an index

Flags:
  -h, --help   help for alpha

Global Flags:
      --skip-tls-verify   skip TLS certificate verification for container image registries while pulling bundles
      --use-http          use plain HTTP for container image registries while pulling bundles

Use "opm alpha [command] --help" for more information about a command.

Step 2: Execute opm init

The creation catalog/operator yaml or json works

opm init frontendoperator \
    --default-channel=preview \
    --description=./frontend-catalog/README.md \
    --icon=./frontend-catalog/frontendoperator.svg \
    --output yaml > ./frontend-catalog/operator.yaml
---
defaultChannel: preview
description: |-
  # This is an example Operator

  You will just deploy a simple web application.
icon:
  base64data: PD94bWwgdmVyc2lvbj0iMS4wIiBlbm........m9ybT0icm90YXRlKDQ1KSIgLz4KPC9zdmc+Cg==
  mediatype: image/svg+xml
name: frontendoperator
schema: olm.package

Step 3: Execute opm validate

Doesn't work

opm validate frontend-catalog

Output:

FATA[0000] json: cannot unmarshal string into Go value of type declcfg.tmp 

Summary

For me the OPM doesn't work on two OSs, I am not able to follow the written documentation.

timflannagan commented 2 years ago

@thomassuedbroecker I briefly poked around this locally and it looks like opm's dockerfile generation functionality was graduated out of alpha sometime in the past couple of minor version releases:

```console $ make bin/opm ... $ ./bin/opm --help CLI to interact with operator-registry and build indexes of operator content Usage: opm [command] Available Commands: completion generate the autocompletion script for the specified shell generate Generate various artifacts for declarative config indexes help Help about any command index generate operator index container images init Generate an olm.package declarative config blob migrate Migrate a sqlite-based index image or database file to a file-based catalog registry interact with operator-registry database render Generate a declarative config blob from catalogs and bundles serve serve declarative configs validate Validate the declarative index config version Print the opm version Flags: -h, --help help for opm --skip-tls-verify skip TLS certificate verification for container image registries while pulling bundles --use-http use plain HTTP for container image registries while pulling bundles Use "opm [command] --help" for more information about a command. $ ./bin/opm generate --help Generate various artifacts for declarative config indexes Usage: opm generate [command] Available Commands: dockerfile Generate a Dockerfile for a declarative config index Flags: -h, --help help for generate Global Flags: --skip-tls-verify skip TLS certificate verification for container image registries while pulling bundles --use-http use plain HTTP for container image registries while pulling bundles Use "opm generate [command] --help" for more information about a command. $ ./bin/opm generate dockerfile --help Generate a Dockerfile for a declarative config index. This command creates a Dockerfile in the same directory as the (named .Dockerfile) that can be used to build the index. If a Dockerfile with the same name already exists, this command will fail. When specifying extra labels, note that if duplicate keys exist, only the last value of each duplicate key will be added to the generated Dockerfile. Usage: opm generate dockerfile [flags] Flags: -i, --binary-image string Image in which to build catalog. (default "quay.io/operator-framework/opm:latest") -l, --extra-labels strings Extra labels to include in the generated Dockerfile. Labels should be of the form 'key=value'. -h, --help help for dockerfile Global Flags: --skip-tls-verify skip TLS certificate verification for container image registries while pulling bundles --use-http use plain HTTP for container image registries while pulling bundles $ ./bin/opm version Version: version.Version{OpmVersion:"v1.21.0-1-gb4264e2b", GitCommit:"b4264e2b", BuildDate:"2022-03-22T13:53:39Z", GoOs:"linux", GoArch:"amd64"} ```

cc @joelanford @anik120

thomassuedbroecker commented 2 years ago

Hi @timflannagan thanks for your feedback.

I used the Operator SDK and it worked. But the documentation inside OLM should also work ;-) Here my blog post Deploy an operator without the Operator SDK

Greetings Thomas

lsierant commented 1 year ago

I have just encountered the same error. It is happening only if dockerfile exists in the catalog directory. If you generate exactly like in the documentation, then dockerfile is in the dir above it.