Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1835884: opm bundle extract shouldn't validate annotations #338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/configmap/configmap_test.go
Expand Up @@ -77,6 +77,19 @@ func TestLoad(t *testing.T) {
assert.Equal(t, 3, len(objects))
},
},
{
name: "BundleWithNoDefaultChannel",
source: "testdata/bundle-with-no-default-channel.yaml",
assertFunc: func(t *testing.T, bundleGot *api.Bundle) {
csvGot := bundleGot.GetCsvJson()
assert.NotNil(t, csvGot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Pointless assertion, csvGot is a string. Actually, two tests above this one asserts nothing but this.

unst := getUnstructured(t, csvGot)
assert.True(t, unst.GetName() == "kiali-operator.v1.4.2")

objects := bundleGot.GetObject()
assert.Equal(t, 3, len(objects))
},
},
}

for _, tt := range tests {
Expand Down
34 changes: 1 addition & 33 deletions pkg/configmap/configmap_writer.go
Expand Up @@ -2,19 +2,16 @@ package configmap

import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"regexp"

"github.com/ghodss/yaml"
errorwrap "github.com/pkg/errors"
"github.com/sirupsen/logrus"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/client-go/kubernetes"

"github.com/operator-framework/operator-registry/pkg/client"
Expand Down Expand Up @@ -66,32 +63,6 @@ func TranslateInvalidChars(input string) string {
return validConfigMapKey
}

func validateConfigmapAnnotations(annotations map[string]string) error {
errs := []error{}
if annotations[bundle.ManifestsLabel] == "" {
errs = append(errs, errors.New(bundle.ManifestsLabel))
}
if annotations[bundle.MediatypeLabel] == "" {
errs = append(errs, errors.New(bundle.MediatypeLabel))
}
if annotations[bundle.MetadataLabel] == "" {
errs = append(errs, errors.New(bundle.MetadataLabel))
}
if annotations[bundle.PackageLabel] == "" {
errs = append(errs, errors.New(bundle.PackageLabel))
}
if annotations[bundle.ChannelsLabel] == "" {
errs = append(errs, errors.New(bundle.ChannelsLabel))
}
if annotations[bundle.ChannelDefaultLabel] == "" {
errs = append(errs, errors.New(bundle.ChannelDefaultLabel))
}
if len(errs) > 0 {
return utilerrors.NewAggregate(errs)
}
return nil
}

func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
subDirs := []string{"manifests/", "metadata/"}

Expand Down Expand Up @@ -150,10 +121,7 @@ func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
}
}
}
err = validateConfigmapAnnotations(configMapPopulate.GetAnnotations())
if err != nil {
return errorwrap.Wrap(err, "annotation validation failed, missing or empty values")
}

if sourceImage := os.Getenv(EnvContainerImage); sourceImage != "" {
annotations := configMapPopulate.GetAnnotations()
annotations[ConfigMapImageAnnotationKey] = sourceImage
Expand Down