Skip to content

Commit 0ea85d7

Browse files
author
Per G. da Silva
committed
Addressed reviewer comments
Signed-off-by: Per G. da Silva <[email protected]>
1 parent 443d7a2 commit 0ea85d7

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

internal/operator-controller/applier/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (r *RegistryV1ManifestProvider) Get(bundleFS fs.FS, ext *ocv1.ClusterExtens
6969
}
7070

7171
if r.IsSingleOwnNamespaceEnabled {
72-
bundleConfig, err := bundle.UnmarshallConfig(ext.ExtensionConfigBytes(), rv1, ext.Spec.Namespace)
72+
bundleConfig, err := bundle.UnmarshalConfig(ext.ExtensionConfigBytes(), rv1, ext.Spec.Namespace)
7373
if err != nil {
7474
return nil, fmt.Errorf("invalid bundle configuration: %w", err)
7575
}

internal/operator-controller/rukpak/bundle/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ type Config struct {
1717
WatchNamespace *string `json:"watchNamespace"`
1818
}
1919

20-
// UnmarshallConfig returns a deserialized and validated *bundle.Config based on bytes and validated
20+
// UnmarshalConfig returns a deserialized and validated *bundle.Config based on bytes and validated
2121
// against rv1 and the desired install namespaces. It will error if:
2222
// - rv is nil
2323
// - bytes is not a valid YAML/JSON object
2424
// - bytes is a valid YAML/JSON object but does not follow the registry+v1 schema
2525
// if bytes is nil it will be treated as an empty json object ({})
26-
func UnmarshallConfig(bytes []byte, rv1 RegistryV1, installNamespace string) (*Config, error) {
26+
func UnmarshalConfig(bytes []byte, rv1 RegistryV1, installNamespace string) (*Config, error) {
2727
if bytes == nil {
2828
bytes = []byte("{}")
2929
}
3030

3131
bundleConfig := &Config{}
3232
if err := yaml.UnmarshalStrict(bytes, bundleConfig); err != nil {
33-
return nil, fmt.Errorf("error unmarshalling registry+v1 configuration: %w", formatUnmarshallError(err))
33+
return nil, fmt.Errorf("error unmarshalling registry+v1 configuration: %w", formatUnmarshalError(err))
3434
}
3535

3636
// collect bundle install modes
@@ -98,8 +98,8 @@ func isWatchNamespaceConfigRequired(bundleInstallModeSet sets.Set[v1alpha1.Insta
9898
!bundleInstallModeSet.Has(v1alpha1.InstallMode{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true})
9999
}
100100

101-
// formatUnmarshallError format JSON unmarshal errors to be more readable
102-
func formatUnmarshallError(err error) error {
101+
// formatUnmarshalError format JSON unmarshal errors to be more readable
102+
func formatUnmarshalError(err error) error {
103103
var unmarshalErr *json.UnmarshalTypeError
104104
if errors.As(err, &unmarshalErr) {
105105
if unmarshalErr.Field == "" {

internal/operator-controller/rukpak/bundle/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/clusterserviceversion"
1313
)
1414

15-
func Test_UnmarshallConfig(t *testing.T) {
15+
func Test_UnmarshalConfig(t *testing.T) {
1616
for _, tc := range []struct {
1717
name string
1818
rawConfig []byte
@@ -299,7 +299,7 @@ func Test_UnmarshallConfig(t *testing.T) {
299299
}
300300
}
301301

302-
config, err := bundle.UnmarshallConfig(tc.rawConfig, rv1, tc.installNamespace)
302+
config, err := bundle.UnmarshalConfig(tc.rawConfig, rv1, tc.installNamespace)
303303
require.Equal(t, tc.expectedConfig, config)
304304
if tc.expectedErrMessage != "" {
305305
require.Error(t, err)

internal/operator-controller/rukpak/render/render.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ func validateTargetNamespaces(rv1 *bundle.RegistryV1, installNamespace string, t
162162
// If only OwnNamespace is supported, the default will be [install-namespace] -> only watch the install/own namespace
163163
if supportedInstallModes.Has(v1alpha1.InstallModeTypeMultiNamespace) {
164164
return errors.New("at least one target namespace must be specified")
165-
} else {
166-
return errors.New("exactly one target namespace must be specified")
167165
}
166+
return errors.New("exactly one target namespace must be specified")
168167
case set.Len() == 1 && set.Has(""):
169168
if supportedInstallModes.Has(v1alpha1.InstallModeTypeAllNamespaces) {
170169
return nil

testdata/images/bundles/own-namespace-operator/v1.0.0/manifests/ownnamespaceoperator.clusterserviceversion.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ spec:
2727
apiservicedefinitions: {}
2828
customresourcedefinitions:
2929
owned:
30-
- description: A dummy resource for an operator that only supports own namespace install mode
31-
displayName: OwnNamespace
32-
kind: OwnNamespace
33-
name: ownnamespaces.olm.operatorframework.io
34-
version: v1
30+
- description: A dummy resource for an operator that only supports own namespace install mode
31+
displayName: OwnNamespace
32+
kind: OwnNamespace
33+
name: ownnamespaces.olm.operatorframework.io
34+
version: v1
3535
description: OLM OwnNamespace Testing Operator
3636
displayName: test-operator
3737
icon:

0 commit comments

Comments
 (0)