Skip to content

alm-example validation #115

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test: test-unit ## Run the tests

TEST_PKGS:=$(shell go list ./...)
test-unit: ## Run the unit tests
$(Q)go test -count=1 -short ${TEST_PKGS}
Copy link
Member

Choose a reason for hiding this comment

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

Any reason we need to add -v? Failing tests always have their details shown, so -v can sometimes make it hard to find the failing test if the entire test suite's details (even for passing tests) are always present.

$(Q)go test -count=1 -short ${TEST_PKGS} -v
Copy link
Contributor

Choose a reason for hiding this comment

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

ihmo only revert this one, rebase and all shows fine for me.
Really nice contribution.


# Utilities.
.PHONY: controller-gen
Expand Down
10 changes: 10 additions & 0 deletions pkg/validation/internal/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ func TestValidateCSV(t *testing.T) {
},
filepath.Join("testdata", "badAnnotationNames.csv.yaml"),
},
{
validatorFuncTest{
description: "invalid alm-examples json for csv",
wantErr: true,
errors: []errors.Error{
errors.ErrInvalidParse("error decoding example CustomResource", "invalid character ']' looking for beginning of value"),
},
},
filepath.Join("testdata", "invalid.alm-examples.csv.yaml"),
},
}
for _, c := range cases {
b, err := ioutil.ReadFile(c.csvPath)
Expand Down
34 changes: 34 additions & 0 deletions pkg/validation/internal/testdata/invalid.alm-examples.csv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
annotations:
alm-examples: '[{"apiVersion":"local.storage.openshift.io/v1","kind":"LocalVolume","metadata":{"name":"example"},"spec":{"storageClassDevices":[{"devicePaths":["/dev/disk/by-id/ata-crucial",],"fsType": "ext4", "storageClassName": "foobar", "volumeMode": "Filesystem" } ] } }, { "apiVersion": "local.storage.openshift.io/v1alpha1", "kind": "LocalVolumeSet", "metadata": { "name": "example-localvolumeset" }, "spec": { "deviceInclusionSpec": { "deviceMechanicalProperties": [ "Rotational", "NonRotational" ], "deviceTypes": [ "RawDisk" ], "maxSize": "100G", "minSize": "10G" }, "maxDeviceCount": 10, "nodeSelector": { "nodeSelectorTerms": [ { "matchExpressions": [ { "key": "kubernetes.io/hostname", "operator": "In", "values": [ "worker-0", "worker-1" ] } ] } ] }, "storageClassName": "example-storageclass", "volumeMode": "Block" } }, { "apiVersion": "local.storage.openshift.io/v1alpha1", "kind": "LocalVolumeDiscovery", "metadata": { "name": "auto-discover-devices" }, "spec": { "nodeSelector": { "nodeSelectorTerms": [ { "matchExpressions": [ { "key":"kubernetes.io/hostname","operator":"In","values":["worker-0","worker-1"]}]}]}}}]'
capabilities: Basic Install
name: test-operator.v0.0.1
namespace: placeholder
spec:
displayName: test-operator
install:
strategy: deployment
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: [email protected]
name: Maintainer Name
maturity: alpha
provider:
name: Provider Name
url: https://your.domain
version: 0.0.1