Skip to content

Commit a367d6c

Browse files
Merge pull request #484 from tmshort/synchronize
OPRUN-4164: Synchronize From Upstream Repositories
2 parents 1487ceb + fd85e1b commit a367d6c

File tree

154 files changed

+733
-4532
lines changed

Some content is hidden

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

154 files changed

+733
-4532
lines changed

Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ else
7171
$(warning Could not find docker or podman in path! This may result in targets requiring a container runtime failing!)
7272
endif
7373

74-
KUSTOMIZE_STANDARD_OVERLAY := config/overlays/standard
75-
KUSTOMIZE_STANDARD_E2E_OVERLAY := config/overlays/standard-e2e
76-
KUSTOMIZE_EXPERIMENTAL_OVERLAY := config/overlays/experimental
77-
KUSTOMIZE_EXPERIMENTAL_E2E_OVERLAY := config/overlays/experimental-e2e
78-
7974
export STANDARD_RELEASE_MANIFEST := operator-controller.yaml
8075
export STANDARD_RELEASE_INSTALL := install.sh
8176
export EXPERIMENTAL_RELEASE_MANIFEST := operator-controller-experimental.yaml
@@ -204,8 +199,8 @@ bingo-upgrade: $(BINGO) #EXHELP Upgrade tools
204199
.PHONY: verify-crd-compatibility
205200
CRD_DIFF_ORIGINAL_REF := git://main?path=
206201
CRD_DIFF_UPDATED_REF := file://
207-
CRD_DIFF_OPCON_SOURCE := config/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml
208-
CRD_DIFF_CATD_SOURCE := config/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml
202+
CRD_DIFF_OPCON_SOURCE := helm/olmv1/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml
203+
CRD_DIFF_CATD_SOURCE := helm/olmv1/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml
209204
CRD_DIFF_CONFIG := crd-diff-config.yaml
210205
verify-crd-compatibility: $(CRD_DIFF) manifests
211206
$(CRD_DIFF) --config="${CRD_DIFF_CONFIG}" "${CRD_DIFF_ORIGINAL_REF}${CRD_DIFF_OPCON_SOURCE}" ${CRD_DIFF_UPDATED_REF}${CRD_DIFF_OPCON_SOURCE}

OWNERS_ALIASES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ aliases:
2020
- thetechnick
2121
- tmshort
2222
- trgeiger
23+
- pedjak
2324

2425
api-approvers:
2526
- grokspawn

api/v1/clustercatalog_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"sigs.k8s.io/yaml"
2121
)
2222

23-
const crdFilePath = "../../config/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml"
23+
const crdFilePath = "../../helm/olmv1/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml"
2424

2525
func TestImageSourceCELValidationRules(t *testing.T) {
2626
validators := fieldValidatorsFromFile(t, crdFilePath)

api/v1/clusterextensionrevision_types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,22 @@ type ClusterExtensionRevisionSpec struct {
4949
// +kubebuilder:validation:Enum=Active;Paused;Archived
5050
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Active' || oldSelf == 'Paused' || oldSelf == 'Archived' && oldSelf == self", message="can not un-archive"
5151
LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`
52-
// Revision number orders changes over time, must always be previous revision +1.
52+
// Revision is a sequence number representing a specific revision of the ClusterExtension instance.
53+
// Must be positive. Each ClusterExtensionRevision of the same parent ClusterExtension needs to have
54+
// a unique value assigned. It is immutable after creation. The new revision number must always be previous revision +1.
5355
//
5456
// +kubebuilder:validation:Required
57+
// +kubebuilder:validation:Minimum:=1
5558
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="revision is immutable"
5659
Revision int64 `json:"revision"`
5760
// Phases are groups of objects that will be applied at the same time.
58-
// All objects in the a phase will have to pass their probes in order to progress to the next phase.
61+
// All objects in the phase will have to pass their probes in order to progress to the next phase.
5962
//
60-
// +kubebuilder:validation:Required
6163
// +kubebuilder:validation:XValidation:rule="self == oldSelf || oldSelf.size() == 0", message="phases is immutable"
6264
// +listType=map
6365
// +listMapKey=name
64-
Phases []ClusterExtensionRevisionPhase `json:"phases"`
66+
// +optional
67+
Phases []ClusterExtensionRevisionPhase `json:"phases,omitempty"`
6568
// Previous references previous revisions that objects can be adopted from.
6669
//
6770
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="previous is immutable"
@@ -104,6 +107,7 @@ type ClusterExtensionRevisionObject struct {
104107
// already existing on the cluster or even owned by another controller.
105108
//
106109
// +kubebuilder:default="Prevent"
110+
// +optional
107111
CollisionProtection CollisionProtection `json:"collisionProtection,omitempty"`
108112
}
109113

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
package v1
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"testing"
7+
8+
"github.com/stretchr/testify/require"
9+
"k8s.io/apimachinery/pkg/api/errors"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
)
12+
13+
func TestClusterExtensionRevisionImmutability(t *testing.T) {
14+
c := newClient(t)
15+
ctx := context.Background()
16+
i := 0
17+
for name, tc := range map[string]struct {
18+
spec ClusterExtensionRevisionSpec
19+
updateFunc func(*ClusterExtensionRevision)
20+
allowed bool
21+
}{
22+
"revision is immutable": {
23+
spec: ClusterExtensionRevisionSpec{
24+
Revision: 1,
25+
},
26+
updateFunc: func(cer *ClusterExtensionRevision) {
27+
cer.Spec.Revision = 2
28+
},
29+
},
30+
"phases may be initially empty": {
31+
spec: ClusterExtensionRevisionSpec{
32+
Revision: 1,
33+
Phases: []ClusterExtensionRevisionPhase{},
34+
},
35+
updateFunc: func(cer *ClusterExtensionRevision) {
36+
cer.Spec.Phases = []ClusterExtensionRevisionPhase{
37+
{
38+
Name: "foo",
39+
Objects: []ClusterExtensionRevisionObject{},
40+
},
41+
}
42+
},
43+
allowed: true,
44+
},
45+
"phases may be initially unset": {
46+
spec: ClusterExtensionRevisionSpec{
47+
Revision: 1,
48+
},
49+
updateFunc: func(cer *ClusterExtensionRevision) {
50+
cer.Spec.Phases = []ClusterExtensionRevisionPhase{
51+
{
52+
Name: "foo",
53+
Objects: []ClusterExtensionRevisionObject{},
54+
},
55+
}
56+
},
57+
allowed: true,
58+
},
59+
"phases are immutable if not empty": {
60+
spec: ClusterExtensionRevisionSpec{
61+
Revision: 1,
62+
Phases: []ClusterExtensionRevisionPhase{
63+
{
64+
Name: "foo",
65+
Objects: []ClusterExtensionRevisionObject{},
66+
},
67+
},
68+
},
69+
updateFunc: func(cer *ClusterExtensionRevision) {
70+
cer.Spec.Phases = []ClusterExtensionRevisionPhase{
71+
{
72+
Name: "foo2",
73+
Objects: []ClusterExtensionRevisionObject{},
74+
},
75+
}
76+
},
77+
},
78+
} {
79+
t.Run(name, func(t *testing.T) {
80+
cer := &ClusterExtensionRevision{
81+
ObjectMeta: metav1.ObjectMeta{
82+
Name: fmt.Sprintf("foo%d", i),
83+
},
84+
Spec: tc.spec,
85+
}
86+
i = i + 1
87+
require.NoError(t, c.Create(ctx, cer))
88+
tc.updateFunc(cer)
89+
err := c.Update(ctx, cer)
90+
if tc.allowed && err != nil {
91+
t.Fatal("expected update to succeed, but got:", err)
92+
}
93+
if !tc.allowed && !errors.IsInvalid(err) {
94+
t.Fatal("expected update to fail due to invalid payload, but got:", err)
95+
}
96+
})
97+
}
98+
}
99+
100+
func TestClusterExtensionRevisionValidity(t *testing.T) {
101+
c := newClient(t)
102+
ctx := context.Background()
103+
i := 0
104+
for name, tc := range map[string]struct {
105+
spec ClusterExtensionRevisionSpec
106+
valid bool
107+
}{
108+
"revision cannot be negative": {
109+
spec: ClusterExtensionRevisionSpec{
110+
Revision: -1,
111+
},
112+
valid: false,
113+
},
114+
"revision cannot be zero": {
115+
spec: ClusterExtensionRevisionSpec{},
116+
valid: false,
117+
},
118+
"revision must be positive": {
119+
spec: ClusterExtensionRevisionSpec{
120+
Revision: 1,
121+
},
122+
valid: true,
123+
},
124+
} {
125+
t.Run(name, func(t *testing.T) {
126+
cer := &ClusterExtensionRevision{
127+
ObjectMeta: metav1.ObjectMeta{
128+
Name: fmt.Sprintf("bar%d", i),
129+
},
130+
Spec: tc.spec,
131+
}
132+
i = i + 1
133+
err := c.Create(ctx, cer)
134+
if tc.valid && err != nil {
135+
t.Fatal("expected create to succeed, but got:", err)
136+
}
137+
if !tc.valid && !errors.IsInvalid(err) {
138+
t.Fatal("expected create to fail due to invalid payload, but got:", err)
139+
}
140+
})
141+
}
142+
}

api/v1/suite_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"log"
21+
"os"
22+
"testing"
23+
24+
"github.com/stretchr/testify/require"
25+
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
26+
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
27+
"k8s.io/client-go/rest"
28+
"sigs.k8s.io/controller-runtime/pkg/client"
29+
30+
"github.com/operator-framework/operator-controller/test"
31+
)
32+
33+
func newScheme(t *testing.T) *apimachineryruntime.Scheme {
34+
sch := apimachineryruntime.NewScheme()
35+
require.NoError(t, AddToScheme(sch))
36+
return sch
37+
}
38+
39+
func newClient(t *testing.T) client.Client {
40+
cl, err := client.New(config, client.Options{Scheme: newScheme(t)})
41+
require.NoError(t, err)
42+
require.NotNil(t, cl)
43+
return cl
44+
}
45+
46+
var config *rest.Config
47+
48+
func TestMain(m *testing.M) {
49+
testEnv := test.NewEnv()
50+
51+
var err error
52+
config, err = testEnv.Start()
53+
utilruntime.Must(err)
54+
if config == nil {
55+
log.Panic("expected cfg to not be nil")
56+
}
57+
58+
code := m.Run()
59+
utilruntime.Must(testEnv.Stop())
60+
os.Exit(code)
61+
}

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: 33fdce258350eb563885ee41da087491a15829bd
1+
expectedMergeBase: 0faf118ce37219d518ed380d76101fc3a083a3dd
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

config/README.md

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,5 @@
11
# OPERATOR-CONTROLLER CONFIGURATION
22

3-
The main kustomize targets are all located in the `config/overlays` directory. These are the directories that should be passed to kustomize:
4-
5-
e.g.
6-
```
7-
kustomize build config/overlays/standard > standard.yaml
8-
```
9-
10-
# Overlays
11-
12-
All other directories are in support of of these overlays.
13-
14-
## config/overlays/basic-olm
15-
16-
This includes basic support for an insecure (non-TLS) OLMv1 deployment.
17-
18-
## config/overlays/standard
19-
20-
This includes support for a secure (i.e. with TLS) configuration of OLMv1. This configuration requires cert-manager.
21-
22-
This configuration is used to generate `manifests/standard.yaml`.
23-
24-
## config/overlays/standard-e2e
25-
26-
This provides additional configuration support for end-to-end testing, including code coverage. This configuration requires cert-manager.
27-
28-
This configuration is used to generate `manifests/standard-e2e.yaml`.
29-
30-
## config/overlays/prometheus
31-
32-
Overlay containing manifest files which enable prometheus scraping of the catalogd and operator-controller pods. Used during e2e runs to measure performance over the lifetime of the test.
33-
34-
These manifests will not end up in the `manifests/` folder, as they must be applied in two distinct steps to avoid issues with applying prometheus CRDs and CRs simultaneously.
35-
36-
Performance alert settings can be found in: `config/overlays/prometheus/prometheus_rule.yaml`
37-
38-
## config/overlays/experimental
39-
40-
This provides additional configuration used to support experimental features, including CRDs. This configuration requires cert-manager.
41-
42-
This configuration is used to generate `manifests/experimental.yaml`.
43-
44-
## config/overlays/experimental-e2e
45-
46-
This provides experimental configuration and support for end-to-end testing, includng code coverage. This configuration requires cert-manager.
47-
48-
This configuration is used to generate `manifests/experimental-e2e.yaml`.
49-
50-
## config/overlays/tilt-local-dev
51-
52-
This provides configuration for Tilt debugging support.
53-
54-
# Components
55-
56-
Components are the kustomize configuration building blocks.
57-
58-
## config/components/base
59-
60-
This directory provides multiple configurations for organizing the base configuration into standard and experimental configurations.
61-
62-
:bangbang: *The following rules should be followed when configurating a feature:*
63-
64-
* Feature components that are GA'd and should be part of the standard manifest should be listed in `config/components/base/common/kustomization.yaml`. This `commmon` kustomization file is included by *both* the **standard** and **experimental** configurations.
65-
* Feature components that are still experimental and should be part of the standard manifest should be listed only in `config/components/base/experimental/kustomization.yaml`.
66-
67-
## config/components/features
68-
69-
This directory contains contains configuration for features (experimental or otherwise).
70-
71-
:bangbang: *Feature configuration should be placed into a subdirectory here.*
72-
73-
## config/components/cert-manager
74-
75-
This directory provides configuration for using cert-manager with OLMv1.
76-
77-
## config/components/e2e
78-
79-
This directory provides configuration for end-to-end testing of OLMv1.
80-
81-
# Base Configuration
82-
83-
The `config/base` directory contains the base kubebuilder-generated configuration, along with CRDs.
84-
85-
# Samples
3+
## Samples
864

875
The `config/samples` directory contains example ClusterCatalog and ClusterExtension resources.

config/base/catalogd/crd/OWNERS

Lines changed: 0 additions & 2 deletions
This file was deleted.

config/base/catalogd/crd/experimental/kustomization.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)