forked from minio/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-operator-krew.py
64 lines (57 loc) · 2 KB
/
update-operator-krew.py
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
#!/usr/bin/env python
import subprocess
version = "v5.0.3"
template = f"""apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: minio
spec:
version: {version}
homepage: https://github.com/minio/operator/tree/master/kubectl-minio
shortDescription: Deploy and manage MinIO Operator and Tenant(s)
description: |
The kubectl-minio plugin wraps the MinIO Operator and provides a simplified
interface to create and manage MinIO tenant clusters.
caveats: |
* For resources that are not in default namespace, currently you must
specify -n/--namespace explicitly (the current namespace setting is not
yet used).
platforms:
"""
main_url = "https://github.com/minio/operator/releases/download/{version}/kubectl-minio_{os}_{arch}{suffix}.zip"
builds = {
"darwin": [
{ "arch": "amd64", "suffix": "_v1"},
{ "arch": "arm64", "suffix": "" }
],
"linux": [
{ "arch": "amd64", "suffix": "_v1" },
{ "arch": "arm64", "suffix": "" }
],
"windows": [
{ "arch": "amd64", "suffix": "_v1" }
],
}
buffer = template
cmd = "curl -L {url} | sha256sum"
for os_key in builds:
for arch_key in builds[os_key]:
url = main_url.format(version=version, os=os_key, arch=arch_key['arch'], suffix=arch_key['suffix'])
ps = subprocess.Popen(('curl', '-L', '--fail', url), stdout=subprocess.PIPE)
output = subprocess.check_output(('sha256sum'), stdin=ps.stdout)
ps.wait()
hash = output.strip().decode("utf-8", "ignore").replace(" -", "")
# print(hash)
binaryext = ""
if os_key == "windows":
binaryext = ".exe"
buffer += f""" - selector:
matchLabels:
os: {os_key}
arch: {arch_key['arch']}
uri: https://github.com/minio/operator/releases/download/{version}/kubectl-minio_{os_key}_{arch_key['arch']}{arch_key['suffix']}.zip
sha256: {hash}
bin: kubectl-minio{binaryext}
"""
with open("minio.yaml", "w") as f:
f.write(buffer)