Skip to content

Commit b1b32f7

Browse files
committed
remove junk and chmod 644 on the bundle files
1 parent ebc6028 commit b1b32f7

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

opa/private/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
exports_files(["opa_eval.sh.tpl"])

opa/private/opa_eval_binary.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ opa_eval_binary = rule(
7272
allow_single_file = True,
7373
doc = "input",
7474
),
75-
"_template": attr.label(
76-
default = Label("opa_eval.sh.tpl"),
77-
allow_single_file = True,
78-
),
7975
},
8076
toolchains = ["//tools:toolchain_type"],
8177
)

opa/private/opa_rules_dependencies.bzl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ _OPA_SHA256 = {
55
"0.54.0": {
66
"opa_darwin_amd64": "a33e829306cd2210ed743da7f4f957588ea350a184bb6ecbb7cbfd77ae7ca401",
77
"opa_darwin_arm64_static": "74500746e5faf0deb60863f1a3d1e3eed96006ff8183940f1c13f1a47969059d",
8-
"opa_linux_amd64": "63c29426db9cf1a2584fcb65c08519cb52077d832933a02c31292555ff6dc3b3",
98
"opa_linux_amd64_static": "633829141f8d6706ac24e0b84393d7730a975a17cc4a15790bf7fad959a28ec3",
109
"opa_linux_arm64_static": "883e22c082508e2f95ba25333559ba8a5c38c9c5ef667314e132c9d8451450d8",
1110
"opa_windows_amd64": "25284b69e1dd7feaa17446e49b1085b61dca0b496dc868304153eb64b422c7eb",
@@ -17,7 +16,6 @@ _OPA_SHA256 = {
1716
_SUPPORTED_PLATFORMS = [
1817
"opa_darwin_amd64",
1918
"opa_darwin_arm64_static",
20-
"opa_linux_amd64",
2119
"opa_linux_amd64_static",
2220
"opa_linux_arm64_static",
2321
"opa_windows_amd64",
@@ -40,7 +38,7 @@ def opa_rules_dependencies(
4038
url = "https://github.com/open-policy-agent/opa/releases/download/v%s/%s%s" % (version, bin, extname),
4139
sha256 = sha256,
4240
executable = 1,
43-
downloaded_file_path = "opa",
41+
downloaded_file_path = "opa%s" % extname,
4442
)
4543

4644
maybe(

tools/opa_ctx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def main():
8585
if args.output:
8686
file, alias = split_once_or_double(args.output, ":")
8787
copy_file(os.path.join(args.wd, alias), file)
88+
os.chmod(file, 0o644)
8889

8990

9091
if __name__ == "__main__":

tools/opa_signer.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from argparse import ArgumentParser
22
from tarfile import TarFile, TarInfo, open as taropen
3-
from subprocess import run, PIPE,STDOUT
3+
from subprocess import run, PIPE, STDOUT
44
from dataclasses import dataclass
55
from io import BytesIO
66
import sys
77
import os
88

9+
910
@dataclass
1011
class Args:
1112
bundle: str
@@ -14,8 +15,10 @@ class Args:
1415
signing_alg: str
1516
command: list[str]
1617

18+
1719
def parse_args() -> Args:
18-
parser = ArgumentParser(prog="rules_opa::opa_signer", description="Tool to re-bundle an opa bundle with a signature file")
20+
parser = ArgumentParser(prog="rules_opa::opa_signer",
21+
description="Tool to re-bundle an opa bundle with a signature file")
1922

2023
parser.add_argument("-b", "--bundle", required=True)
2124
parser.add_argument("-o", "--output", required=True)
@@ -33,28 +36,34 @@ def parse_args() -> Args:
3336
ns.command,
3437
)
3538

39+
3640
def perform_signature(args: Args) -> str:
3741
expected_file = ".signatures.json"
38-
completed_process = run(args.command + ['--signing-key', args.signing_key, "--signing-alg", args.signing_alg, "--bundle", args.bundle], stdout=PIPE, stderr=STDOUT)
42+
completed_process = run(args.command + ['--signing-key', args.signing_key, "--signing-alg",
43+
args.signing_alg, "--bundle", args.bundle], stdout=PIPE, stderr=STDOUT)
3944
returncode = completed_process.returncode
40-
45+
4146
if returncode != 0:
4247
command = " ".join(completed_process.args)
4348
stdout = completed_process.stdout.decode()
44-
print(f"Command exited with non-zero return code {returncode}.\n{command}\n{stdout}", file=sys.stderr)
49+
print(
50+
f"Command exited with non-zero return code {returncode}.\n{command}\n{stdout}", file=sys.stderr)
4551
sys.exit(1)
46-
52+
4753
if not os.path.exists(expected_file):
4854
command = " ".join(completed_process.args)
49-
print(f"File {expected_file} not found after running command:\n{command}", file=sys.stderr)
55+
print(
56+
f"File {expected_file} not found after running command:\n{command}", file=sys.stderr)
5057
sys.exit(1)
5158

5259
return expected_file
5360

61+
5462
def transfer_files(output: TarFile, bundle: TarFile):
5563
for member in bundle.getmembers():
5664
output.addfile(member, bundle.extractfile(member))
5765

66+
5867
def addfile(output: TarFile, file_name: str):
5968
with open(file_name, mode="rb") as f:
6069
data = f.read()
@@ -74,6 +83,8 @@ def main():
7483
addfile(output, signature_file)
7584
transfer_files(output, bundle)
7685

86+
os.chmod(args.output, 0o644)
87+
88+
7789
if __name__ == "__main__":
7890
main()
79-

0 commit comments

Comments
 (0)