feat(validation): adding validation for ZFSPV CR parameters (#66)

Validating few parameters for the ZFSVolume custom resource

- compression can be "on", "off", "lzjb", "gzip", "gzip-[1-9]", "zle" and "lz4"
- encryption can be "on", "off", "aes-128-ccm", "aes-192-ccm", "aes-256-ccm", "aes-128-gcm", "aes-192-gcm", and "aes-256-gcm"
- dedup can be "on" and "off"
- poolname can be string
- ownernodeid can be string
- thinprovision can be "yes" and "no"
- volumetype can be "DATASET" and "ZVOL"

Also added required fields needed to create ZFSVolume CR
- ownerNodeID
- poolname
- volumeType
- capacity


Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
Pawan Prakash Sharma 2020-04-14 17:26:46 +05:30 committed by GitHub
parent fbd4812642
commit ae724ee096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 2206 additions and 342 deletions

View file

@ -0,0 +1,80 @@
#!/bin/bash
# Copyright 2019 The Kubernetes Authors.
# Copyright 2020 The OpenEBS Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#set -o errexit
set -o nounset
set -o pipefail
## find or download controller-gen
CONTROLLER_GEN=$(which controller-gen)
if [ "$CONTROLLER_GEN" = "" ]
then
echo "ERROR: failed to get controller-gen, Please run make bootstrap to install it";
exit 1;
fi
SCRIPT_ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
$CONTROLLER_GEN crd:trivialVersions=true,preserveUnknownFields=false paths=${SCRIPT_ROOT}/pkg/apis/openebs.io/zfs/v1alpha1 output:crd:artifacts:config=deploy/yamls
## create the the crd yamls
echo '
##############################################
########### ############
########### ZFSVolume CRD ############
########### ############
##############################################
# ZFSVolume CRD is autogenerated via `make manifests` command.
# Do the modification in the code and run the `make manifests` command
# to generate the CRD definition' > deploy/yamls/zfsvolume-crd.yaml
cat deploy/yamls/zfs.openebs.io_zfsvolumes.yaml >> deploy/yamls/zfsvolume-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfsvolumes.yaml
echo '
##############################################
########### ############
########### ZFSSnapshot CRD ############
########### ############
##############################################
# ZFSSnapshot CRD is autogenerated via `make manifests` command.
# Do the modification in the code and run the `make manifests` command
# to generate the CRD definition' > deploy/yamls/zfssnapshot-crd.yaml
cat deploy/yamls/zfs.openebs.io_zfssnapshots.yaml >> deploy/yamls/zfssnapshot-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfssnapshots.yaml
## create the operator file using all the yamls
echo '# This manifest is autogenerated via `make manifests` command
# Do the modification to the zfs-driver.yaml in directory deploy/yamls/
# and then run `make manifests` command
# This manifest deploys the OpenEBS ZFS control plane components,
# with associated CRs & RBAC rules.
' > deploy/zfs-operator.yaml
cat deploy/yamls/namespace.yaml deploy/yamls/zfsvolume-crd.yaml deploy/yamls/zfssnapshot-crd.yaml deploy/yamls/zfs-driver.yaml >> deploy/zfs-operator.yaml
# To use your own boilerplate text use:
# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt

View file

@ -17,7 +17,7 @@ set -e
DST_REPO="$GOPATH/src/github.com/openebs/zfs-localpv"
function checkGitDiff() {
if [[ `git diff --shortstat | wc -l` != 0 ]]; then echo "Some files got changed after $1";printf "\n";git diff --stat;printf "\n"; exit 1; fi
if [[ `git diff --shortstat | wc -l` != 0 ]]; then echo "Some files got changed after $1";printf "\n";git diff;printf "\n"; exit 1; fi
}
#make golint-travis
@ -29,6 +29,12 @@ rc=$?; if [[ $rc != 0 ]]; then echo "make kubegen failed"; exit $rc; fi
checkGitDiff "make kubegen"
printf "\n"
echo "Running : make manifests"
make manifests
rc=$?; if [[ $rc != 0 ]]; then echo "make manifests failed"; exit $rc; fi
checkGitDiff "make manifests"
printf "\n"
./buildscripts/test-cov.sh
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi

View file

@ -1,45 +0,0 @@
#!/bin/bash
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#set -o errexit
set -o nounset
set -o pipefail
## find or download controller-gen
CONTROLLER_GEN=$(which controller-gen)
if [ "$CONTROLLER_GEN" = "" ]
then
TMP_DIR=$(mktemp -d);
cd $TMP_DIR;
go mod init tmp;
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.8;
rm -rf $TMP_DIR;
CONTROLLER_GEN=$(which controller-gen)
fi
if [ "$CONTROLLER_GEN" = "" ]
then
echo "ERROR: failed to get controller-gen";
exit 1;
fi
SCRIPT_ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
$CONTROLLER_GEN crd:trivialVersions=true,preserveUnknownFields=false paths=${SCRIPT_ROOT}/pkg/apis/openebs.io/zfs/v1alpha1 output:crd:artifacts:config=deploy/yamls
# To use your own boilerplate text use:
# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt