Sha256: e36b173ac4dafd42d7ff64ab5f416424dbd27ee8321381f9f250b5e0f4a70c74
Contents?: true
Size: 1.55 KB
Versions: 23
Compression:
Stored size: 1.55 KB
Contents
#!/usr/bin/env ruby $: << (ENV['is_devel'] ? File.expand_path('../../../lib', __FILE__) : '/opt/lib') require 'kite/helpers/concourse' Dir.chdir ARGV[0] params = Kite::Helpers::Concourse.params(STDIN.read) Kite::Helpers::Concourse.fatal '`source` missing' unless params['source'] token = params['source']['token'] # kubectl service account token endpoint = params['source']['endpoint'] cert = params['source']['certificate-authority'] command = params['params']['command'] Kite::Helpers::Concourse.fatal '`command` missing' if command.to_s.empty? path_certificate = '/tmp/ca.crt' path_key = '/tmp/key.json' path_kubeconfig = '/tmp/kubeconfig' cleaner = [/(token)=[^ ]*/, '\1=REDACTED'] env = {} File.write(path_certificate, cert) env['KUBECONFIG'] = path_kubeconfig Kite::Helpers::Concourse.execute("kubectl config set-cluster concourse " \ "--embed-certs=true --server=#{ endpoint } " \ "--certificate-authority=#{ path_certificate }", env) Kite::Helpers::Concourse.execute("kubectl config set-credentials concourse --token='#{ token }'", env, cleaner) Kite::Helpers::Concourse.execute("kubectl config set-context concourse --cluster=concourse --user=concourse", env) Kite::Helpers::Concourse.execute("kubectl config use-context concourse", env) if Kite::Helpers::Concourse.execute(command, env) ::Kite::Helpers::Concourse.respond(version: { status: 'ok' }) else ::Kite::Helpers::Concourse.respond( version: { status: 'error' }, metadata: ["Failed to execute command #{ command }"] ) exit 1 end
Version data entries
23 entries across 23 versions & 1 rubygems
Version | Path |
---|---|
kite-1.0.2 | bin/concourse/out |
kite-1.0.1 | bin/concourse/out |
kite-1.0.0 | bin/concourse/out |