Skip to content

Commit 9277daa

Browse files
author
Per Goncalves da Silva
committed
Refactor MakeCSV utility to builder pattern
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 5f37a67 commit 9277daa

File tree

12 files changed

+565
-628
lines changed

12 files changed

+565
-628
lines changed

internal/operator-controller/applier/boxcutter_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import (
3232
"github.com/operator-framework/operator-controller/internal/operator-controller/labels"
3333
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle"
3434
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render"
35-
testutils "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing"
3635
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/bundlefs"
36+
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/clusterserviceversion"
3737
)
3838

3939
func Test_RegistryV1BundleRenderer_Render_Success(t *testing.T) {
@@ -57,8 +57,8 @@ func Test_RegistryV1BundleRenderer_Render_Success(t *testing.T) {
5757
}
5858
bundleFS := bundlefs.Builder().
5959
WithPackageName("some-package").
60-
WithCSV(testutils.MakeCSV(testutils.WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces))).Build()
61-
60+
WithCSV(clusterserviceversion.Builder().WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces).Build()).
61+
Build()
6262
objs, err := r.Render(bundleFS, &ocv1.ClusterExtension{
6363
Spec: ocv1.ClusterExtensionSpec{
6464
Namespace: "some-namespace",
@@ -81,8 +81,8 @@ func Test_RegistryV1BundleRenderer_Render_Failure(t *testing.T) {
8181
}
8282
bundleFS := bundlefs.Builder().
8383
WithPackageName("some-package").
84-
WithCSV(testutils.MakeCSV(testutils.WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces))).Build()
85-
84+
WithCSV(clusterserviceversion.Builder().WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces).Build()).
85+
Build()
8686
objs, err := r.Render(bundleFS, &ocv1.ClusterExtension{
8787
Spec: ocv1.ClusterExtensionSpec{
8888
Namespace: "some-namespace",
@@ -811,7 +811,7 @@ func TestBoxcutter_Apply(t *testing.T) {
811811
} else {
812812
require.NoError(t, err)
813813
assert.False(t, installSucceeded)
814-
assert.Equal(t, "New revision created", installStatus)
814+
assert.Equal(t, "Builder revision created", installStatus)
815815
}
816816

817817
if tc.validate != nil {

internal/operator-controller/applier/provider_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle/source"
2222
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render"
2323
. "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing"
24+
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/clusterserviceversion"
2425
)
2526

2627
func Test_RegistryV1HelmChartProvider_Get_ReturnsBundleSourceFailures(t *testing.T) {
@@ -51,7 +52,7 @@ func Test_RegistryV1HelmChartProvider_Get_ReturnsBundleRendererFailures(t *testi
5152

5253
b := source.FromBundle(
5354
bundle.RegistryV1{
54-
CSV: MakeCSV(WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces)),
55+
CSV: clusterserviceversion.Builder().WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces).Build(),
5556
},
5657
)
5758

@@ -70,7 +71,7 @@ func Test_RegistryV1HelmChartProvider_Get_NoAPIServiceDefinitions(t *testing.T)
7071

7172
b := source.FromBundle(
7273
bundle.RegistryV1{
73-
CSV: MakeCSV(WithOwnedAPIServiceDescriptions(v1alpha1.APIServiceDescription{})),
74+
CSV: clusterserviceversion.Builder().WithOwnedAPIServiceDescriptions(v1alpha1.APIServiceDescription{}).Build(),
7475
},
7576
)
7677

@@ -92,7 +93,7 @@ func Test_RegistryV1HelmChartProvider_Get_NoWebhooksWithoutCertProvider(t *testi
9293

9394
b := source.FromBundle(
9495
bundle.RegistryV1{
95-
CSV: MakeCSV(WithWebhookDefinitions(v1alpha1.WebhookDescription{})),
96+
CSV: clusterserviceversion.Builder().WithWebhookDefinitions(v1alpha1.WebhookDescription{}).Build(),
9697
},
9798
)
9899

@@ -114,7 +115,7 @@ func Test_RegistryV1HelmChartProvider_Get_WebhooksSupportDisabled(t *testing.T)
114115

115116
b := source.FromBundle(
116117
bundle.RegistryV1{
117-
CSV: MakeCSV(WithWebhookDefinitions(v1alpha1.WebhookDescription{})),
118+
CSV: clusterserviceversion.Builder().WithWebhookDefinitions(v1alpha1.WebhookDescription{}).Build(),
118119
},
119120
)
120121

@@ -137,10 +138,9 @@ func Test_RegistryV1HelmChartProvider_Get_WebhooksWithCertProvider(t *testing.T)
137138

138139
b := source.FromBundle(
139140
bundle.RegistryV1{
140-
CSV: MakeCSV(
141-
WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces),
142-
WithWebhookDefinitions(v1alpha1.WebhookDescription{}),
143-
),
141+
CSV: clusterserviceversion.Builder().
142+
WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces).
143+
WithWebhookDefinitions(v1alpha1.WebhookDescription{}).Build(),
144144
},
145145
)
146146

@@ -173,7 +173,7 @@ func Test_RegistryV1HelmChartProvider_Get_BundleRendererIntegration(t *testing.T
173173

174174
b := source.FromBundle(
175175
bundle.RegistryV1{
176-
CSV: MakeCSV(WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces, v1alpha1.InstallModeTypeSingleNamespace)),
176+
CSV: clusterserviceversion.Builder().WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces, v1alpha1.InstallModeTypeSingleNamespace).Build(),
177177
},
178178
)
179179

@@ -243,10 +243,9 @@ func Test_RegistryV1HelmChartProvider_Get_Success(t *testing.T) {
243243

244244
b := source.FromBundle(
245245
bundle.RegistryV1{
246-
CSV: MakeCSV(
247-
WithAnnotations(map[string]string{"foo": "bar"}),
248-
WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces),
249-
),
246+
CSV: clusterserviceversion.Builder().
247+
WithAnnotations(map[string]string{"foo": "bar"}).
248+
WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces).Build(),
250249
Others: []unstructured.Unstructured{
251250
*ToUnstructuredT(t, &corev1.Service{
252251
TypeMeta: metav1.TypeMeta{

internal/operator-controller/rukpak/bundle/source/source_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle"
1515
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle/source"
16-
testutils "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing"
1716
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/bundlefs"
17+
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/clusterserviceversion"
1818
)
1919

2020
const (
@@ -34,13 +34,13 @@ func Test_FromFS_Success(t *testing.T) {
3434
bundleFS := bundlefs.Builder().
3535
WithPackageName("test").
3636
WithBundleProperty("from-file-key", "from-file-value").
37-
WithBundleResource("csv.yaml", ptr.To(testutils.MakeCSV(
38-
testutils.WithName("test.v1.0.0"),
39-
testutils.WithAnnotations(map[string]string{
37+
WithBundleResource("csv.yaml", ptr.To(clusterserviceversion.Builder().
38+
WithName("test.v1.0.0").
39+
WithAnnotations(map[string]string{
4040
"olm.properties": `[{"type":"from-csv-annotations-key", "value":"from-csv-annotations-value"}]`,
41-
}),
42-
testutils.WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces)),
43-
)).Build()
41+
}).
42+
WithInstallModeSupportFor(v1alpha1.InstallModeTypeAllNamespaces).Build())).
43+
Build()
4444

4545
rv1, err := source.FromFS(bundleFS).GetBundle()
4646
require.NoError(t, err)
@@ -72,12 +72,12 @@ func Test_FromFS_Fails(t *testing.T) {
7272
name: "bundle missing metadata/annotations.yaml",
7373
FS: bundlefs.Builder().
7474
WithBundleProperty("foo", "bar").
75-
WithBundleResource("csv.yaml", ptr.To(testutils.MakeCSV())).Build(),
75+
WithBundleResource("csv.yaml", ptr.To(clusterserviceversion.Builder().Build())).Build(),
7676
}, {
7777
name: "metadata/annotations.yaml missing package name annotation",
7878
FS: bundlefs.Builder().
7979
WithBundleProperty("foo", "bar").
80-
WithBundleResource("csv.yaml", ptr.To(testutils.MakeCSV())).Build(),
80+
WithBundleResource("csv.yaml", ptr.To(clusterserviceversion.Builder().Build())).Build(),
8181
}, {
8282
name: "bundle missing manifests directory",
8383
FS: bundlefs.Builder().

0 commit comments

Comments
 (0)