Skip to content

Commit 768dcf1

Browse files
authoredNov 18, 2019
Merge pull request operator-framework#125 from anik120/opm-bundle-extract-bug
Bug 1771850: Error logging for opm alpha bundle extract command
2 parents 3f13ca1 + 02e2a97 commit 768dcf1

File tree

11 files changed

+613
-1
lines changed

11 files changed

+613
-1
lines changed
 

‎go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/onsi/gomega v1.5.0
1717
github.com/otiai10/copy v1.0.1
1818
github.com/otiai10/curr v0.0.0-20190513014714-f5a3d24e5776 // indirect
19+
github.com/pkg/errors v0.8.1
1920
github.com/sirupsen/logrus v1.4.2
2021
github.com/spf13/cobra v0.0.5
2122
github.com/stretchr/testify v1.3.0

‎go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09Vjb
175175
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
176176
github.com/golang-migrate/migrate/v4 v4.6.2 h1:LDDOHo/q1W5UDj6PbkxdCv7lv9yunyZHXvxuwDkGo3k=
177177
github.com/golang-migrate/migrate/v4 v4.6.2/go.mod h1:JYi6reN3+Z734VZ0akNuyOJNcrg45ZL7LDBMW3WGJL0=
178+
github.com/golang/dep v0.5.4 h1:WfV5qbGwsBNUDhk+pfI6emWm7SdDFsnSWkqCMNG3BRs=
178179
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
179180
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
180181
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903 h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8=
@@ -326,6 +327,7 @@ github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+v
326327
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
327328
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
328329
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
330+
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
329331
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
330332
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
331333
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

‎pkg/configmap/configmap_writer.go

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package configmap
22

33
import (
4+
"errors"
45
"fmt"
56
"io/ioutil"
67
"os"
78
"regexp"
89

910
"github.com/ghodss/yaml"
1011
_ "github.com/mattn/go-sqlite3"
12+
errorwrap "github.com/pkg/errors"
1113
"github.com/sirupsen/logrus"
1214
batchv1 "k8s.io/api/batch/v1"
1315
corev1 "k8s.io/api/core/v1"
1416
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17+
utilerrors "k8s.io/apimachinery/pkg/util/errors"
1518
"k8s.io/client-go/kubernetes"
1619

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

69+
func validateConfigmapAnnotations(annotations map[string]string) error {
70+
errs := []error{}
71+
if annotations[bundle.ManifestsLabel] == "" {
72+
errs = append(errs, errors.New(bundle.ManifestsLabel))
73+
}
74+
if annotations[bundle.MediatypeLabel] == "" {
75+
errs = append(errs, errors.New(bundle.MediatypeLabel))
76+
}
77+
if annotations[bundle.MetadataLabel] == "" {
78+
errs = append(errs, errors.New(bundle.MetadataLabel))
79+
}
80+
if annotations[bundle.PackageLabel] == "" {
81+
errs = append(errs, errors.New(bundle.PackageLabel))
82+
}
83+
if annotations[bundle.ChannelsLabel] == "" {
84+
errs = append(errs, errors.New(bundle.ChannelsLabel))
85+
}
86+
if annotations[bundle.ChannelDefaultLabel] == "" {
87+
errs = append(errs, errors.New(bundle.ChannelDefaultLabel))
88+
}
89+
if len(errs) > 0 {
90+
return utilerrors.NewAggregate(errs)
91+
}
92+
return nil
93+
}
94+
6695
func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
6796
subDirs := []string{"manifests/", "metadata/"}
6897

@@ -121,7 +150,10 @@ func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
121150
}
122151
}
123152
}
124-
153+
err = validateConfigmapAnnotations(configMapPopulate.GetAnnotations())
154+
if err != nil {
155+
return errorwrap.Wrap(err, "annotation validation failed, missing or empty values")
156+
}
125157
if sourceImage := os.Getenv(EnvContainerImage); sourceImage != "" {
126158
annotations := configMapPopulate.GetAnnotations()
127159
annotations[ConfigMapImageAnnotationKey] = sourceImage

‎vendor/github.com/pkg/errors/.gitignore

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/pkg/errors/.travis.yml

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/pkg/errors/LICENSE

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/pkg/errors/README.md

+52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/pkg/errors/appveyor.yml

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/pkg/errors/errors.go

+282
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/github.com/pkg/errors/stack.go

+147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vendor/modules.txt

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ github.com/onsi/gomega/types
9696
github.com/opencontainers/go-digest
9797
# github.com/otiai10/copy v1.0.1
9898
github.com/otiai10/copy
99+
# github.com/pkg/errors v0.8.1
100+
github.com/pkg/errors
99101
# github.com/pmezard/go-difflib v1.0.0
100102
github.com/pmezard/go-difflib/difflib
101103
# github.com/sirupsen/logrus v1.4.2

0 commit comments

Comments
 (0)
Please sign in to comment.