Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/manifests/bundleloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@ func loadBundle(csvName string, dir string) (*Bundle, error) {
Name: csvName,
}
for _, f := range files {
path := filepath.Join(dir, f.Name())

if f.IsDir() {
errs = append(errs, fmt.Errorf("bundle manifests dir contains directory: %s", path))
continue
}

if strings.HasPrefix(f.Name(), ".") {
errs = append(errs, fmt.Errorf("bundle manifests dir has hidden file: %s", path))
continue
}

path := filepath.Join(dir, f.Name())
fileReader, err := os.Open(path)
if err != nil {
errs = append(errs, fmt.Errorf("unable to load file %s: %s", path, err))
Expand Down
9 changes: 9 additions & 0 deletions pkg/manifests/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ func TestGetPackage(t *testing.T) {
require.Equal(t, 2, len(bundles[1].V1beta1CRDs))
require.Equal(t, 1, len(bundles[1].V1CRDs))
}

func TestLoadBundle(t *testing.T) {
var err error

_, err = loadBundle("test-operator.v0.0.1", "./testdata/invalid_bundle_with_subdir")
require.EqualError(t, err, "bundle manifests dir contains directory: testdata/invalid_bundle_with_subdir/foo")
_, err = loadBundle("test-operator.v0.0.1", "./testdata/invalid_bundle_with_hidden")
require.EqualError(t, err, "bundle manifests dir has hidden file: testdata/invalid_bundle_with_hidden/.hidden")
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
annotations:
capabilities: Basic Install
name: test-operator.v0.0.1
namespace: placeholder
spec:
apiservicedefinitions: {}
customresourcedefinitions:
owned:
- description: Test is the Schema for the tests API
kind: Test
name: tests.test.example.com
version: v1alpha1
installModes:
- supported: true
type: OwnNamespace
- supported: true
type: SingleNamespace
- supported: false
type: MultiNamespace
- supported: true
type: AllNamespaces
keywords:
- test-operator
links:
- name: Test Operator
url: https://test-operator.domain
maintainers:
- email: your@email.com
name: Maintainer Name
maturity: alpha
provider:
name: Provider Name
url: https://your.domain
version: 0.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: tests.test.example.com
spec:
group: test.example.com
names:
kind: Test
listKind: TestList
plural: tests
singular: test
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
annotations:
capabilities: Basic Install
name: test-operator.v0.0.1
namespace: placeholder
spec:
apiservicedefinitions: {}
customresourcedefinitions:
owned:
- description: Test is the Schema for the tests API
kind: Test
name: tests.test.example.com
version: v1alpha1
installModes:
- supported: true
type: OwnNamespace
- supported: true
type: SingleNamespace
- supported: false
type: MultiNamespace
- supported: true
type: AllNamespaces
keywords:
- test-operator
links:
- name: Test Operator
url: https://test-operator.domain
maintainers:
- email: your@email.com
name: Maintainer Name
maturity: alpha
provider:
name: Provider Name
url: https://your.domain
version: 0.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: tests.test.example.com
spec:
group: test.example.com
names:
kind: Test
listKind: TestList
plural: tests
singular: test
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true