Repository navigation
Expand file tree
/
Copy pathaccess-qa
More file actions
executable file
·70 lines (56 loc) · 1.86 KB
/
Copy pathaccess-qa
File metadata and controls
executable file
·70 lines (56 loc) · 1.86 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env ruby
# frozen_string_literal: true
require "clipboard"
require "colorize"
require "optimist"
$:.unshift(File.expand_path("~/bin/lib"))
require "dbrady_cli"
String.disable_colorization unless $stdout.tty?
class Application
include DbradyCli
opt_flag :aws
opt_reader :image
def image?
opts[:image_given]
end
def run
@opts = Optimist.options do
banner <<BANNER
access-qa [-i <image-tag>] [--no-aws]
access-qa --no-aws -i dbrady-MPI-312-install-coverband-67c5e86
Options:
BANNER
opt :aws, "Automatically check aws sso login", short: :a, default: true
opt :debug, "Print extra debug info", short: :d, default: false
opt :image, "Image tag to use", short: :i, type: :string
opt :pretend, "Print commands but do not run them", short: :p, default: false
opt :quiet, "Run with minimal output", short: :q, default: false
opt :verbose, "Run with verbose output (overrides --quiet)", short: :v, default: false
end
opts[:quiet] = !opts[:verbose] if opts[:verbose_given]
dump_opts if debug?
# if you invoke access-qa <image>, you probably meant access-qa -i <image>
Optimist.educate unless ARGV.empty?
run!
end
def run!
if aws? && !run_command("aws-check-sso-login")
run_command "aws sso login --profile AcimaNonprod-NonProdDeveloperAccess"
end
env = {
"AWS_PROFILE" => "AcimaNonprod-NonProdDeveloperAccess"
}
env_str = env.map { |k, v| "#{k}=#{v}" }.join " "
run_command "kubectl config use-context qa", env: env
acimos_command = "acimos run merchant-portal"
acimos_command += " -i #{image.inspect}" if image?
# puts "Putting this in the clipboard. Run this:".yellow
command = "#{env_str} eval $(#{acimos_command})"
# puts command
# Clipboard.copy command
run_command command
end
end
if __FILE__ == $0
Application.new.run
end