Code Snippets Starlark

Short texts Starlark 🧑‍💻 Code snippets Starlark ✍️ Reading lists Starlark 👀

Starlark debug macro

def _stringify_provider(p): if type(p) == “DefaultInfo”: return “”” {} data_runfiles: {} default_runfiles: {} files: {} files_to_run: executable: {} runfiles_manifest: {} “””.format( type(p), p.data_runfiles.files.to_list(), p.default_runfiles.files.to_list(), p.files.to_list(), p.files_to_run.executable, p.files_to_run.runfiles_manifest, ) elif type(p) == “CcInfo”: return “”” {} compilation_context {} linking_context {} “””.format( type(p), str(p.compilation_context), str(p.linking_context), ) KNOWN_PROVIDERS = [DefaultInfo, CcInfo] def _debug_impl(ctx): to_print = “” providers = […]

Tiltfile Example with function

load(‘ext://restart_process’, ‘docker_build_with_restart’) def poc1(path = ‘.’): docker_build_with_restart(‘zerotrustpoc/poc1’, path, build_args = { ‘node_env’: ‘development’ }, entrypoint = ‘node dist/main.js’, live_update = [ sync(path + ‘/src’, ‘/app/src’), sync(path + ‘/package.json’, ‘/app/package.json’), sync(path + ‘/package-lock.json’, ‘/app/package-lock.json’), run(‘cd /app && npm install’, trigger = [path + ‘/package.json’, path + ‘/package-lock.lock’]), run(‘cd /app && npm run build’, trigger = [path […]

Master Tiltfile

k8s_yaml(‘IstioSecurity.yml’) load(‘./services/poc1/Poc1Tiltfile’, ‘poc1’) poc1(‘./services/poc1’) load(‘./services/poc2/Poc2Tiltfile’, ‘poc2’) poc2(‘./services/poc2’) k8s_yaml(‘IstioGateway.yml’)

A simple base Tiltfile for deploying a simple web app into a local kubernetes cluster

load(‘ext://restart_process’, ‘docker_build_with_restart’) def poc2(path = ‘.’): docker_build_with_restart(‘zerotrustpoc/poc2’, path, build_args = { ‘node_env’: ‘development’ }, entrypoint = ‘node dist/main.js’, live_update = [ sync(path + ‘/src’, ‘/app/src’), sync(path + ‘/package.json’, ‘/app/package.json’), sync(path + ‘/package-lock.json’, ‘/app/package-lock.json’), run(‘cd /app && npm install’, trigger = [path + ‘/package.json’, path + ‘./package-lock.lock’]), run(‘cd /app && npm run build’, trigger = [path […]