Skip to content

Commit 639fc12

Browse files
Merge pull request #612 from openshift-bot/synchronize-upstream
OPECO-3066: Synchronize From Upstream Repositories
2 parents 464202c + d663a0d commit 639fc12

File tree

56 files changed

+2177
-473
lines changed

Some content is hidden

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

56 files changed

+2177
-473
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/openshift/api v3.9.0+incompatible
1616
github.com/operator-framework/api v0.19.0
1717
github.com/operator-framework/operator-lifecycle-manager v0.0.0-00010101000000-000000000000
18-
github.com/operator-framework/operator-registry v1.30.1
18+
github.com/operator-framework/operator-registry v1.32.0
1919
github.com/sirupsen/logrus v1.9.2
2020
github.com/spf13/cobra v1.7.0
2121
github.com/stretchr/testify v1.8.3

staging/api/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.19
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
7-
github.com/ghodss/yaml v1.0.0
87
github.com/go-bindata/go-bindata/v3 v3.1.3
98
github.com/google/cel-go v0.15.3
109
github.com/sirupsen/logrus v1.9.2
@@ -16,6 +15,7 @@ require (
1615
k8s.io/apimachinery v0.27.7
1716
k8s.io/client-go v0.27.7
1817
sigs.k8s.io/controller-runtime v0.15.0
18+
sigs.k8s.io/yaml v1.3.0
1919
)
2020

2121
require (
@@ -91,5 +91,4 @@ require (
9191
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect
9292
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
9393
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
94-
sigs.k8s.io/yaml v1.3.0 // indirect
9594
)

staging/api/go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
7878
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
7979
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
8080
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
81-
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
8281
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
8382
github.com/go-bindata/go-bindata/v3 v3.1.3 h1:F0nVttLC3ws0ojc7p60veTurcOm//D4QBODNM7EGrCI=
8483
github.com/go-bindata/go-bindata/v3 v3.1.3/go.mod h1:1/zrpXsLD8YDIbhZRqXzm1Ghc7NhEvIN9+Z6R5/xH4I=

staging/api/pkg/validation/internal/crd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1010
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
1111

12-
"github.com/ghodss/yaml"
12+
"sigs.k8s.io/yaml"
1313
)
1414

1515
func TestValidateCRD(t *testing.T) {

staging/api/pkg/validation/internal/csv_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88

99
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
1010

11-
"github.com/ghodss/yaml"
1211
"github.com/operator-framework/api/pkg/validation/errors"
1312
"k8s.io/apimachinery/pkg/runtime/schema"
13+
"sigs.k8s.io/yaml"
1414
)
1515

1616
func TestValidateCSV(t *testing.T) {

staging/api/pkg/validation/internal/object_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package internal
22

33
import (
4-
"github.com/ghodss/yaml"
54
"io/ioutil"
6-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
75
"testing"
6+
7+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
8+
"sigs.k8s.io/yaml"
89
)
910

1011
func TestValidateObject(t *testing.T) {

staging/api/pkg/validation/internal/operatorgroup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"path/filepath"
66
"testing"
77

8-
"github.com/ghodss/yaml"
98
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
109
"github.com/operator-framework/api/pkg/validation/errors"
10+
"sigs.k8s.io/yaml"
1111
)
1212

1313
func TestValidateOperatorGroup(t *testing.T) {

staging/operator-lifecycle-manager/.github/workflows/sanity.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ jobs:
2727
uses: "golangci/golangci-lint-action@v3"
2828
with:
2929
version: "v1.51.1"
30+

staging/operator-lifecycle-manager/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.20
55
require (
66
github.com/blang/semver/v4 v4.0.0
77
github.com/coreos/go-semver v0.3.0
8-
github.com/davecgh/go-spew v1.1.1
98
github.com/distribution/distribution v2.7.1+incompatible
109
github.com/evanphx/json-patch v5.6.0+incompatible
1110
github.com/fsnotify/fsnotify v1.6.0
@@ -25,8 +24,8 @@ require (
2524
github.com/onsi/gomega v1.27.7
2625
github.com/openshift/api v3.9.0+incompatible
2726
github.com/openshift/client-go v0.0.0-20220525160904-9e1acff93e4a
28-
github.com/operator-framework/api v0.18.0
29-
github.com/operator-framework/operator-registry v1.30.1
27+
github.com/operator-framework/api v0.19.0
28+
github.com/operator-framework/operator-registry v1.32.0
3029
github.com/otiai10/copy v1.12.0
3130
github.com/pkg/errors v0.9.1
3231
github.com/prometheus/client_golang v1.15.1
@@ -90,6 +89,7 @@ require (
9089
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
9190
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
9291
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
92+
github.com/davecgh/go-spew v1.1.1 // indirect
9393
github.com/docker/cli v23.0.1+incompatible // indirect
9494
github.com/docker/distribution v2.8.2+incompatible // indirect
9595
github.com/docker/docker v23.0.3+incompatible // indirect

staging/operator-lifecycle-manager/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,10 @@ github.com/openshift/api v0.0.0-20221021112143-4226c2167e40 h1:PxjGCA72RtsdHWToZ
604604
github.com/openshift/api v0.0.0-20221021112143-4226c2167e40/go.mod h1:aQ6LDasvHMvHZXqLHnX2GRmnfTWCF/iIwz8EMTTIE9A=
605605
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c h1:CV76yFOTXmq9VciBR3Bve5ZWzSxdft7gaMVB3kS0rwg=
606606
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c/go.mod h1:lFMO8mLHXWFzSdYvGNo8ivF9SfF6zInA8ZGw4phRnUE=
607-
github.com/operator-framework/api v0.18.0 h1:6EdSNeAjin4LRu2YQnQWMJMc6HXS0AQDG+CfaEvFrAo=
608-
github.com/operator-framework/api v0.18.0/go.mod h1:SCCslqke6AVOJ5JM+NqNE1CHuAgJLScsL66pnPaSMXs=
609-
github.com/operator-framework/operator-registry v1.30.1 h1:7XvISZrwi+j9z4MIiApRRU+K7v3qMXIcgBs88eQ724Q=
610-
github.com/operator-framework/operator-registry v1.30.1/go.mod h1:iKVnZsuGjPm6h/jPn4WyQ7JFguRCZMUN+YmsEMu6byA=
607+
github.com/operator-framework/api v0.19.0 h1:QU1CTJU+CufoeneA5rsNlP/uP96s8vDHWUYDFZTauzA=
608+
github.com/operator-framework/api v0.19.0/go.mod h1:SCCslqke6AVOJ5JM+NqNE1CHuAgJLScsL66pnPaSMXs=
609+
github.com/operator-framework/operator-registry v1.32.0 h1:RNazXYt3vBf5FZ+JrNNjq4bNh3tDwlkwZJnC+kmCeKk=
610+
github.com/operator-framework/operator-registry v1.32.0/go.mod h1:89VshAf6+n0V12vdh43+WOi8i1+XpY+kg6Ao4JO0y6k=
611611
github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY=
612612
github.com/otiai10/copy v1.12.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww=
613613
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=

staging/operator-lifecycle-manager/pkg/controller/install/deployment.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package install
22

33
import (
44
"fmt"
5-
"hash/fnv"
65
"time"
76

87
log "github.com/sirupsen/logrus"
98
appsv1 "k8s.io/api/apps/v1"
109
corev1 "k8s.io/api/core/v1"
1110
apierrors "k8s.io/apimachinery/pkg/api/errors"
1211
k8slabels "k8s.io/apimachinery/pkg/labels"
13-
"k8s.io/apimachinery/pkg/util/rand"
1412
"k8s.io/utils/pointer"
1513

1614
"github.com/operator-framework/api/pkg/operators/v1alpha1"
@@ -181,7 +179,10 @@ func (i *StrategyDeploymentInstaller) deploymentForSpec(name string, spec appsv1
181179
// to 2 ReplicaSets per deployment it manages, saving memory.
182180
dep.Spec.RevisionHistoryLimit = pointer.Int32(1)
183181

184-
hash = HashDeploymentSpec(dep.Spec)
182+
hash, err = hashutil.DeepHashObject(&dep.Spec)
183+
if err != nil {
184+
return nil, "", err
185+
}
185186
dep.Labels[DeploymentSpecHashLabelKey] = hash
186187

187188
deployment = dep
@@ -327,11 +328,3 @@ func (i *StrategyDeploymentInstaller) cleanupOrphanedDeployments(deploymentSpecs
327328

328329
return nil
329330
}
330-
331-
// HashDeploymentSpec calculates a hash given a copy of the deployment spec from a CSV, stripping any
332-
// operatorgroup annotations.
333-
func HashDeploymentSpec(spec appsv1.DeploymentSpec) string {
334-
hasher := fnv.New32a()
335-
hashutil.DeepHashObject(hasher, &spec)
336-
return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))
337-
}

staging/operator-lifecycle-manager/pkg/controller/install/deployment_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"testing"
66

7+
hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
78
"github.com/stretchr/testify/assert"
89
"github.com/stretchr/testify/require"
910
appsv1 "k8s.io/api/apps/v1"
@@ -352,7 +353,11 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
352353
dep := testDeployment("olm-dep-1", namespace, &mockOwner)
353354
dep.Spec.Template.SetAnnotations(map[string]string{"test": "annotation"})
354355
dep.Spec.RevisionHistoryLimit = &revisionHistoryLimit
355-
dep.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, HashDeploymentSpec(dep.Spec)))
356+
hash, err := hashutil.DeepHashObject(&dep.Spec)
357+
if err != nil {
358+
t.Fatal(err)
359+
}
360+
dep.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, hash))
356361
dep.Labels[OLMManagedLabelKey] = OLMManagedLabelValue
357362
dep.Status.Conditions = append(dep.Status.Conditions, appsv1.DeploymentCondition{
358363
Type: appsv1.DeploymentAvailable,
@@ -374,7 +379,11 @@ func TestInstallStrategyDeploymentCheckInstallErrors(t *testing.T) {
374379
deployment := testDeployment("olm-dep-1", namespace, &mockOwner)
375380
deployment.Spec.Template.SetAnnotations(map[string]string{"test": "annotation"})
376381
deployment.Spec.RevisionHistoryLimit = &revisionHistoryLimit
377-
deployment.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, HashDeploymentSpec(deployment.Spec)))
382+
hash, err = hashutil.DeepHashObject(&deployment.Spec)
383+
if err != nil {
384+
t.Fatal(err)
385+
}
386+
deployment.SetLabels(labels.CloneAndAddLabel(dep.ObjectMeta.GetLabels(), DeploymentSpecHashLabelKey, hash))
378387
fakeClient.CreateOrUpdateDeploymentReturns(&deployment, tt.createDeploymentErr)
379388
defer func() {
380389
require.Equal(t, &deployment, fakeClient.CreateOrUpdateDeploymentArgsForCall(0))

staging/operator-lifecycle-manager/pkg/controller/install/webhook.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ package install
33
import (
44
"context"
55
"fmt"
6-
"hash/fnv"
76

87
log "github.com/sirupsen/logrus"
98
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
109
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1211
"k8s.io/apimachinery/pkg/labels"
13-
"k8s.io/apimachinery/pkg/util/rand"
1412
"k8s.io/client-go/util/retry"
1513

1614
"github.com/operator-framework/api/pkg/operators/v1alpha1"
@@ -285,17 +283,14 @@ func addWebhookLabels(object metav1.Object, webhookDesc v1alpha1.WebhookDescript
285283
if labels == nil {
286284
labels = map[string]string{}
287285
}
286+
hash, err := hashutil.DeepHashObject(&webhookDesc)
287+
if err != nil {
288+
return err
289+
}
288290
labels[WebhookDescKey] = webhookDesc.GenerateName
289-
labels[WebhookHashKey] = HashWebhookDesc(webhookDesc)
291+
labels[WebhookHashKey] = hash
290292
labels[OLMManagedLabelKey] = OLMManagedLabelValue
291293
object.SetLabels(labels)
292294

293295
return nil
294296
}
295-
296-
// HashWebhookDesc calculates a hash given a webhookDescription
297-
func HashWebhookDesc(webhookDesc v1alpha1.WebhookDescription) string {
298-
hasher := fnv.New32a()
299-
hashutil.DeepHashObject(hasher, &webhookDesc)
300-
return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))
301-
}

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,15 @@ func TestSyncCatalogSources(t *testing.T) {
999999
},
10001000
expectedError: nil,
10011001
expectedObjs: []runtime.Object{
1002-
pod(*grpcCatalog),
1002+
pod(t, *grpcCatalog),
10031003
},
10041004
},
10051005
{
10061006
testName: "CatalogSourceWithGrpcImage/EnsuresCorrectImage",
10071007
namespace: "cool-namespace",
10081008
catalogSource: grpcCatalog,
10091009
k8sObjs: []runtime.Object{
1010-
pod(v1alpha1.CatalogSource{
1010+
pod(t, v1alpha1.CatalogSource{
10111011
ObjectMeta: metav1.ObjectMeta{
10121012
Name: "cool-catalog",
10131013
Namespace: "cool-namespace",
@@ -1031,7 +1031,7 @@ func TestSyncCatalogSources(t *testing.T) {
10311031
},
10321032
expectedError: nil,
10331033
expectedObjs: []runtime.Object{
1034-
pod(*grpcCatalog),
1034+
pod(t, *grpcCatalog),
10351035
},
10361036
},
10371037
{
@@ -1110,7 +1110,7 @@ func TestSyncCatalogSources(t *testing.T) {
11101110
},
11111111
}),
11121112
k8sObjs: []runtime.Object{
1113-
pod(*grpcCatalog),
1113+
pod(t, *grpcCatalog),
11141114
service(grpcCatalog.GetName(), grpcCatalog.GetNamespace()),
11151115
serviceAccount(grpcCatalog.GetName(), grpcCatalog.GetNamespace(), "", objectReference("init secret")),
11161116
},
@@ -2119,14 +2119,17 @@ func toManifest(t *testing.T, obj runtime.Object) string {
21192119
return string(raw)
21202120
}
21212121

2122-
func pod(s v1alpha1.CatalogSource) *corev1.Pod {
2122+
func pod(t *testing.T, s v1alpha1.CatalogSource) *corev1.Pod {
21232123
serviceAccount := &corev1.ServiceAccount{
21242124
ObjectMeta: metav1.ObjectMeta{
21252125
Namespace: s.GetNamespace(),
21262126
Name: s.GetName(),
21272127
},
21282128
}
2129-
pod := reconciler.Pod(&s, "registry-server", "central-opm", "central-util", s.Spec.Image, serviceAccount, s.GetLabels(), s.GetAnnotations(), 5, 10, 1001)
2129+
pod, err := reconciler.Pod(&s, "registry-server", "central-opm", "central-util", s.Spec.Image, serviceAccount, s.GetLabels(), s.GetAnnotations(), 5, 10, 1001)
2130+
if err != nil {
2131+
t.Fatal(err)
2132+
}
21302133
ownerutil.AddOwner(pod, &s, false, true)
21312134
return pod
21322135
}

staging/operator-lifecycle-manager/pkg/controller/operators/olm/apiservices.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66

7+
hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
78
log "github.com/sirupsen/logrus"
89
appsv1 "k8s.io/api/apps/v1"
910
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -414,7 +415,11 @@ func (a *Operator) areWebhooksAvailable(csv *v1alpha1.ClusterServiceVersion) (bo
414415
// Create Webhook Label Selector
415416
webhookLabels := ownerutil.OwnerLabel(csv, v1alpha1.ClusterServiceVersionKind)
416417
webhookLabels[install.WebhookDescKey] = desc.GenerateName
417-
webhookLabels[install.WebhookHashKey] = install.HashWebhookDesc(desc)
418+
hash, err := hashutil.DeepHashObject(&desc)
419+
if err != nil {
420+
return false, err
421+
}
422+
webhookLabels[install.WebhookHashKey] = hash
418423
webhookSelector := labels.SelectorFromSet(webhookLabels).String()
419424

420425
webhookCount := 0

0 commit comments

Comments
 (0)