forked from rancher/rancher-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
304 lines (288 loc) · 14.5 KB
/
Copy pathvalidate.yml
File metadata and controls
304 lines (288 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: Validate Catalog Templates
on:
workflow_dispatch:
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- name: Check out immutable Catalog source
env:
SOURCE_SHA: ${{ github.sha }}
run: |
set -euo pipefail
git init .
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
git fetch --depth=1 origin "$SOURCE_SHA"
git -c advice.detachedHead=false checkout --detach FETCH_HEAD
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
test -z "$(git status --short)"
- name: Set up pinned Python toolchain
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.14.6'
check-latest: false
- name: Validate images, schema, and localized metadata
env:
CATALOG_SERVICE_VERSION: 0.20.7
CATALOG_SERVICE_SHA256: b195dd7f54fecc58e4af6942cd537b7deaaa7c659cfa97b3869e998e6b75fde3
SOURCE_SHA: ${{ github.sha }}
run: |
set -euo pipefail
work_root=$(mktemp -d)
service_pid=
cleanup() {
status=$?
if [ -n "$service_pid" ]; then
kill "$service_pid" 2>/dev/null || true
wait "$service_pid" 2>/dev/null || true
fi
rm -rf "$work_root" 2>/dev/null || true
exit "$status"
}
trap cleanup EXIT
test "$(cat .python-version)" = '3.14.6'
test "$(python -c 'import platform; print(platform.python_version())')" = \
'3.14.6'
python -m pip install \
--disable-pip-version-check \
--require-hashes \
--only-binary=:all: \
--requirement integration/requirements.lock
python -m flake8 integration/core
bash scripts/audit-deployable-images
asset="$work_root/catalog-service.tar.xz"
curl \
--proto '=https' \
--tlsv1.2 \
--fail \
--silent \
--show-error \
--location \
--retry 5 \
--retry-all-errors \
--retry-delay 2 \
-o "$asset" \
"https://github.com/PastureStack/catalog-service/releases/download/v${CATALOG_SERVICE_VERSION}/catalog-service-${CATALOG_SERVICE_VERSION}.tar.xz"
printf '%s %s\n' "$CATALOG_SERVICE_SHA256" "$asset" |
sha256sum --check
tar -xJf "$asset" -C "$work_root"
catalog_service="$work_root/catalog-service-sqlite"
test "$("$catalog_service" --version)" = "v${CATALOG_SERVICE_VERSION}"
branch="validation-${SOURCE_SHA}"
git branch -f "$branch" "$SOURCE_SHA"
jq -n \
--arg url "file://${GITHUB_WORKSPACE}" \
--arg branch "$branch" \
--arg commit "$SOURCE_SHA" \
'{catalogs:{pasturestack:{url:$url,branch:$branch,pinnedCommit:$commit}}}' \
>"$work_root/repo.json"
"$catalog_service" \
--config "$work_root/repo.json" \
--cache "$work_root/validate-cache" \
--validate \
--sqlite \
--port 18088
"$catalog_service" \
--config "$work_root/repo.json" \
--cache "$work_root/service-cache" \
--sqlite \
--refresh-interval 7200 \
--port 18088 \
>"$work_root/catalog-service.log" 2>&1 &
service_pid=$!
ready=false
for _ in $(seq 1 60); do
if curl -fsS --max-time 5 \
'http://127.0.0.1:18088/v1-catalog/templates?limit=-1' \
-o "$work_root/templates.json" 2>/dev/null; then
template_count=$(jq '(.data // []) | length' \
"$work_root/templates.json")
if [ "$template_count" -eq 23 ]; then
ready=true
break
fi
fi
sleep 1
done
if [ "$ready" != true ]; then
tail -100 "$work_root/catalog-service.log" >&2 || true
exit 1
fi
test "$(jq '(.data // []) | length' "$work_root/templates.json")" -eq 23
test "$(jq '[.data[] | select(
.templateBase == "infra" and
.labels["io.pasturestack.catalog.origin"] == "upstream-first-party" and
(.labels["io.pasturestack.catalog.origin-template"] | length) > 0 and
(.labels["io.pasturestack.catalog.origin-status"] |
IN("supported", "experimental", "first-party"))
)] | length' "$work_root/templates.json")" -eq 22
curl -fsS --max-time 10 \
'http://127.0.0.1:18088/v1-catalog/templateversions/pasturestack:infra*kubernetes-cluster:2' \
-o "$work_root/kubernetes-v2.json"
curl -fsS --max-time 10 \
'http://127.0.0.1:18088/v1-catalog/templateversions/pasturestack:infra*kubernetes-cluster:3' \
-o "$work_root/kubernetes-v3.json"
curl -fsS --max-time 10 \
'http://127.0.0.1:18088/v1-catalog/templateversions/pasturestack:infra*kubernetes-cluster:4' \
-o "$work_root/kubernetes-v4.json"
curl -fsS --max-time 10 \
'http://127.0.0.1:18088/v1-catalog/templateversions/pasturestack:infra*kubernetes-cluster:5' \
-o "$work_root/kubernetes-v5.json"
curl -fsS --max-time 10 \
'http://127.0.0.1:18088/v1-catalog/templateversions/pasturestack:infra*kubernetes-cluster:6' \
-o "$work_root/kubernetes-v6.json"
test "$(jq -r '.version' "$work_root/kubernetes-v2.json")" = \
'v1.12.10-pasturestack.2'
test "$(jq -r '.version' "$work_root/kubernetes-v3.json")" = \
'v1.12.10-pasturestack.3'
test "$(jq -r '.version' "$work_root/kubernetes-v4.json")" = \
'v1.12.10-pasturestack.4'
test "$(jq -r '.version' "$work_root/kubernetes-v5.json")" = \
'v1.12.10-pasturestack.5'
test "$(jq -r '.version' "$work_root/kubernetes-v6.json")" = \
'v1.12.10-pasturestack.6'
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v2.json" | \
grep -Fc 'kubernetes-package:v1.12.10-pasturestack.1')" -eq 6
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v3.json" | \
grep -Fc 'kubernetes-package:v1.12.10-pasturestack.3')" -eq 6
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v2.json" | \
grep -Fc 'kubectl-service:v0.9.11-pasturestack.1')" -eq 2
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v3.json" | \
grep -Fc 'kubectl-service:v0.9.11-pasturestack.3')" -eq 2
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v4.json" | \
grep -Fc 'kubernetes-package:v1.12.10-pasturestack.3')" -eq 6
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v4.json" | \
grep -Fc 'kubectl-service:v0.9.11-pasturestack.5')" -eq 2
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v5.json" | \
grep -Fc 'kubernetes-package:v1.12.10-pasturestack.3')" -eq 6
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v5.json" | \
grep -Fc 'etcd-compat:v2.3.7-pasturestack.2')" -eq 1
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v5.json" | \
grep -Fc 'kubectl-service:v0.9.11-pasturestack.5')" -eq 2
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v6.json" | \
grep -Fc 'kubernetes-package:v1.12.10-pasturestack.4')" -eq 6
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v6.json" | \
grep -Fc 'etcd-compat:v2.3.7-pasturestack.2')" -eq 1
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v6.json" | \
grep -Fc 'kubectl-service:v0.9.11-pasturestack.7')" -eq 2
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v6.json" | \
grep -Fc '/var/lib/docker:/var/lib/docker:rslave,z')" -eq 2
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v6.json" | \
grep -Fc '/var/lib/docker:/var/lib/docker:z')" -eq 0
test "$(jq -r '.files["docker-compose.yml.tpl"]' \
"$work_root/kubernetes-v6.json" | grep -Fc '@sha256:')" -eq 0
verify_localized() {
base=$1
folder=$2
expected_name=$3
expected_description=$4
jq -e \
--arg base "$base" \
--arg folder "$folder" \
--arg name "$expected_name" \
--arg description "$expected_description" \
'any(.data[];
((if ((.templateBase // "") == "")
then "template"
else .templateBase
end) == $base) and
(.folderName == $folder) and
(.labels["io.pasturestack.catalog.name.zh-tw"] == $name) and
(.labels["io.pasturestack.catalog.description.zh-tw"] == $description))' \
"$work_root/templates.json" >/dev/null
}
verify_localized infra amazon-ebs-storage \
'Amazon EBS 儲存空間' \
'掛載既有的 Amazon EBS 磁碟區;如需建立加密磁碟區,必須明確啟用雲端資源配置。'
verify_localized infra amazon-efs-storage \
'Amazon EFS 儲存空間' \
'掛載既有的 Amazon EFS 檔案系統;如需建立檔案系統與掛載目標,必須明確啟用雲端資源配置。'
verify_localized infra container-schedule \
'容器定時排程' \
'依容器標籤中的 Cron 表達式,定時啟動、停止或重新啟動容器。'
verify_localized infra ecr-credential-sync \
'Amazon ECR 登入資訊同步' \
'定期更新 Amazon Elastic Container Registry 的短效登入資訊,並同步至目前或指定的環境。'
verify_localized infra healthcheck \
'中繼資料健康檢查' \
'依據中繼資料定義檢查工作負載健康狀態,並透過相容控制 API 回報結果。'
verify_localized infra ipsec-overlay \
'IPsec 加密網路' \
'為受管工作負載提供跨主機的加密網路。'
verify_localized infra kubernetes-cluster \
'Kubernetes 叢集' \
'部署維護中的 Kubernetes 1.12 相容控制平面與主機服務。'
verify_localized infra layer-2-flat-network \
'第 2 層平面網路' \
'透過主機網橋,將受管理的工作負載直接連接到共用的第 2 層子網路。'
verify_localized infra network-policy-manager \
'網路政策管理器' \
'依中繼資料中的網路政策,在每台受管主機套用最小權限的流量控管規則。'
verify_localized infra network-services \
'網路服務' \
'安裝受管工作負載所需的主機網路、中繼資料與內部 DNS 服務。'
verify_localized infra network-diagnostics \
'網路診斷' \
'蒐集經過界線控管與去識別化處理的主機網路健康摘要,並保留由管理者建立的診斷封存檔。'
verify_localized infra nfs-storage \
'NFS 儲存空間' \
'提供 NFS 第 3 版與第 4 版的 Docker 磁碟區,移除磁碟區時預設保留資料。'
verify_localized infra secret-volume-driver \
'機密資料磁碟區' \
'將控制平面核准的加密機密資料,以唯讀的記憶體磁碟區安全提供給工作負載。'
verify_localized infra per-host-subnet-network \
'每台主機獨立子網路' \
'為每台主機配置獨立的工作負載子網路,並維護主機間的閘道路由。'
verify_localized infra resource-scheduler \
'資源排程器' \
'依控制平面事件與目前的中繼資料狀態,排程原生工作負載。'
verify_localized infra route53-dns-sync \
'Route 53 DNS 紀錄同步' \
'將相容環境的服務位址同步至指定的 Amazon Route 53 託管區域。'
verify_localized infra system-image-preloader \
'系統映像預先下載' \
'預先下載相容基礎架構堆疊所需的容器映像,以縮短主機升級等待時間。'
verify_localized infra vault-volume-driver \
'Vault 存取權杖磁碟區' \
'透過主機身分驗證及唯讀記憶體磁碟區,為每個工作負載安全提供短效、回應封裝的 Vault 存取權杖。'
verify_localized infra vxlan-overlay-network \
'VXLAN 覆疊網路' \
'透過 UDP 4789,在受管主機之間建立未加密的 VXLAN 覆疊網路。'
verify_localized infra windows-container-networking \
'Windows 容器網路' \
'為相容的 Windows 容器主機定義 NAT 與透明 Docker 網路驅動程式。'
verify_localized infra windows-ecr-credential-sync \
'Windows ECR 登入資訊同步' \
'從相容的 Windows Server 2022 主機定期更新 Amazon ECR 短效登入資訊。'
verify_localized infra windows-network-services \
'Windows 網路服務' \
'為相容的 Windows Server 2022 工作負載安裝中繼資料與內部 DNS 服務。'
verify_localized project native \
'原生專案範本' \
'PastureStack 原生編排執行環境的預設專案範本。'
CATALOG_SERVICE_BIN="$catalog_service" \
CATALOG_TEST_REPO="$GITHUB_WORKSPACE" \
CATALOG_TEST_BRANCH="$branch" \
CATALOG_TEST_COMMIT="$SOURCE_SHA" \
CATALOG_TEST_BASE_URL='http://127.0.0.1:18088' \
CATALOG_TEST_NAME='pasturestack' \
python -m pytest -q integration/core \
-k 'not test_validate_exits_normal'
echo "CATALOG_TW_LOCALIZATION_OK source=$SOURCE_SHA templates=23 infra_first_party=22 questions=171 python=3.14.6 pytest=3"