Skip to content

Commit ce6cde0

Browse files
committed
AMEND ME
1 parent 416ee7b commit ce6cde0

File tree

492 files changed

+212598
-2187
lines changed

Some content is hidden

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

492 files changed

+212598
-2187
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CMDS := $(shell go list $(MOD_FLAGS) ./cmd/...)
99
TCMDS := $(shell go list $(MOD_FLAGS) ./test/e2e/...)
1010
MOCKGEN := ./scripts/update_mockgen.sh
1111
CODEGEN := ./scripts/update_codegen.sh
12+
GEN_PATHS := "./pkg/api/apis/operators/v2alpha1/..."
1213
IMAGE_REPO := quay.io/operator-framework/olm
1314
IMAGE_TAG ?= "dev"
1415
SPECIFIC_UNIT_TEST := $(if $(TEST),-run $(TEST),)
@@ -32,7 +33,7 @@ endif
3233
GIT_COMMIT := $(if $(SOURCE_GIT_COMMIT),$(SOURCE_GIT_COMMIT),$(shell git rev-parse HEAD))
3334

3435
.PHONY: build test run clean vendor schema-check \
35-
vendor-update coverage coverage-html e2e .FORCE
36+
vendor-update coverage coverage-html e2e manifests controller-gen .FORCE
3637

3738
all: test build
3839

@@ -138,13 +139,18 @@ clean:
138139
@rm -rf test/e2e/log
139140
@rm -rf e2e.namespace
140141

142+
# Generate manifests for CRDs
143+
# Use trivialVersions=true to generate CRDs w/o conversion webhooks for now
144+
manifests: controller-gen
145+
$(CONTROLLER_GEN) crd:trivialVersions=true paths=$(GEN_PATHS) output:crd:artifacts:config="config/crd/bases"
146+
141147
codegen: codegen-v2 codegen-v1
142148

143149
codegen-v1: vendor
144150
$(CODEGEN)
145151

146152
codegen-v2: controller-gen
147-
$(CONTROLLER_GEN) object:headerFile=boilerplate.go.txt paths="./pkg/api/apis/operators/v2alpha1/..."
153+
$(CONTROLLER_GEN) object:headerFile=boilerplate.go.txt paths=$(GEN_PATHS)
148154

149155
# Find or download controller-gen.
150156
# Note: v0.2.1 is incompatible with k8s 1.16 deps, so download is broken until controller-tools is bumped.
@@ -180,9 +186,6 @@ verify-release:
180186
rm -rf manifests
181187
mkdir manifests
182188
./scripts/package_release.sh $(ver) manifests deploy/ocp/values.yaml
183-
# requires gnu sed if on mac
184-
find ./manifests -type f -exec sed -i "/^#/d" {} \;
185-
find ./manifests -type f -exec sed -i "1{/---/d}" {} \;
186189
git diff --exit-code
187190

188191
# before running release, bump the version in OLM_VERSION and push to master,
@@ -195,9 +198,6 @@ release:
195198
rm -rf manifests
196199
mkdir manifests
197200
cp -R deploy/ocp/manifests/$(ver)/. manifests
198-
# requires gnu sed if on mac
199-
find ./manifests -type f -exec sed -i "/^#/d" {} \;
200-
find ./manifests -type f -exec sed -i "1{/---/d}" {} \;
201201

202202
package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' quay.io/operator-framework/olm:$(ver))
203203
package:

cmd/catalog/main.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"flag"
65
"fmt"
76
"net/http"
87
"os"
@@ -12,6 +11,7 @@ import (
1211
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
1312
"github.com/prometheus/client_golang/prometheus/promhttp"
1413
log "github.com/sirupsen/logrus"
14+
"github.com/spf13/pflag"
1515
v1 "k8s.io/api/core/v1"
1616
utilclock "k8s.io/apimachinery/pkg/util/clock"
1717
"k8s.io/client-go/tools/clientcmd"
@@ -36,36 +36,36 @@ const (
3636

3737
// config flags defined globally so that they appear on the test binary as well
3838
var (
39-
kubeConfigPath = flag.String(
39+
kubeConfigPath = pflag.String(
4040
"kubeconfig", "", "absolute path to the kubeconfig file")
4141

42-
wakeupInterval = flag.Duration(
42+
wakeupInterval = pflag.Duration(
4343
"interval", defaultWakeupInterval, "wakeup interval")
4444

45-
watchedNamespaces = flag.String(
45+
watchedNamespaces = pflag.String(
4646
"watchedNamespaces", "", "comma separated list of namespaces that catalog watches, leave empty to watch all namespaces")
4747

48-
catalogNamespace = flag.String(
48+
catalogNamespace = pflag.String(
4949
"namespace", defaultCatalogNamespace, "namespace where catalog will run and install catalog resources")
5050

51-
configmapServerImage = flag.String(
51+
configmapServerImage = pflag.String(
5252
"configmapServerImage", defaultConfigMapServerImage, "the image to use for serving the operator registry api for a configmap")
5353

54-
writeStatusName = flag.String(
54+
writeStatusName = pflag.String(
5555
"writeStatusName", defaultOperatorName, "ClusterOperator name in which to write status, set to \"\" to disable.")
5656

57-
debug = flag.Bool(
57+
debug = pflag.Bool(
5858
"debug", false, "use debug log level")
5959

60-
version = flag.Bool("version", false, "displays olm version")
60+
version = pflag.Bool("version", false, "displays olm version")
6161

62-
tlsKeyPath = flag.String(
62+
tlsKeyPath = pflag.String(
6363
"tls-key", "", "Path to use for private key (requires tls-cert)")
6464

65-
tlsCertPath = flag.String(
65+
tlsCertPath = pflag.String(
6666
"tls-cert", "", "Path to use for certificate key (requires tls-key)")
6767

68-
profiling = flag.Bool(
68+
profiling = pflag.Bool(
6969
"profiling", false, "serve profiling data (on port 8080)")
7070
)
7171

@@ -79,7 +79,7 @@ func main() {
7979
defer cancel()
8080

8181
// Parse the command-line flags.
82-
flag.Parse()
82+
pflag.Parse()
8383

8484
// Check if version flag was set
8585
if *version {

cmd/olm/main.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"flag"
65
"fmt"
76
"net/http"
87
"os"
@@ -13,10 +12,12 @@ import (
1312
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
1413
"github.com/prometheus/client_golang/prometheus/promhttp"
1514
"github.com/sirupsen/logrus"
15+
"github.com/spf13/pflag"
1616
v1 "k8s.io/api/core/v1"
1717

1818
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
1919
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm"
20+
"github.com/operator-framework/operator-lifecycle-manager/pkg/features"
2021
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
2122
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
2223
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/profile"
@@ -33,43 +34,43 @@ const (
3334

3435
// config flags defined globally so that they appear on the test binary as well
3536
var (
36-
// kubeConfigPath = flag.String(
37-
// "kubeconfig", "", "absolute path to the kubeconfig file")
38-
39-
wakeupInterval = flag.Duration(
37+
wakeupInterval = pflag.Duration(
4038
"interval", defaultWakeupInterval, "wake up interval")
4139

42-
watchedNamespaces = flag.String(
40+
watchedNamespaces = pflag.String(
4341
"watchedNamespaces", "", "comma separated list of namespaces for olm operator to watch. "+
4442
"If not set, or set to the empty string (e.g. `-watchedNamespaces=\"\"`), "+
4543
"olm operator will watch all namespaces in the cluster.")
4644

47-
writeStatusName = flag.String(
45+
writeStatusName = pflag.String(
4846
"writeStatusName", defaultOperatorName, "ClusterOperator name in which to write status, set to \"\" to disable.")
4947

50-
writePackageServerStatusName = flag.String(
48+
writePackageServerStatusName = pflag.String(
5149
"writePackageServerStatusName", defaultPackageServerStatusName, "ClusterOperator name in which to write status for package API server, set to \"\" to disable.")
5250

53-
debug = flag.Bool(
51+
debug = pflag.Bool(
5452
"debug", false, "use debug log level")
5553

56-
version = flag.Bool("version", false, "displays olm version")
54+
version = pflag.Bool("version", false, "displays olm version")
5755

58-
tlsKeyPath = flag.String(
56+
tlsKeyPath = pflag.String(
5957
"tls-key", "", "Path to use for private key (requires tls-cert)")
6058

61-
tlsCertPath = flag.String(
59+
tlsCertPath = pflag.String(
6260
"tls-cert", "", "Path to use for certificate key (requires tls-key)")
6361

64-
profiling = flag.Bool(
62+
profiling = pflag.Bool(
6563
"profiling", false, "serve profiling data (on port 8080)")
6664

67-
namespace = flag.String(
65+
namespace = pflag.String(
6866
"namespace", "", "namespace where cleanup runs")
6967
)
7068

7169
func init() {
7270
metrics.RegisterOLM()
71+
72+
// Add feature gates before parsing
73+
features.AddFlag(pflag.CommandLine)
7374
}
7475

7576
// main function - entrypoint to OLM operator
@@ -79,7 +80,7 @@ func main() {
7980
defer cancel()
8081

8182
// Parse the command-line flags.
82-
flag.Parse()
83+
pflag.Parse()
8384

8485
// Check if version flag was set
8586
if *version {
@@ -215,6 +216,7 @@ func main() {
215216
go monitor.Run(op.Done())
216217
}
217218

219+
// Start the controller manager
218220
if err := mgr.Start(ctx.Done()); err != nil {
219221
logger.WithError(err).Fatal("controller manager stopped")
220222
}

cmd/olm/manager.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package main
22

33
import (
4-
"k8s.io/apimachinery/pkg/runtime"
54
ctrl "sigs.k8s.io/controller-runtime"
65
"sigs.k8s.io/controller-runtime/pkg/log/zap"
76

87
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operator"
8+
"github.com/operator-framework/operator-lifecycle-manager/pkg/features"
99
)
1010

1111
var log = ctrl.Log.WithName("olm-manager")
@@ -16,15 +16,20 @@ func Manager() (ctrl.Manager, error) {
1616

1717
// Setup a Manager
1818
setupLog.Info("configuring manager")
19-
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{Scheme: runtime.NewScheme(), MetricsBindAddress: "0"}) // TODO: Enable metrics on non-conflicting port (not 8080)
19+
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{MetricsBindAddress: "0"}) // TODO: Enable metrics on non-conflicting port (not 8080)
2020
if err != nil {
2121
return nil, err
2222
}
2323

2424
// Setup a new controller to reconcile Operators
2525
setupLog.Info("configuring controller")
26-
if err := operator.AddController(mgr, log); err != nil {
27-
return nil, err
26+
27+
if features.Gate.Enabled(features.OperatorLifecycleManagerV2) {
28+
setupLog.Info("feature enabled: %v", features.OperatorLifecycleManagerV2)
29+
30+
if err := operator.AddController(mgr, log); err != nil {
31+
return nil, err
32+
}
2833
}
2934

3035
setupLog.Info("manager configured")

0 commit comments

Comments
 (0)