Skip to content

Commit c1d8d0b

Browse files
committedJan 3, 2020
Fix a few minor issues
1. Improve helm chart validation 2. Return right away if annotations file is not found Signed-off-by: Vu Dinh <[email protected]>
1 parent 96994f9 commit c1d8d0b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed
 

‎pkg/lib/bundle/generate.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
log "github.com/sirupsen/logrus"
1111

1212
"gopkg.in/yaml.v2"
13+
"helm.sh/helm/v3/pkg/chartutil"
14+
1315
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1416
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
1517
)
@@ -128,15 +130,13 @@ func GetMediaType(directory string) (string, error) {
128130
return "", fmt.Errorf("The directory %s contains no yaml files", directory)
129131
}
130132

133+
// Validate if bundle is helm chart type
134+
if _, err := chartutil.IsChartDir(directory); err == nil {
135+
return HelmType, nil
136+
}
137+
131138
// Validate the files to determine media type
132139
for _, fileName := range files {
133-
// TODO: be more robust here, we should validate the format of helm charts
134-
// instead of file name
135-
fmt.Println(fileName)
136-
if fileName == "Chart.yaml" {
137-
return HelmType, nil
138-
}
139-
140140
// Check if one of the k8s files is a CSV
141141
if k8sFile, ok := k8sFiles[fileName]; ok {
142142
if k8sFile.GetObjectKind().GroupVersionKind().Kind == "ClusterServiceVersion" {

‎pkg/lib/bundle/validate.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func (i imageValidator) ValidateBundle(directory string) error {
7474
if err != nil {
7575
fmtErr := fmt.Errorf("Unable to read annotations.yaml file: %s", err.Error())
7676
formatErrors = append(formatErrors, fmtErr)
77+
return NewValidationError(annotationErrors, formatErrors)
7778
}
7879

7980
var fileAnnotations AnnotationMetadata

‎test/e2e/bundle_image_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ spec:
678678
}
679679

680680
func buildContainer(tag, dockerfilePath, context string) {
681-
err:= bundle.ValidateFunc(tag,builderCmd)
681+
err := bundle.ValidateFunc(tag, builderCmd)
682682
gomega.Expect(err).NotTo(gomega.HaveOccurred())
683683

684684
cmd := exec.Command(builderCmd, "build", "-t", tag, "-f", dockerfilePath, context)

0 commit comments

Comments
 (0)
Please sign in to comment.