### Install btree Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/tidwall/btree/README.md Use 'go get' to install the btree package. This is the initial step to start using the library. ```sh go get github.com/tidwall/btree ``` -------------------------------- ### Install etcd/client/v3 Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.etcd.io/etcd/client/v3/README.md Install the official Go etcd client for v3 using go get. ```bash go get go.etcd.io/etcd/client/v3 ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-isatty/README.md Install the go-isatty package using the go get command. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Install Flect Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/gobuffalo/flect/README.md Install the Flect package using the go get command. ```console go get github.com/gobuffalo/flect ``` -------------------------------- ### Example InstallPlan Configuration Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/developing.md An example of an `InstallPlan` resource configuration. This is used to manage the installation and updates of cluster service versions (CSVs) within OLM. ```yaml apiVersion: app.coreos.com/v1alpha1 kind: InstallPlan metadata: namespace: default name: olm-testing spec: clusterServiceVersionNames: - etcdoperator.v0.7.2 approval: Automatic ``` -------------------------------- ### Install gziphandler Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/NYTimes/gziphandler/README.md Install the gziphandler package using go get. ```bash go get -u github.com/NYTimes/gziphandler ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/json-iterator/go/README.md Install the library using the go get command. ```go go get github.com/json-iterator/go ``` -------------------------------- ### Basic WebService Setup and Route Definition Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/emicklei/go-restful/v3/README.md Defines a WebService with path, consumes, and produces types, and sets up a GET route for retrieving a user by ID. The route includes documentation and parameter definition. ```Go ws := new(restful.WebService) ws. Path("/users"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser). Doc("get a user"). Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")), Writes(User{})) ... func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } ``` -------------------------------- ### Install Cobra Library Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/spf13/cobra/README.md Use 'go get' to install the latest version of the Cobra library. ```go go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Install mapstructure Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/go-viper/mapstructure/v2/README.md Use go get to install the mapstructure library. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Subscription Object Example Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/scoped-operator-install.md Inspect the Subscription object to find a reference to the InstallPlan that attempted the installation. ```yaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: etcd namespace: scoped status: installPlanRef: apiVersion: operators.coreos.com/v1alpha1 kind: InstallPlan name: install-4plp8 namespace: scoped resourceVersion: "117359" uid: 2c1df80e-afea-11e9-bce3-5254009c9c23 ``` -------------------------------- ### Install color Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/fatih/color/README.md Use 'go get' to install the color package for your Go project. ```bash go get github.com/fatih/color ``` -------------------------------- ### Install sigs.k8s.io/yaml Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/sigs.k8s.io/yaml/README.md Run this command to install the library. ```bash $ go get sigs.k8s.io/yaml ``` -------------------------------- ### Local OLM Development Setup Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/AGENTS.md Commands to set up and run OLM locally. 'make run-local' performs a complete local setup. Alternatively, use the step-by-step commands: 'make kind-create' to create a kind cluster, 'make cert-manager-install' to install cert-manager, and 'make deploy' to deploy OLM to the cluster. ```bash make run-local # Complete local setup # OR step-by-step: make kind-create # Create kind cluster (kind-olmv0) make cert-manager-install make deploy # Deploy OLM to cluster ``` -------------------------------- ### Install hashstructure v2 Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mitchellh/hashstructure/v2/README.md Use `go get` to install the v2 release of the hashstructure library. It is recommended over v1 due to fixes for hash collision issues. ```bash $ go get github.com/mitchellh/hashstructure/v2 ``` -------------------------------- ### Install gojq with Zero Install Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/itchyny/gojq/README.md Add gojq using the Zero Install system by providing its XML manifest URL. ```sh 0install add gojq https://apps.0install.net/utils/gojq.xml ``` -------------------------------- ### SQL User Management Examples Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-sqlite3/README.md Examples demonstrating how to add, change, and delete users using SQL functions. Ensure you have the necessary administrator privileges. ```sql SELECT auth_user_add('admin2', 'admin2', 1); ``` ```sql SELECT auth_user_change('user', 'userpassword', 0); ``` ```sql SELECT user_delete('user'); ``` -------------------------------- ### Initialize Procfs and Get Stats Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/prometheus/procfs/README.md Initializes the proc filesystem and retrieves CPU statistics. Use this to get started with basic system metrics. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Install filetype package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/h2non/filetype/README.md Use go get to install the filetype package for your Go project. ```bash go get github.com/h2non/filetype ``` -------------------------------- ### Install yaml.v3 Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.yaml.in/yaml/v3/README.md Use 'go get' to install the yaml.v3 package for use in your Go projects. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install OpenCensus Go Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.opencensus.io/README.md Use this command to install the OpenCensus Go library. Vendoring or a dependency management tool is recommended. ```bash $ go get -u go.opencensus.io ``` -------------------------------- ### Install gojq with Homebrew Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/itchyny/gojq/README.md Use Homebrew to install the gojq command-line tool. ```sh brew install gojq ``` -------------------------------- ### Install go-colorable Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-colorable/README.md Use the go get command to install the go-colorable package into your project. This is the standard way to add external Go dependencies. ```bash go get github.com/mattn/go-colorable ``` -------------------------------- ### Operator Install Deployment and Permissions Example Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/building-your-csv.md This YAML defines the installation configuration for an operator, including its deployment specifications and the RBAC permissions it requires. Ensure the serviceAccountName in the deployment matches a defined role. ```yaml install: spec: deployments: - name: example-operator label: application: example-operator technology: general spec: replicas: 1 selector: matchLabels: k8s-app: example-operator template: metadata: labels: k8s-app: example-operator spec: containers: image: 'quay.io/example/example-operator:v0.0.1' imagePullPolicy: Always name: example-operator resources: limits: cpu: 200m memory: 100Mi requests: cpu: 100m memory: 50Mi imagePullSecrets: - name: '' nodeSelector: kubernetes.io/os: linux serviceAccountName: example-operator permissions: - serviceAccountName: example-operator rules: - apiGroups: - '' resources: - configmaps - secrets - services verbs: - get - list - create - update - delete - apiGroups: - apps resources: - statefulsets verbs: - '*' - apiGroups: - apiextensions.k8s.io resources: - customresourcedefinitions verbs: - get - list - watch - create - delete - apiGroups: - mongodb.com resources: - '*' verbs: - '*' - serviceAccountName: example-operator-list rules: - apiGroups: - '' resources: - services verbs: - get - list strategy: deployment ``` -------------------------------- ### Install Ubuntu Build Essentials Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-sqlite3/README.md For Ubuntu, install the 'build-essential' package to obtain the required compilation tools. ```bash sudo apt-get install build-essential ``` -------------------------------- ### Install operator-verify Tool Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/contributors/design-proposals/operator-validation-library.md Install the operator-verify command-line tool from source using the go install command. Ensure your Go workspace's bin directory is in your PATH. ```bash $ go install ``` ```bash $ echo $PATH ``` ```bash $ export PATH=$PATH:$(go env GOPATH)/bin ``` ```bash $ which operator-verify ``` ```bash ~/go/bin/operator-verify ``` -------------------------------- ### Example Go Module Requirement (Expected) Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/antlr4-go/antlr/v4/README.md Shows the desired `go get` output for the ANTLR4 Go runtime, providing clear and standard versioning. ```go require ( github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.13.0 ) ``` -------------------------------- ### Run the SVG Check Example Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/h2non/go-is-svg/README.md Execute the Go example program to test SVG file verification. ```bash go run _example/example.go ``` -------------------------------- ### Install gojq with mise Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/itchyny/gojq/README.md Use mise to manage and install the latest version of gojq globally. ```sh mise use -g gojq@latest ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site for viewing package documentation. Ensure you have the latest version of pkgsite. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install uuid Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/google/uuid/README.md Use this command to install the uuid package. Ensure you have Go installed and configured. ```sh go get github.com/google/uuid ``` -------------------------------- ### Install go-sqlite3 Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-sqlite3/README.md Use this command to install the go-sqlite3 package. Ensure CGO_ENABLED=1 and a GCC compiler are set up as this is a CGO-enabled package. ```bash go get github.com/mattn/go-sqlite3 ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/DEVELOPMENT.md Download and install project dependencies using the Makefile. This ensures the project is set up correctly for development. ```sh $ make vendor ``` -------------------------------- ### Install Development Tools Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.opencensus.io/CONTRIBUTING.md Run `make install-tools` once to install necessary development dependencies. This command is typically executed before running the main build or test commands. ```bash $ make install-tools # Only first time. ``` -------------------------------- ### Install Fedora Development Tools Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-sqlite3/README.md On Fedora, install the 'Development Tools' and 'Development Libraries' groups to compile. ```bash sudo yum groupinstall "Development Tools" "Development Libraries" ``` -------------------------------- ### Install Gorilla Mux Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/gorilla/mux/README.md Install the Gorilla Mux package using the Go toolchain. Ensure your Go environment is correctly configured. ```sh go get -u github.com/gorilla/mux ``` -------------------------------- ### Operator Pod Configuration Example Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/contributors/design-proposals/operator-config.md Example of configuring operator pods with resource requests/limits, node selectors, tolerations, volumes, and environment variables. ```yaml # ... config: - selector: matchLabels: app: etcd-operator resources: requests: memory: "64Mi" cpu: "250m" limits: memory: "128Mi" cpu: "500m" nodeSelector: disktype: ssd tolerations: - key: "key" operator: "Equal" value: "value" effect: "NoSchedule" # provide application config via a configmap volume volumes: - name: config-volume configMap: name: etcd-operator-config volumeMounts: - mountPath: /config name: config-volume # provide application config via env variables env: - name: SPECIAL_LEVEL_KEY valueFrom: configMapKeyRef: name: special-config key: special.how envFrom: - configMapRef: name: etcd-env-config ``` -------------------------------- ### Explicit Instrumentation Setup in Go Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates the recommended pattern for initializing instrumentation within a constructor function. This ensures clear ownership and scope, avoiding global or implicit side effects. ```go import ( "errors" semconv "go.opentelemetry.io/otel/semconv/v1.40.0" "go.opentelemetry.io/otel/semconv/v1.40.0/otelconv" ) type SDKComponent struct { inst *instrumentation } func NewSDKComponent(config Config) (*SDKComponent, error) { inst, err := newInstrumentation() if err != nil { return nil, err } return &SDKComponent{inst: inst}, nil } type instrumentation struct { inflight otelconv.SDKComponentInflight exported otelconv.SDKComponentExported } func newInstrumentation() (*instrumentation, error) { if !x.Observability.Enabled() { return nil, nil } meter := otel.GetMeterProvider().Meter( "", metric.WithInstrumentationVersion(sdk.Version()), metric.WithSchemaURL(semconv.SchemaURL), ) inst := &instrumentation{} var err, e error inst.inflight, e = otelconv.NewSDKComponentInflight(meter) err = errors.Join(err, e) inst.exported, e = otelconv.NewSDKComponentExported(meter) err = errors.Join(err, e) return inst, err } ``` -------------------------------- ### Populate SubscriptionStatus with InstallPlanRef Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/contributors/design-proposals/subscription-status.md Uses ObjectReference to populate both SubscriptionStatus.InstallPlan and SubscriptionStatus.InstallPlanRef. ```go func (o *Operator) updateSubscriptionStatus(namespace string, subs []*v1alpha1.Subscription, installPlanRef *corev1.ObjectReference) error { // ... for _, sub := range subs { // ... if installPlanRef != nil { sub.Status.InstallPlanRef = installPlanRef sub.Status.Install = v1alpha1.NewInstallPlanReference(installPlanRef) sub.Status.State = v1alpha1.SubscriptionStateUpgradePending } // ... } // ... ``` -------------------------------- ### Install Pogreb Go Package Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/akrylysov/pogreb/README.md Install the Pogreb package using go get. ```sh $ go get -u github.com/akrylysov/pogreb ``` -------------------------------- ### Basic Gorilla Mux Server Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/gorilla/mux/README.md A complete example demonstrating how to set up a simple HTTP server with routing using Gorilla Mux. It includes defining a handler and binding the router to a port. ```go package main import ( "net/http" "log" "github.com/gorilla/mux" ) func YourHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Gorilla!\n")) } func main() { r := mux.NewRouter() // Routes consist of a path and a handler function. r.HandleFunc("/", YourHandler) // Bind to a port and pass our router in log.Fatal(http.ListenAndServe(":8000", r)) } ``` -------------------------------- ### Basic Structured Logging Example Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/sigs.k8s.io/controller-runtime/TMP-LOGGING.md Illustrates the basic syntax for structured logging in controller-runtime, contrasting it with the standard Go log package. ```go log.Printf("starting reconciliation for pod %s/%s", podNamespace, podName) ``` ```go logger.Info("starting reconciliation", "pod", req.NamespacedName) ``` -------------------------------- ### Install Latest JSON-Patch Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/evanphx/json-patch/README.md Install the latest version of the jsonpatch library using go get. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### Create InstallPlanReference Helper Function Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/contributors/design-proposals/subscription-status.md A helper function to convert corev1.ObjectReference into v1alpha1.InstallPlanReference. ```go func NewInstallPlanReference(ref *corev1.ObjectReference) *InstallPlanReference { return &InstallPlanReference{ APIVersion: ref.APIVersion, Kind: ref.Kind, Name: ref.Name, UID: ref.UID, } } ``` -------------------------------- ### Install bbolt Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.etcd.io/bbolt/README.md Install the bbolt library using go get. This command retrieves the library and updates your go.mod and go.sum files. ```sh go get go.etcd.io/bbolt@latest ``` -------------------------------- ### Go Btree Example with Custom Comparators Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/tidwall/btree/README.md Demonstrates creating and populating two B-trees with custom comparison functions for sorting by different fields (key and value). Shows how to iterate and print elements from each tree. ```go package main import ( "fmt" "github.com/tidwall/btree" ) type Item struct { Key, Val string } // byKeys is a comparison function that compares item keys and returns true // when a is less than b. func byKeys(a, b interface{}) bool { i1, i2 := a.(*Item), b.(*Item) return i1.Key < i2.Key } // byVals is a comparison function that compares item values and returns true // when a is less than b. func byVals(a, b interface{}) bool { i1, i2 := a.(*Item), b.(*Item) if i1.Val < i2.Val { return true } if i1.Val > i2.Val { return false } // Both vals are equal so we should fall though // and let the key comparison take over. return byKeys(a, b) } func main() { // Create a tree for keys and a tree for values. // The "keys" tree will be sorted on the Keys field. // The "values" tree will be sorted on the Values field. keys := btree.New(byKeys) vals := btree.New(byVals) // Create some items. users := []*Item{ &Item{Key: "user:1", Val: "Jane"}, &Item{Key: "user:2", Val: "Andy"}, &Item{Key: "user:3", Val: "Steve"}, &Item{Key: "user:4", Val: "Andrea"}, &Item{Key: "user:5", Val: "Janet"}, &Item{Key: "user:6", Val: "Andy"}, } // Insert each user into both trees for _, user := range users { keys.Set(user) vals.Set(user) } // Iterate over each user in the key tree keys.Ascend(nil, func(item interface{}) bool { kvi := item.(*Item) fmt.Printf("%s %s\n", kvi.Key, kvi.Val) return true }) fmt.Printf("\n") // Iterate over each user in the val tree vals.Ascend(nil, func(item interface{}) bool { kvi := item.(*Item) fmt.Printf("%s %s\n", kvi.Key, kvi.Val) return true }) // Output: // user:1 Jane // user:2 Andy // user:3 Steve // user:4 Andrea // user:5 Janet // user:6 Andy // // user:4 Andrea // user:2 Andy // user:6 Andy // user:1 Jane // user:5 Janet // user:3 Steve } ``` -------------------------------- ### Reinstall go-sqlite3 using go install Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-sqlite3/README.md If 'go get' fails with a 'gcc' internal compiler error, remove the download repository and use 'go install' instead. ```bash go install github.com/mattn/go-sqlite3 ``` -------------------------------- ### CRD Templates with Annotations Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/building-your-csv.md Provides example CRs for users to customize, using the 'alm-examples' annotation. Metadata for these examples, such as descriptions, is provided in 'alm-examples-metadata'. This helps UIs pre-populate and guide users. ```yaml metadata: annotations: alm-examples-metadata: >- {"example-etcd-cluster":{"description":"Example EtcdCluster CR"},"example-etcd-restore":{"description":"Example EtcdRestore CR that restores data from S3"},"example-etcd-backup":{"description":"Example EtcdBackup CR that stores backups on S3"}} alm-examples: >- [{"apiVersion":"etcd.database.coreos.com/v1beta2","kind":"EtcdCluster","metadata":{"name":"example-etcd-cluster","namespace":"default"},"spec":{"size":3,"version":"3.2.13"}},{"apiVersion":"etcd.database.coreos.com/v1beta2","kind":"EtcdRestore","metadata":{"name":"example-etcd-restore"},"spec":{"etcdCluster":{"name":"example-etcd-cluster"},"backupStorageType":"S3","s3":{"path":"","awsSecret":""}}},{"apiVersion":"etcd.database.coreos.com/v1beta2","kind":"EtcdBackup","metadata":{"name":"example-etcd-backup"},"spec":{"etcdEndpoints":[""],"storageType":"S3","s3":{"path":"","awsSecret":""}}}] ``` -------------------------------- ### Build gojq from source Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/itchyny/gojq/README.md Build and install gojq from its source code using the Go toolchain. ```sh go install github.com/itchyny/gojq/cmd/gojq@latest ``` -------------------------------- ### Build with Multiple Features Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/mattn/go-sqlite3/README.md Example command to build go-sqlite3 with multiple features enabled. Tags should be space-delimited. ```bash go build -tags "icu json1 fts5 secure_delete" ``` -------------------------------- ### Example of Skipping an Operator Update Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/how-to-update-operators.md Use the 'skips' field in the ClusterServiceVersion manifest to specify operator versions that should not be installed if they haven't been already. This ensures a safe update path by preventing the installation of known problematic versions. ```yaml apiVersion: operators.coreos.com/v1alpha1 kind: ClusterServiceVersion metadata: name: etcdoperator.v0.9.2 namespace: placeholder annotations: spec: displayName: etcd description: Etcd Operator replaces: etcdoperator.v0.9.0 skips: - etcdoperator.v0.9.1 ``` -------------------------------- ### Define an InstallPlan for Testing Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/debugging.md Create an InstallPlan resource to test dependency resolution. This example defines an InstallPlan that will fail because the specified CSV does not exist in the catalog. ```yaml apiVersion: app.coreos.com/v1alpha1 kind: InstallPlan metadata: namespace: ci-olm-pr-188-gc-csvs name: olm-testing spec: clusterServiceVersionNames: - etcdoperator123 approval: Automatic ``` -------------------------------- ### Install go-openapi/swag Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/go-openapi/swag/README.md Use this command to get the go-openapi/swag module for your project. For backward compatibility, you can use the older import path. ```bash go get github.com/go-openapi/swag/{module} ``` ```bash go get github.com/go-openapi/swag ``` -------------------------------- ### Inspect ClusterServiceVersion Status Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/debugging.md Use kubectl to get the YAML definition of a ClusterServiceVersion and check its phase and messages for installation issues. ```sh $ kubectl -n ci-olm-pr-188-gc-csvs get clusterserviceversions etcdoperator.v0.8.1 -o yaml ... lastTransitionTime: 2018-01-22T15:48:13Z lastUpdateTime: 2018-01-22T15:51:09Z message: | installing: Waiting: waiting for deployment etcd-operator to become ready: Waiting for rollout to finish: 0 of 1 updated replicas are available... phase: Installing reason: InstallWaiting ... ``` -------------------------------- ### Basic Usage of gziphandler Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/NYTimes/gziphandler/README.md Demonstrates how to wrap an existing http.Handler with gziphandler to enable transparent gzip compression for responses. This example shows setting up a simple handler and then applying the gzip handler. ```go package main import ( io "net/http" "github.com/NYTimes/gziphandler" ) func main() { withoutGz := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") io.WriteString(w, "Hello, World") }) withGz := gziphandler.GzipHandler(withoutGz) http.Handle("/", withGz) http.ListenAndServe("0.0.0.0:8000", nil) } ``` -------------------------------- ### Subscribe to Package and Channel Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/install/install.md Defines a Kubernetes Subscription resource to install operators from a catalog. This example subscribes to the 'etcd' and 'prometheus' operators from the 'operatorhubio-catalog' in the 'olm' namespace. ```yaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: etcd namespace: olm spec: channel: singlenamespace-alpha name: etcd source: operatorhubio-catalog sourceNamespace: olm --- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: prometheus namespace: olm spec: channel: alpha name: prometheus source: operatorhubio-catalog sourceNamespace: olm ``` -------------------------------- ### Example Go Module Requirement (Incorrect) Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/antlr4-go/antlr/v4/README.md Illustrates the problematic `go get` output when importing the ANTLR4 runtime directly from the main repository, leading to unclear versioning. ```go require ( github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc ) ``` -------------------------------- ### Operator Metadata Example Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/building-your-csv.md This YAML snippet demonstrates the structure and common fields for operator metadata, including keywords, version, maturity, maintainers, provider, labels, selectors, links, icon, and install modes. ```yaml keywords: ['etcd', 'key value', 'database', 'coreos', 'open source'] version: 0.9.2 maturity: alpha replaces: etcdoperator.v0.9.0 maintainers: - name: CoreOS, Inc email: support@coreos.com provider: name: CoreOS, Inc labels: alm-owner-etcd: etcdoperator operated-by: etcdoperator selector: matchLabels: alm-owner-etcd: etcdoperator operated-by: etcdoperator links: - name: Blog url: https://coreos.com/etcd - name: Documentation url: https://coreos.com/operators/etcd/docs/latest/ - name: etcd Operator Source Code url: https://github.com/coreos/etcd-operator icon: - base64data: mediatype: image/png installModes: - type: OwnNamespace supported: true - type: SingleNamespace supported: true - type: MultiNamespace supported: false - type: AllNamespaces supported: true ``` -------------------------------- ### Install go-openapi/jsonpointer Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/github.com/go-openapi/jsonpointer/README.md Use this command to add the jsonpointer library to your Go project. ```cmd go get github.com/go-openapi/jsonpointer ``` -------------------------------- ### Install bbolt Command Line Utility Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.etcd.io/bbolt/README.md Install the bbolt command line utility globally using 'go install'. The utility will be placed in your $GOBIN path. ```sh go install go.etcd.io/bbolt/cmd/bbolt@latest ``` -------------------------------- ### Coexist with glog Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/k8s.io/klog/v2/README.md Example demonstrating how to initialize and synchronize flags between klog and glog, and redirect output to stderr. ```go import ( flag "flag" "k8s.io/klog/v2" ) func main() { // Initialize klog flags klog.InitFlags(nil) // Parse command-line flags flag.Parse() // Ensure klog and glog flags are synchronized if both are used // (This example assumes glog is also imported and flags are managed) // Set alsologtostderr to true to redirect all logs to stderr klog.SetOutput(os.Stderr) // ... rest of your application logic ... klog.Info("Application started") } ``` -------------------------------- ### Install multierr Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.uber.org/multierr/README.md Use this command to install the latest version of the multierr library. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Instantiation with Options Source: https://github.com/operator-framework/operator-lifecycle-manager/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates how to instantiate a type `T` using a variadic `options` parameter of type `Option`. Required parameters can precede the options. ```go func NewT(options ...Option) T {…} ```