From 9cf11ef2ff508bdc42248acf73a3c2d257f31ccf Mon Sep 17 00:00:00 2001 From: hasbro17 Date: Thu, 10 Oct 2019 21:12:40 -0700 Subject: [PATCH 1/2] *: allow add crd to run for helm/ansible projects --- ci/tests/e2e-ansible.sh | 2 +- ci/tests/e2e-helm.sh | 2 +- cmd/operator-sdk/add/crd.go | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ci/tests/e2e-ansible.sh b/ci/tests/e2e-ansible.sh index 3285fc91731..7d2bba9e2e2 100755 --- a/ci/tests/e2e-ansible.sh +++ b/ci/tests/e2e-ansible.sh @@ -9,7 +9,7 @@ eval IMAGE=$IMAGE_FORMAT component="osdk-ansible-e2e-hybrid" eval IMAGE2=$IMAGE_FORMAT ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d -p $GOPATH/src)" +GOTMP="$(mktemp -d)" trap_add 'rm -rf $GOTMP' EXIT mkdir -p $ROOTDIR/bin diff --git a/ci/tests/e2e-helm.sh b/ci/tests/e2e-helm.sh index 7eef8230c29..0f449193589 100755 --- a/ci/tests/e2e-helm.sh +++ b/ci/tests/e2e-helm.sh @@ -9,7 +9,7 @@ eval IMAGE=$IMAGE_FORMAT component="osdk-helm-e2e-hybrid" eval IMAGE2=$IMAGE_FORMAT ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d -p $GOPATH/src)" +GOTMP="$(mktemp -d)" trap_add 'rm -rf $GOTMP' EXIT mkdir -p $ROOTDIR/bin diff --git a/cmd/operator-sdk/add/crd.go b/cmd/operator-sdk/add/crd.go index 83835e6f844..fe88c74826f 100644 --- a/cmd/operator-sdk/add/crd.go +++ b/cmd/operator-sdk/add/crd.go @@ -59,8 +59,11 @@ func crdFunc(cmd *cobra.Command, args []string) error { cfg := &input.Config{ AbsProjectPath: projutil.MustGetwd(), - Repo: projutil.GetGoPkg(), } + if projutil.IsOperatorGo() { + cfg.Repo = projutil.GetGoPkg() + } + if len(args) != 0 { return fmt.Errorf("command %s doesn't accept any arguments", cmd.CommandPath()) } From 9e80955c87a3c9859b830275dcc39d2cf0284a6c Mon Sep 17 00:00:00 2001 From: hasbro17 Date: Thu, 10 Oct 2019 21:18:14 -0700 Subject: [PATCH 2/2] *: rename GOTMP to TMPDIR for helm/ansible scripts --- ci/tests/e2e-ansible.sh | 6 +++--- ci/tests/e2e-helm.sh | 6 +++--- hack/image/build-ansible-image.sh | 6 +++--- hack/image/build-helm-image.sh | 6 +++--- hack/tests/e2e-ansible-molecule.sh | 6 +++--- hack/tests/e2e-ansible.sh | 6 +++--- hack/tests/e2e-helm.sh | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ci/tests/e2e-ansible.sh b/ci/tests/e2e-ansible.sh index 7d2bba9e2e2..a8f6f09e5a6 100755 --- a/ci/tests/e2e-ansible.sh +++ b/ci/tests/e2e-ansible.sh @@ -9,8 +9,8 @@ eval IMAGE=$IMAGE_FORMAT component="osdk-ansible-e2e-hybrid" eval IMAGE2=$IMAGE_FORMAT ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT mkdir -p $ROOTDIR/bin export PATH=$ROOTDIR/bin:$PATH @@ -163,7 +163,7 @@ test_operator() { oc project default # create and build the operator -pushd "$GOTMP" +pushd "$TMPDIR" operator-sdk new memcached-operator --api-version=ansible.example.com/v1alpha1 --kind=Memcached --type=ansible pushd memcached-operator diff --git a/ci/tests/e2e-helm.sh b/ci/tests/e2e-helm.sh index 0f449193589..056e1170d3b 100755 --- a/ci/tests/e2e-helm.sh +++ b/ci/tests/e2e-helm.sh @@ -9,8 +9,8 @@ eval IMAGE=$IMAGE_FORMAT component="osdk-helm-e2e-hybrid" eval IMAGE2=$IMAGE_FORMAT ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT mkdir -p $ROOTDIR/bin export PATH=$ROOTDIR/bin:$PATH @@ -136,7 +136,7 @@ if oc api-versions | grep openshift; then fi # create and build the operator -pushd "$GOTMP" +pushd "$TMPDIR" operator-sdk new nginx-operator --api-version=helm.example.com/v1alpha1 --kind=Nginx --type=helm pushd nginx-operator diff --git a/hack/image/build-ansible-image.sh b/hack/image/build-ansible-image.sh index 421663deb8f..892455c27bb 100755 --- a/hack/image/build-ansible-image.sh +++ b/hack/image/build-ansible-image.sh @@ -6,9 +6,9 @@ source hack/lib/test_lib.sh source hack/lib/image_lib.sh ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT -BASEIMAGEDIR="$GOTMP/ansible-operator" +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT +BASEIMAGEDIR="$TMPDIR/ansible-operator" mkdir -p "$BASEIMAGEDIR" go build -o $BASEIMAGEDIR/scaffold-ansible-image ./hack/image/ansible/scaffold-ansible-image.go diff --git a/hack/image/build-helm-image.sh b/hack/image/build-helm-image.sh index 5a26c9bd369..469129536b8 100755 --- a/hack/image/build-helm-image.sh +++ b/hack/image/build-helm-image.sh @@ -6,9 +6,9 @@ source hack/lib/test_lib.sh source hack/lib/image_lib.sh ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT -BASEIMAGEDIR="$GOTMP/helm-operator" +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT +BASEIMAGEDIR="$TMPDIR/helm-operator" mkdir -p "$BASEIMAGEDIR" go build -o $BASEIMAGEDIR/scaffold-helm-image ./hack/image/helm/scaffold-helm-image.go diff --git a/hack/tests/e2e-ansible-molecule.sh b/hack/tests/e2e-ansible-molecule.sh index f89d2c3bd78..68634b3d63f 100755 --- a/hack/tests/e2e-ansible-molecule.sh +++ b/hack/tests/e2e-ansible-molecule.sh @@ -5,8 +5,8 @@ source hack/lib/test_lib.sh set -eux ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT pip3 install --user pyasn1==0.4.7 pyasn1-modules==0.2.6 idna==2.8 ipaddress==1.0.22 pip3 install --user molecule==2.22 pip3 install --user docker openshift jmespath @@ -25,7 +25,7 @@ remove_prereqs() { kubectl delete --ignore-not-found=true -f "$OPERATORDIR/deploy/crds/ansible.example.com_memcacheds_crd.yaml" } -pushd "$GOTMP" +pushd "$TMPDIR" operator-sdk new memcached-operator \ --api-version=ansible.example.com/v1alpha1 \ --kind=Memcached \ diff --git a/hack/tests/e2e-ansible.sh b/hack/tests/e2e-ansible.sh index e40d53b57e1..e04601bf586 100755 --- a/hack/tests/e2e-ansible.sh +++ b/hack/tests/e2e-ansible.sh @@ -10,8 +10,8 @@ go test -count=1 ./pkg/ansible/proxy/... DEST_IMAGE="quay.io/example/memcached-operator:v0.0.2" ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT deploy_operator() { kubectl create -f "$OPERATORDIR/deploy/service_account.yaml" @@ -129,7 +129,7 @@ test_operator() { } # create and build the operator -pushd "$GOTMP" +pushd "$TMPDIR" operator-sdk new memcached-operator \ --api-version=ansible.example.com/v1alpha1 \ --kind=Memcached \ diff --git a/hack/tests/e2e-helm.sh b/hack/tests/e2e-helm.sh index 99eb97ea7a0..22b7e6e319f 100755 --- a/hack/tests/e2e-helm.sh +++ b/hack/tests/e2e-helm.sh @@ -7,8 +7,8 @@ source hack/lib/image_lib.sh DEST_IMAGE="quay.io/example/nginx-operator:v0.0.2" ROOTDIR="$(pwd)" -GOTMP="$(mktemp -d)" -trap_add 'rm -rf $GOTMP' EXIT +TMPDIR="$(mktemp -d)" +trap_add 'rm -rf $TMPDIR' EXIT deploy_operator() { kubectl create -f "$OPERATORDIR/deploy/service_account.yaml" @@ -112,7 +112,7 @@ test_operator() { } # create and build the operator -pushd "$GOTMP" +pushd "$TMPDIR" log=$(operator-sdk new nginx-operator \ --api-version=helm.example.com/v1alpha1 \ --kind=Nginx \