xref: /aosp_15_r20/external/skia/infra/bots/assets/kubeval_mac_amd64/create.py (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1#!/usr/bin/env python3
2#
3# Copyright 2024 Google LLC
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8
9"""Create the asset."""
10
11
12import argparse
13import os
14import subprocess
15import tempfile
16
17URL = 'https://github.com/instrumenta/kubeval/releases/download/v0.16.1/kubeval-darwin-amd64.tar.gz'
18SHA256 = 'c79a91f2e6638463881a8189e0628ebd583a5e2912e6f411897e3cea567125e7'
19
20BINARY = URL.split('/')[-1]
21
22
23def create_asset(target_dir):
24  """Create the asset."""
25  tmp = tempfile.mkdtemp()
26  target_file = os.path.join(tmp, 'kubeval.tar.gz')
27  subprocess.call(['wget', '--quiet', '--output-document', target_file, URL])
28  output = subprocess.check_output(['sha256sum', target_file], encoding='utf-8')
29  actual_hash = output.split(' ')[0]
30  if actual_hash != SHA256:
31    raise Exception('SHA256 does not match (%s != %s)' % (actual_hash, SHA256))
32  subprocess.check_call(
33      ['tar', 'xf', os.path.join(tmp, 'kubeval.tar.gz'), 'kubeval'],
34      cwd=target_dir)
35  subprocess.check_call(['rm', '-rf', tmp])
36
37
38def main():
39  parser = argparse.ArgumentParser()
40  parser.add_argument('--target_dir', '-t', required=True)
41  args = parser.parse_args()
42  create_asset(args.target_dir)
43
44
45if __name__ == '__main__':
46  main()
47
48