Skip to content

Commit 2ce7a17

Browse files
authored
*: allow add crd to run for ansible/helm projects outside $GOPATH (#2044)
* allow add crd to run for helm/ansible projects * rename GOTMP to TMPDIR for helm/ansible scripts
1 parent 40b8138 commit 2ce7a17

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

ci/tests/e2e-ansible.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ eval IMAGE=$IMAGE_FORMAT
99
component="osdk-ansible-e2e-hybrid"
1010
eval IMAGE2=$IMAGE_FORMAT
1111
ROOTDIR="$(pwd)"
12-
GOTMP="$(mktemp -d -p $GOPATH/src)"
13-
trap_add 'rm -rf $GOTMP' EXIT
12+
TMPDIR="$(mktemp -d)"
13+
trap_add 'rm -rf $TMPDIR' EXIT
1414

1515
mkdir -p $ROOTDIR/bin
1616
export PATH=$ROOTDIR/bin:$PATH
@@ -163,7 +163,7 @@ test_operator() {
163163
oc project default
164164

165165
# create and build the operator
166-
pushd "$GOTMP"
166+
pushd "$TMPDIR"
167167
operator-sdk new memcached-operator --api-version=ansible.example.com/v1alpha1 --kind=Memcached --type=ansible
168168

169169
pushd memcached-operator

ci/tests/e2e-helm.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ eval IMAGE=$IMAGE_FORMAT
99
component="osdk-helm-e2e-hybrid"
1010
eval IMAGE2=$IMAGE_FORMAT
1111
ROOTDIR="$(pwd)"
12-
GOTMP="$(mktemp -d -p $GOPATH/src)"
13-
trap_add 'rm -rf $GOTMP' EXIT
12+
TMPDIR="$(mktemp -d)"
13+
trap_add 'rm -rf $TMPDIR' EXIT
1414

1515
mkdir -p $ROOTDIR/bin
1616
export PATH=$ROOTDIR/bin:$PATH
@@ -136,7 +136,7 @@ if oc api-versions | grep openshift; then
136136
fi
137137

138138
# create and build the operator
139-
pushd "$GOTMP"
139+
pushd "$TMPDIR"
140140
operator-sdk new nginx-operator --api-version=helm.example.com/v1alpha1 --kind=Nginx --type=helm
141141

142142
pushd nginx-operator

cmd/operator-sdk/add/crd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ func crdFunc(cmd *cobra.Command, args []string) error {
5959

6060
cfg := &input.Config{
6161
AbsProjectPath: projutil.MustGetwd(),
62-
Repo: projutil.GetGoPkg(),
6362
}
63+
if projutil.IsOperatorGo() {
64+
cfg.Repo = projutil.GetGoPkg()
65+
}
66+
6467
if len(args) != 0 {
6568
return fmt.Errorf("command %s doesn't accept any arguments", cmd.CommandPath())
6669
}

hack/image/build-ansible-image.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ source hack/lib/test_lib.sh
66
source hack/lib/image_lib.sh
77

88
ROOTDIR="$(pwd)"
9-
GOTMP="$(mktemp -d)"
10-
trap_add 'rm -rf $GOTMP' EXIT
11-
BASEIMAGEDIR="$GOTMP/ansible-operator"
9+
TMPDIR="$(mktemp -d)"
10+
trap_add 'rm -rf $TMPDIR' EXIT
11+
BASEIMAGEDIR="$TMPDIR/ansible-operator"
1212
mkdir -p "$BASEIMAGEDIR"
1313
go build -o $BASEIMAGEDIR/scaffold-ansible-image ./hack/image/ansible/scaffold-ansible-image.go
1414

hack/image/build-helm-image.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ source hack/lib/test_lib.sh
66
source hack/lib/image_lib.sh
77

88
ROOTDIR="$(pwd)"
9-
GOTMP="$(mktemp -d)"
10-
trap_add 'rm -rf $GOTMP' EXIT
11-
BASEIMAGEDIR="$GOTMP/helm-operator"
9+
TMPDIR="$(mktemp -d)"
10+
trap_add 'rm -rf $TMPDIR' EXIT
11+
BASEIMAGEDIR="$TMPDIR/helm-operator"
1212
mkdir -p "$BASEIMAGEDIR"
1313
go build -o $BASEIMAGEDIR/scaffold-helm-image ./hack/image/helm/scaffold-helm-image.go
1414

hack/tests/e2e-ansible-molecule.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ source hack/lib/test_lib.sh
55
set -eux
66

77
ROOTDIR="$(pwd)"
8-
GOTMP="$(mktemp -d)"
9-
trap_add 'rm -rf $GOTMP' EXIT
8+
TMPDIR="$(mktemp -d)"
9+
trap_add 'rm -rf $TMPDIR' EXIT
1010
pip3 install --user pyasn1==0.4.7 pyasn1-modules==0.2.6 idna==2.8 ipaddress==1.0.22
1111
pip3 install --user molecule==2.22
1212
pip3 install --user docker openshift jmespath
@@ -25,7 +25,7 @@ remove_prereqs() {
2525
kubectl delete --ignore-not-found=true -f "$OPERATORDIR/deploy/crds/ansible.example.com_memcacheds_crd.yaml"
2626
}
2727

28-
pushd "$GOTMP"
28+
pushd "$TMPDIR"
2929
operator-sdk new memcached-operator \
3030
--api-version=ansible.example.com/v1alpha1 \
3131
--kind=Memcached \

hack/tests/e2e-ansible.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ go test -count=1 ./pkg/ansible/proxy/...
1010

1111
DEST_IMAGE="quay.io/example/memcached-operator:v0.0.2"
1212
ROOTDIR="$(pwd)"
13-
GOTMP="$(mktemp -d)"
14-
trap_add 'rm -rf $GOTMP' EXIT
13+
TMPDIR="$(mktemp -d)"
14+
trap_add 'rm -rf $TMPDIR' EXIT
1515

1616
deploy_operator() {
1717
kubectl create -f "$OPERATORDIR/deploy/service_account.yaml"
@@ -129,7 +129,7 @@ test_operator() {
129129
}
130130

131131
# create and build the operator
132-
pushd "$GOTMP"
132+
pushd "$TMPDIR"
133133
operator-sdk new memcached-operator \
134134
--api-version=ansible.example.com/v1alpha1 \
135135
--kind=Memcached \

hack/tests/e2e-helm.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ source hack/lib/image_lib.sh
77

88
DEST_IMAGE="quay.io/example/nginx-operator:v0.0.2"
99
ROOTDIR="$(pwd)"
10-
GOTMP="$(mktemp -d)"
11-
trap_add 'rm -rf $GOTMP' EXIT
10+
TMPDIR="$(mktemp -d)"
11+
trap_add 'rm -rf $TMPDIR' EXIT
1212

1313
deploy_operator() {
1414
kubectl create -f "$OPERATORDIR/deploy/service_account.yaml"
@@ -112,7 +112,7 @@ test_operator() {
112112
}
113113

114114
# create and build the operator
115-
pushd "$GOTMP"
115+
pushd "$TMPDIR"
116116
log=$(operator-sdk new nginx-operator \
117117
--api-version=helm.example.com/v1alpha1 \
118118
--kind=Nginx \

0 commit comments

Comments
 (0)