Skip to content

Commit cae22ce

Browse files
authored
Merge pull request #523 from rewantsoni/macos
make the operator scripts compatible with mac
2 parents cd5a9a2 + 371b157 commit cae22ce

5 files changed

Lines changed: 51 additions & 25 deletions

File tree

.github/workflows/build.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ permissions:
1616
jobs:
1717
build:
1818
name: build
19-
runs-on: ubuntu-latest
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, macos-latest]
2023
steps:
2124
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2225
with:
2326
fetch-depth: 1
2427
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
2528
with:
2629
go-version-file: go.mod
30+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
31+
with:
32+
python-version: '3.x'
33+
- name: Install Python dependencies
34+
run: pip install pyyaml
2735
- name: run make build
2836
run: make build
2937
- name: make build installer

.github/workflows/lint.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ jobs:
3939
4040
golangci:
4141
name: golangci-lint
42-
runs-on: ubuntu-latest
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
matrix:
45+
os: [ubuntu-latest, macos-latest]
4346
steps:
4447
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4548
with:
@@ -93,7 +96,10 @@ jobs:
9396
9497
modcheck:
9598
name: modcheck
96-
runs-on: ubuntu-latest
99+
runs-on: ${{ matrix.os }}
100+
strategy:
101+
matrix:
102+
os: [ubuntu-latest, macos-latest]
97103
steps:
98104
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99105
with:
@@ -106,9 +112,15 @@ jobs:
106112

107113
vendorcheck:
108114
name: vendorcheck
109-
runs-on: ubuntu-latest
115+
runs-on: ${{ matrix.os }}
116+
strategy:
117+
matrix:
118+
os: [ubuntu-latest, macos-latest]
110119
steps:
111120
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
121+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
122+
with:
123+
go-version-file: go.mod
112124
- name: Check the vendor folder consistency
113125
run: |
114126
go mod vendor -o vendor.gen

.github/workflows/unit-test.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ permissions:
1818
jobs:
1919
unittests:
2020
name: unittests
21-
runs-on: ubuntu-latest
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest, macos-latest]
2225
steps:
23-
- name: checkout
26+
- name: checkout
2427
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2528
with:
2629
fetch-depth: 1
27-
- name: setup go
30+
- name: setup go
2831
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
29-
with:
32+
with:
3033
go-version-file: go.mod
3134
check-latest: true
3235
- name: run unit tests

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ set -e; \
354354
package=$(2)@$(3) ;\
355355
echo "Downloading $${package}" ;\
356356
GOBIN=$(LOCALBIN) go install $${package} ;\
357-
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\
357+
tmp="$(1)" ;\
358+
mv "$${tmp%-$(3)}" $(1) ;\
358359
}
359360
endef

hack/patch-csi-operator-helm-chart.sh

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,28 @@ if [ ! -f "$SA_FILE" ]; then
1313
exit 1
1414
fi
1515

16-
TEMPLATE_SNIPPET=$(
17-
cat <<'EOF'
18-
{{- with .Values.imagePullSecrets }}
19-
imagePullSecrets:
20-
{{ toYaml . | indent 2 }}
21-
{{- end }}
22-
EOF
23-
)
24-
2516
echo "Patching $SA_FILE for imagePullSecrets"
2617

27-
awk -v snippet="$TEMPLATE_SNIPPET" '
18+
# Use awk to insert the snippet before each '---' separator and at the end
19+
awk '
2820
# Before printing a separator, print the snippet
29-
/^---/ { print snippet }
21+
/^---/ {
22+
print "{{- with .Values.imagePullSecrets }}"
23+
print "imagePullSecrets:"
24+
print "{{ toYaml . | indent 2 }}"
25+
print "{{- end }}"
26+
}
3027
3128
# Print the current line
3229
{ print }
3330
3431
# At the end of the file, print the snippet for the last section
35-
END { print snippet }
32+
END {
33+
print "{{- with .Values.imagePullSecrets }}"
34+
print "imagePullSecrets:"
35+
print "{{ toYaml . | indent 2 }}"
36+
print "{{- end }}"
37+
}
3638
' "$SA_FILE" >"${SA_FILE}.tmp"
3739

3840
mv "${SA_FILE}.tmp" "$SA_FILE"
@@ -51,12 +53,12 @@ if [[ "$CHART_DIR" == *"ceph-csi-operator"* ]]; then
5153

5254
# Check if the file already has the $root variable definition
5355
if ! grep -q "{{- \$root := . -}}" "$file"; then
54-
# Add the $root variable definition at the top of the file
55-
sed -i "1i{{- \$root := . -}}" "$file"
56+
# Add the $root variable definition at the top of the file using a temp file
57+
echo "{{- \$root := . -}}" | cat - "$file" > "$file.tmp" && mv "$file.tmp" "$file"
5658
fi
5759

58-
# Replace the namespace string
59-
sed -i "s/namespace: ceph-csi-operator-system/namespace: {{ \$root.Release.Namespace }}/g" "$file"
60+
# Replace the namespace string using a temp file (portable across all platforms)
61+
sed "s/namespace: ceph-csi-operator-system/namespace: {{ \$root.Release.Namespace }}/g" "$file" > "$file.tmp" && mv "$file.tmp" "$file"
6062
fi
6163
done
6264

0 commit comments

Comments
 (0)