forked from tilt-dev/tilt-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTiltfile
27 lines (25 loc) · 1.07 KB
/
Tiltfile
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
load('ext://local_output', 'local_output')
def encode_base64(content):
base64_cmd = ['base64']
# the bsd base64 binary has no "-w" cli option. there is an alternative "-b" which has "0" as default, so we pass "-w 0" only if we use a gnu base64 binary
# see https://stackoverflow.com/a/46464081
# windows is not affected
is_windows = True if os.name == 'nt' else False
is_gnu_base64 = True if not is_windows and 'gnu coreutils' in local_output('base64 --version', quiet=True, echo_off=True).lower() else False
if is_gnu_base64:
base64_cmd.extend(['-w', '0'])
return local_output(
command=base64_cmd,
command_bat=['powershell', '[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($input))'],
quiet=True,
echo_off=True,
stdin=content,
)
def decode_base64(content):
return local_output(
command=['base64', '-d'],
command_bat=['powershell', '[Text.Encoding]::UTF8.GetString([convert]::FromBase64String($input))'],
quiet=True,
echo_off=True,
stdin=content,
)