1#!/usr/bin/env python 2# 3# Copyright 2017 Google Inc. 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 17 18DOWNLOAD_URL = 'https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz' 19 20 21def create_asset(target_dir): 22 """Create the asset.""" 23 tmp = tempfile.mkdtemp() 24 subprocess.check_call(['wget', DOWNLOAD_URL], cwd=tmp) 25 subprocess.check_call( 26 ['tar', 'xf', os.path.join(tmp, 'kubeval-linux-amd64.tar.gz'), 'kubeval'], 27 cwd=target_dir) 28 subprocess.check_call(['rm', '-rf', tmp]) 29 30 31def main(): 32 parser = argparse.ArgumentParser() 33 parser.add_argument('--target_dir', '-t', required=True) 34 args = parser.parse_args() 35 create_asset(args.target_dir) 36 37 38if __name__ == '__main__': 39 main() 40 41