Skip to content

Commit 7f7cc9a

Browse files
[v1.3.x] (helm/v1,ansible/v1) fix download URLs and order of binary checks (#4412)
Signed-off-by: Eric Stroczynski <[email protected]> Co-authored-by: Eric Stroczynski <[email protected]>
1 parent 608aa05 commit 7f7cc9a

File tree

5 files changed

+106
-64
lines changed

5 files changed

+106
-64
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
entries:
2+
- description: >
3+
Corrected the download URL for helm-operator and ansible-operator in their respective project types.
4+
kind: bugfix
5+
migration:
6+
header: For Helm and Ansible projects, fix the helm-operator and ansible-operator URLs in the Makefile
7+
body: >
8+
Helm projects: `https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/helm-operator-v1.3.0-$(ARCHOPER)-$(OSOPER)`
9+
-> `https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/helm-operator_$(OS)_$(ARCH)`
10+
Ansible projects: `https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/ansible-operator-v1.3.0-$(ARCHOPER)-$(OSOPER)`
11+
-> `https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/ansible-operator_$(OS)_$(ARCH)`
12+
- description: >
13+
Fixed the order of helm-operator, ansible-operator, and kustomize binary checks in the Makefile.
14+
kind: bugfix
15+
migration:
16+
header: For Helm and Ansible projects, fix the helm-operator, ansible-operator, and kustomize Makefile rules
17+
body: >
18+
See the diff in [this PR](https://github.com/operator-framework/operator-sdk/pull/4407) for details.

internal/plugins/ansible/v1/scaffolds/internal/templates/makefile.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,34 +101,40 @@ docker-push:
101101
102102
PATH := $(PATH):$(PWD)/bin
103103
SHELL := env PATH=$(PATH) /bin/sh
104-
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
105-
ARCH = $(shell uname -m | sed 's/x86_64/amd64/')
106-
OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/')
107-
ARCHOPER = $(shell uname -m )
104+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
105+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
108106
107+
# Download kustomize locally if necessary, preferring the $(pwd)/bin path over global if both exist.
108+
.PHONY: kustomize
109+
KUSTOMIZE = $(shell pwd)/bin/kustomize
109110
kustomize:
110-
ifeq (, $(shell which kustomize 2>/dev/null))
111+
ifeq (,$(wildcard $(KUSTOMIZE)))
112+
ifeq (,$(shell which kustomize 2>/dev/null))
111113
@{ \
112114
set -e ;\
113-
mkdir -p bin ;\
114-
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/{{ .KustomizeVersion }}/kustomize_{{ .KustomizeVersion }}_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\
115+
mkdir -p $(dir $(KUSTOMIZE)) ;\
116+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/{{ .KustomizeVersion }}/kustomize_{{ .KustomizeVersion }}_$(OS)_$(ARCH).tar.gz | \
117+
tar xzf - -C bin/ ;\
115118
}
116-
KUSTOMIZE=$(realpath ./bin/kustomize)
117119
else
118-
KUSTOMIZE=$(shell which kustomize)
120+
KUSTOMIZE = $(shell which kustomize)
121+
endif
119122
endif
120123
124+
# Download ansible-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
125+
.PHONY: ansible-operator
126+
ANSIBLE_OPERATOR = $(shell pwd)/bin/ansible-operator
121127
ansible-operator:
122-
ifeq (, $(shell which ansible-operator 2>/dev/null))
128+
ifeq (,$(wildcard $(ANSIBLE_OPERATOR)))
129+
ifeq (,$(shell which ansible-operator 2>/dev/null))
123130
@{ \
124131
set -e ;\
125-
mkdir -p bin ;\
126-
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/{{ .AnsibleOperatorVersion}}/ansible-operator-{{ .AnsibleOperatorVersion}}-$(ARCHOPER)-$(OSOPER) ;\
127-
mv ansible-operator-{{ .AnsibleOperatorVersion}}-$(ARCHOPER)-$(OSOPER) ./bin/ansible-operator ;\
128-
chmod +x ./bin/ansible-operator ;\
132+
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
133+
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/{{ .AnsibleOperatorVersion }}/ansible-operator_$(OS)_$(ARCH) ;\
134+
chmod +x $(ANSIBLE_OPERATOR) ;\
129135
}
130-
ANSIBLE_OPERATOR=$(realpath ./bin/ansible-operator)
131136
else
132-
ANSIBLE_OPERATOR=$(shell which ansible-operator)
137+
ANSIBLE_OPERATOR = $(shell which ansible-operator)
138+
endif
133139
endif
134140
`

internal/plugins/helm/v1/scaffolds/internal/templates/makefile.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,34 +101,40 @@ docker-push:
101101
102102
PATH := $(PATH):$(PWD)/bin
103103
SHELL := env PATH=$(PATH) /bin/sh
104-
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
105-
ARCH = $(shell uname -m | sed 's/x86_64/amd64/')
106-
OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/')
107-
ARCHOPER = $(shell uname -m )
104+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
105+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
108106
107+
# Download kustomize locally if necessary, preferring the $(pwd)/bin path over global if both exist.
108+
.PHONY: kustomize
109+
KUSTOMIZE = $(shell pwd)/bin/kustomize
109110
kustomize:
110-
ifeq (, $(shell which kustomize 2>/dev/null))
111+
ifeq (,$(wildcard $(KUSTOMIZE)))
112+
ifeq (,$(shell which kustomize 2>/dev/null))
111113
@{ \
112114
set -e ;\
113-
mkdir -p bin ;\
114-
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/{{ .KustomizeVersion }}/kustomize_{{ .KustomizeVersion }}_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\
115+
mkdir -p $(dir $(KUSTOMIZE)) ;\
116+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/{{ .KustomizeVersion }}/kustomize_{{ .KustomizeVersion }}_$(OS)_$(ARCH).tar.gz | \
117+
tar xzf - -C bin/ ;\
115118
}
116-
KUSTOMIZE=$(realpath ./bin/kustomize)
117119
else
118-
KUSTOMIZE=$(shell which kustomize)
120+
KUSTOMIZE = $(shell which kustomize)
121+
endif
119122
endif
120123
124+
# Download helm-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
125+
.PHONY: helm-operator
126+
HELM_OPERATOR = $(shell pwd)/bin/helm-operator
121127
helm-operator:
122-
ifeq (, $(shell which helm-operator 2>/dev/null))
128+
ifeq (,$(wildcard $(HELM_OPERATOR)))
129+
ifeq (,$(shell which helm-operator 2>/dev/null))
123130
@{ \
124131
set -e ;\
125-
mkdir -p bin ;\
126-
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/{{ .HelmOperatorVersion }}/helm-operator-{{ .HelmOperatorVersion }}-$(ARCHOPER)-$(OSOPER) ;\
127-
mv helm-operator-{{ .HelmOperatorVersion }}-$(ARCHOPER)-$(OSOPER) ./bin/helm-operator ;\
128-
chmod +x ./bin/helm-operator ;\
132+
mkdir -p $(dir $(HELM_OPERATOR)) ;\
133+
curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/{{ .HelmOperatorVersion }}/helm-operator_$(OS)_$(ARCH) ;\
134+
chmod +x $(HELM_OPERATOR) ;\
129135
}
130-
HELM_OPERATOR=$(realpath ./bin/helm-operator)
131136
else
132-
HELM_OPERATOR=$(shell which helm-operator)
137+
HELM_OPERATOR = $(shell which helm-operator)
138+
endif
133139
endif
134140
`

testdata/ansible/memcached-operator/Makefile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,41 @@ docker-push:
4747

4848
PATH := $(PATH):$(PWD)/bin
4949
SHELL := env PATH=$(PATH) /bin/sh
50-
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
51-
ARCH = $(shell uname -m | sed 's/x86_64/amd64/')
52-
OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/')
53-
ARCHOPER = $(shell uname -m )
50+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
51+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
5452

53+
# Download kustomize locally if necessary, preferring the $(pwd)/bin path over global if both exist.
54+
.PHONY: kustomize
55+
KUSTOMIZE = $(shell pwd)/bin/kustomize
5556
kustomize:
56-
ifeq (, $(shell which kustomize 2>/dev/null))
57+
ifeq (,$(wildcard $(KUSTOMIZE)))
58+
ifeq (,$(shell which kustomize 2>/dev/null))
5759
@{ \
5860
set -e ;\
59-
mkdir -p bin ;\
60-
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\
61+
mkdir -p $(dir $(KUSTOMIZE)) ;\
62+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | \
63+
tar xzf - -C bin/ ;\
6164
}
62-
KUSTOMIZE=$(realpath ./bin/kustomize)
6365
else
64-
KUSTOMIZE=$(shell which kustomize)
66+
KUSTOMIZE = $(shell which kustomize)
67+
endif
6568
endif
6669

70+
# Download ansible-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
71+
.PHONY: ansible-operator
72+
ANSIBLE_OPERATOR = $(shell pwd)/bin/ansible-operator
6773
ansible-operator:
68-
ifeq (, $(shell which ansible-operator 2>/dev/null))
74+
ifeq (,$(wildcard $(ANSIBLE_OPERATOR)))
75+
ifeq (,$(shell which ansible-operator 2>/dev/null))
6976
@{ \
7077
set -e ;\
71-
mkdir -p bin ;\
72-
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/ansible-operator-v1.3.0-$(ARCHOPER)-$(OSOPER) ;\
73-
mv ansible-operator-v1.3.0-$(ARCHOPER)-$(OSOPER) ./bin/ansible-operator ;\
74-
chmod +x ./bin/ansible-operator ;\
78+
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
79+
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/ansible-operator_$(OS)_$(ARCH) ;\
80+
chmod +x $(ANSIBLE_OPERATOR) ;\
7581
}
76-
ANSIBLE_OPERATOR=$(realpath ./bin/ansible-operator)
7782
else
78-
ANSIBLE_OPERATOR=$(shell which ansible-operator)
83+
ANSIBLE_OPERATOR = $(shell which ansible-operator)
84+
endif
7985
endif
8086

8187
# Generate bundle manifests and metadata, then validate generated files.

testdata/helm/memcached-operator/Makefile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,41 @@ docker-push:
4747

4848
PATH := $(PATH):$(PWD)/bin
4949
SHELL := env PATH=$(PATH) /bin/sh
50-
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
51-
ARCH = $(shell uname -m | sed 's/x86_64/amd64/')
52-
OSOPER = $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/apple-darwin/' | sed 's/linux/linux-gnu/')
53-
ARCHOPER = $(shell uname -m )
50+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
51+
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
5452

53+
# Download kustomize locally if necessary, preferring the $(pwd)/bin path over global if both exist.
54+
.PHONY: kustomize
55+
KUSTOMIZE = $(shell pwd)/bin/kustomize
5556
kustomize:
56-
ifeq (, $(shell which kustomize 2>/dev/null))
57+
ifeq (,$(wildcard $(KUSTOMIZE)))
58+
ifeq (,$(shell which kustomize 2>/dev/null))
5759
@{ \
5860
set -e ;\
59-
mkdir -p bin ;\
60-
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | tar xzf - -C bin/ ;\
61+
mkdir -p $(dir $(KUSTOMIZE)) ;\
62+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.5.4/kustomize_v3.5.4_$(OS)_$(ARCH).tar.gz | \
63+
tar xzf - -C bin/ ;\
6164
}
62-
KUSTOMIZE=$(realpath ./bin/kustomize)
6365
else
64-
KUSTOMIZE=$(shell which kustomize)
66+
KUSTOMIZE = $(shell which kustomize)
67+
endif
6568
endif
6669

70+
# Download helm-operator locally if necessary, preferring the $(pwd)/bin path over global if both exist.
71+
.PHONY: helm-operator
72+
HELM_OPERATOR = $(shell pwd)/bin/helm-operator
6773
helm-operator:
68-
ifeq (, $(shell which helm-operator 2>/dev/null))
74+
ifeq (,$(wildcard $(HELM_OPERATOR)))
75+
ifeq (,$(shell which helm-operator 2>/dev/null))
6976
@{ \
7077
set -e ;\
71-
mkdir -p bin ;\
72-
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/helm-operator-v1.3.0-$(ARCHOPER)-$(OSOPER) ;\
73-
mv helm-operator-v1.3.0-$(ARCHOPER)-$(OSOPER) ./bin/helm-operator ;\
74-
chmod +x ./bin/helm-operator ;\
78+
mkdir -p $(dir $(HELM_OPERATOR)) ;\
79+
curl -sSLo $(HELM_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.3.0/helm-operator_$(OS)_$(ARCH) ;\
80+
chmod +x $(HELM_OPERATOR) ;\
7581
}
76-
HELM_OPERATOR=$(realpath ./bin/helm-operator)
7782
else
78-
HELM_OPERATOR=$(shell which helm-operator)
83+
HELM_OPERATOR = $(shell which helm-operator)
84+
endif
7985
endif
8086

8187
# Generate bundle manifests and metadata, then validate generated files.

0 commit comments

Comments
 (0)