Skip to content

Commit 7055ff6

Browse files
Updating the subprocess.run stuff to use lists of arguments
1 parent c87c908 commit 7055ff6

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

bin/buildAndDeploy.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def buildArchs() -> dict:
3737
"""Returns the list of binaries we should build"""
3838
buildArchs = {
3939
'darwin': ['arm64', 'amd64'],
40-
'linux': ['amd64', '386', 'arm64', 'ppc64le', 's390x'],
40+
'linux': ['amd64', '386', 'arm64'],
4141
'windows': ['386', 'amd64'],
4242
}
4343
return buildArchs
@@ -54,28 +54,29 @@ def cgoEnable(theOs: str, theArch: str) -> int:
5454
def runTests() -> None:
5555
"""Runs unit tests"""
5656

57-
go_ven = 'go mod vendor'
58-
print(f"[turquoise2]Running: {go_ven}")
57+
go_ven = ['go', 'mod', 'vendor']
58+
print("[turquoise2]Running: " + " ".join(go_ven))
5959
subprocess.run(go_ven, check=True)
6060
# We can't use the `| grep -v "fixtures" | grep -v "vendor"` stuff because working with pipes in
6161
# subprocess is tricky, doing this is easier to me.
62-
go_mods = 'go list ./...'
63-
print(f"[turquoise2]Running: {go_mods}")
62+
go_mods = ['go', 'list', './...']
63+
print(f"[turquoise2]Running:" + " ".join(go_mods))
6464
mods = subprocess.run(go_mods, capture_output=True, check=True, text=True)
6565
clean_mods = []
6666
for mod in mods.stdout.split("\n"):
6767
if re.match(r"fixtrues|vendor", mod) is None:
6868
clean_mods.append(mod)
6969

70-
go_vet = f"go vet {' '.join(clean_mods)}"
70+
go_vet = ['go', 'vet'] + clean_mods
7171
# Not using the 'real' command here because this looks neater.
7272
print(f'[turquoise2]Running: go vet $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
7373
subprocess.run(go_vet, check=True)
74-
go_test = f"go test {' '.join(clean_mods)}"
75-
print(f'[turquoise2]Running: go test $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
74+
go_test = ['go', 'test'] + clean_mods
75+
print(f'[turquoise2]Running: ' + " ".join(go_test))
7676
subprocess.run(go_test, check=True)
77-
go_sec = 'gosec -exclude-dir=fixture -exclude-dir=plugin/resources -quiet ./...'
78-
print(f'[turquoise2]Running: {go_sec}')
77+
go_sec = ['gosec', '-exclude-dir=fixture', '-exclude-dir=plugin/resources', '-quiet', './...']
78+
# Not using the 'real' command because this is more copy/pasteable.
79+
print(f'[turquoise2]Running: go test $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
7980
try:
8081
subprocess.run(go_sec, check=True)
8182
except FileNotFoundError:
@@ -255,13 +256,14 @@ def deploy(self):
255256
apikey = os.getenv("IBMCLOUD_APIKEY")
256257
if not apikey:
257258
raise Exception("IBMCLOUD_APIKEY needs to be set to the proper API key first.")
258-
login_cmd = f"ibmcloud login --apikey {apikey}"
259+
login_cmd = ["ibmcloud", "login", f"--apikey={apikey}"]
259260
print(f"[yellow]Running: ibmcloud login --apikey $IBMCLOUD_APIKEY")
260261
subprocess.run(login_cmd)
261262
files = glob.glob(os.path.join(self.cwd, 'out', f"sl-{self.version}-*"))
262263
for f in files:
263-
upload_cmd = f"ibmcloud cos upload --bucket softlayer-cli-binaries --file {f} --key {os.path.basename(f)}"
264-
print(f"[yellow]Running: {upload_cmd}")
264+
upload_cmd = ["ibmcloud", "cos", "upload", "--bucket=softlayer-cli-binaries",
265+
f"--file={f}", f"--key={os.path.basename(f)}"]
266+
print(f"[yellow]Running: " + " ".join(upload_cmd))
265267
subprocess.run(upload_cmd)
266268

267269
def getChecksums(self) -> dict:

0 commit comments

Comments
 (0)