Skip to content

Commit 951e630

Browse files
author
Per Goncalves da Silva
committed
Prune v2.0.0 test-operator
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent afd2706 commit 951e630

13 files changed

+38
-59
lines changed

test/test-operator/v2.0.0/api/v1/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ limitations under the License.
1515
*/
1616

1717
// Package v1 contains API Schema definitions for the testolm v1 API group.
18-
// +kubebuilder:object:generate=true
19-
// +groupName=testolm.operator-framework.io
18+
// +kubebuilder:object:generate=false
19+
// +groupName=testolm.operatorframework.io
2020
package v1
2121

2222
import (
@@ -26,7 +26,7 @@ import (
2626

2727
var (
2828
// GroupVersion is group version used to register these objects.
29-
GroupVersion = schema.GroupVersion{Group: "testolm.operator-framework.io", Version: "v1"}
29+
GroupVersion = schema.GroupVersion{Group: "testolm.operatorframework.io", Version: "v1"}
3030

3131
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

test/test-operator/v2.0.0/api/v1/testoperator_conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
"sigs.k8s.io/controller-runtime/pkg/conversion"
2323

24-
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v2"
24+
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/api/v2"
2525
)
2626

2727
// ConvertTo converts this TestOperator (v1) to the Hub version (v2).

test/test-operator/v2.0.0/api/v2/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ limitations under the License.
1515
*/
1616

1717
// Package v2 contains API Schema definitions for the testolm v2 API group.
18-
// +kubebuilder:object:generate=true
19-
// +groupName=testolm.operator-framework.io
18+
// +kubebuilder:object:generate=false
19+
// +groupName=testolm.operatorframework.io
2020
package v2
2121

2222
import (
@@ -26,7 +26,7 @@ import (
2626

2727
var (
2828
// GroupVersion is group version used to register these objects.
29-
GroupVersion = schema.GroupVersion{Group: "testolm.operator-framework.io", Version: "v2"}
29+
GroupVersion = schema.GroupVersion{Group: "testolm.operatorframework.io", Version: "v2"}
3030

3131
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

test/test-operator/v2.0.0/bin/manager

51.2 MB
Binary file not shown.

test/test-operator/v2.0.0/bundle/manifests/test-operator.v2.0.0.clusterserviceversion.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ spec:
104104
valueFrom:
105105
fieldRef:
106106
fieldPath: metadata.annotations['olm.targetNamespaces']
107-
image: docker-registry.operator-controller-e2e.svc:5000/controllers/test-operator:v2.0.0
107+
image: docker.io/perdasilva/test-operator:v2.0.0
108108
livenessProbe:
109109
httpGet:
110110
path: /healthz
@@ -211,7 +211,7 @@ spec:
211211
type: ConversionWebhook
212212
webhookPath: /convert
213213
- admissionReviewVersions:
214-
- v2
214+
- v1
215215
containerPort: 443
216216
deploymentName: test-operator-controller-manager
217217
failurePolicy: Fail
@@ -231,7 +231,7 @@ spec:
231231
type: MutatingAdmissionWebhook
232232
webhookPath: /mutate-testolm-test-operatorframework-io-v2-testoperator
233233
- admissionReviewVersions:
234-
- v2
234+
- v1
235235
containerPort: 443
236236
deploymentName: test-operator-controller-manager
237237
failurePolicy: Fail
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
annotations:
2-
# Core bundle annotations.
32
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
43
operators.operatorframework.io.bundle.manifests.v1: manifests/
54
operators.operatorframework.io.bundle.metadata.v1: metadata/
6-
operators.operatorframework.io.bundle.package.v1: v1
5+
operators.operatorframework.io.bundle.package.v1: test-operator
76
operators.operatorframework.io.bundle.channels.v1: alpha
8-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.40.0+git
9-
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
10-
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v4

test/test-operator/v2.0.0/cmd/main.go

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
"crypto/tls"
2121
"flag"
22-
"fmt"
2322
"os"
2423
"path/filepath"
2524
"sigs.k8s.io/controller-runtime/pkg/cache"
@@ -39,11 +38,10 @@ import (
3938
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4039
"sigs.k8s.io/controller-runtime/pkg/webhook"
4140

42-
testolmv1 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v1"
43-
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v2"
44-
"github.com/operator-framework/operator-controller/test/test-operator/v2/internal/controller"
45-
webhookv1 "github.com/operator-framework/operator-controller/test/test-operator/v2/internal/webhook/v1"
46-
webhookv2 "github.com/operator-framework/operator-controller/test/test-operator/v2/internal/webhook/v2"
41+
testolmv1 "github.com/operator-framework/operator-controller/test/test-operator/v1.0.0/api/v1"
42+
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/api/v2"
43+
"github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/internal/controller"
44+
testolmwebhook "github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/internal/webhook"
4745
// +kubebuilder:scaffold:imports
4846
)
4947

@@ -184,19 +182,15 @@ func main() {
184182
})
185183
}
186184

187-
watchNamespace, err := getWatchNamespace()
188-
if err != nil {
189-
setupLog.Error(err, "unable to get WatchNamespace, "+
190-
"the manager will watch and manage resources in all namespaces")
191-
}
185+
watchNamespace := getWatchNamespace()
192186

193187
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
194188
Scheme: scheme,
195189
Metrics: metricsServerOptions,
196190
WebhookServer: webhookServer,
197191
HealthProbeBindAddress: probeAddr,
198192
LeaderElection: enableLeaderElection,
199-
LeaderElectionID: "e10ca34c.operator-framework.io",
193+
LeaderElectionID: "e10ca34c.operatorframework.io",
200194
Cache: cache.Options{
201195
DefaultNamespaces: map[string]cache.Config{watchNamespace: {}},
202196
},
@@ -226,14 +220,7 @@ func main() {
226220
}
227221
// nolint:goconst
228222
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
229-
if err := webhookv1.SetupTestOperatorWebhookWithManager(mgr); err != nil {
230-
setupLog.Error(err, "unable to create webhook", "webhook", "TestOperator")
231-
os.Exit(1)
232-
}
233-
}
234-
// nolint:goconst
235-
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
236-
if err := webhookv2.SetupTestOperatorWebhookWithManager(mgr); err != nil {
223+
if err := testolmwebhook.SetupTestOperatorWebhookWithManager(mgr); err != nil {
237224
setupLog.Error(err, "unable to create webhook", "webhook", "TestOperator")
238225
os.Exit(1)
239226
}
@@ -273,15 +260,12 @@ func main() {
273260
}
274261

275262
// getWatchNamespace returns the Namespace the operator should be watching for changes
276-
func getWatchNamespace() (string, error) {
263+
func getWatchNamespace() string {
277264
// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
278265
// which specifies the Namespace to watch.
279266
// An empty value means the operator is running with cluster scope.
280267
var watchNamespaceEnvVar = "WATCH_NAMESPACE"
281268

282-
ns, found := os.LookupEnv(watchNamespaceEnvVar)
283-
if !found {
284-
return "", fmt.Errorf("%s must be set", watchNamespaceEnvVar)
285-
}
286-
return ns, nil
269+
ns, _ := os.LookupEnv(watchNamespaceEnvVar)
270+
return ns
287271
}

test/test-operator/v2.0.0/internal/controller/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package controller
1818

1919
import (
2020
"context"
21-
testolmv1 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v1"
22-
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v2"
21+
testolmv1 "github.com/operator-framework/operator-controller/test/test-operator/v1.0.0/api/v1"
22+
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/api/v2"
2323
"os"
2424
"path/filepath"
2525
"testing"

test/test-operator/v2.0.0/internal/controller/testoperator_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package controller
1919
import (
2020
"context"
2121
"fmt"
22-
testolmv1 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v1"
22+
23+
testolmv1 "github.com/operator-framework/operator-controller/test/test-operator/v1.0.0/api/v1"
24+
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/api/v2"
2325

2426
"k8s.io/apimachinery/pkg/api/equality"
2527
crfinalizer "sigs.k8s.io/controller-runtime/pkg/finalizer"
@@ -28,8 +30,6 @@ import (
2830
ctrl "sigs.k8s.io/controller-runtime"
2931
"sigs.k8s.io/controller-runtime/pkg/client"
3032
"sigs.k8s.io/controller-runtime/pkg/log"
31-
32-
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v2"
3333
)
3434

3535
const (
@@ -43,9 +43,9 @@ type TestOperatorReconciler struct {
4343
Finalizers crfinalizer.Finalizers
4444
}
4545

46-
// +kubebuilder:rbac:groups=testolm.operator-framework.io,resources=testoperators,verbs=get;list;watch;create;update;patch;delete
47-
// +kubebuilder:rbac:groups=testolm.operator-framework.io,resources=testoperators/status,verbs=get;update;patch
48-
// +kubebuilder:rbac:groups=testolm.operator-framework.io,resources=testoperators/finalizers,verbs=update
46+
// +kubebuilder:rbac:groups=testolm.operatorframework.io,resources=testoperators,verbs=get;list;watch;create;update;patch;delete
47+
// +kubebuilder:rbac:groups=testolm.operatorframework.io,resources=testoperators/status,verbs=get;update;patch
48+
// +kubebuilder:rbac:groups=testolm.operatorframework.io,resources=testoperators/finalizers,verbs=update
4949

5050
func (r *TestOperatorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
5151
l := log.FromContext(ctx).WithName("test-operator")

test/test-operator/v2.0.0/internal/controller/testoperator_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030

31-
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2/api/v2"
31+
testolmv2 "github.com/operator-framework/operator-controller/test/test-operator/v2.0.0/api/v2"
3232
)
3333

3434
var _ = Describe("TestOperator Controller", func() {

0 commit comments

Comments
 (0)