Class: Envirobly::Cli::Main
Instance Method Summary collapse
- #deploy(environ_name = Envirobly::Git.new.current_branch) ⇒ Object
- #measure ⇒ Object
- #object_tree ⇒ Object
- #pull(region, bucket, ref, path) ⇒ Object
- #push(region, bucket, ref = "HEAD") ⇒ Object
- #set_access_token ⇒ Object
- #validate ⇒ Object
- #version ⇒ Object
Methods inherited from Base
Instance Method Details
#deploy(environ_name = Envirobly::Git.new.current_branch) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/envirobly/cli/main.rb', line 45 def deploy(environ_name = Envirobly::Git.new.current_branch) deployment = Envirobly::Deployment.new( environ_name:, commit_ref: .commit, account_id: .account_id, project_name: .project_name, project_region: .project_region ) deployment.perform(dry_run: .dry_run) end |
#measure ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/envirobly/cli/main.rb', line 94 def measure Envirobly::Duration.measure do print "Doing something for 2s" sleep 2 end Envirobly::Duration.measure do print "Doing something else for 100ms" sleep 0.1 end Envirobly::Duration.measure("Custom message, took %s") do puts "Sleeping 2.5s with custom message" sleep 2.5 end puts "Done." end |
#object_tree ⇒ Object
86 87 88 89 90 91 |
# File 'lib/envirobly/cli/main.rb', line 86 def object_tree commit = Envirobly::Git::Commit.new .commit puts "Commit: #{commit.ref}" pp commit.object_tree puts "SHA256: #{commit.object_tree_checksum}" end |
#pull(region, bucket, ref, path) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/envirobly/cli/main.rb', line 77 def pull(region, bucket, ref, path) Envirobly::Duration.measure("Build context download took %s") do s3 = Envirobly::Aws::S3.new(region:, bucket:) s3.pull ref, path end end |
#push(region, bucket, ref = "HEAD") ⇒ Object
70 71 72 73 74 |
# File 'lib/envirobly/cli/main.rb', line 70 def push(region, bucket, ref = "HEAD") commit = Envirobly::Git::Commit.new ref s3 = Envirobly::Aws::S3.new(region:, bucket:) s3.push commit end |
#set_access_token ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/envirobly/cli/main.rb', line 57 def set_access_token token = ask("Access Token:", echo: false).strip if token.blank? $stderr.puts $stderr.puts "Token can't be empty." exit 1 end Envirobly::AccessToken.new(token).save end |
#validate ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/envirobly/cli/main.rb', line 13 def validate configs = Envirobly::Configs.new api = Envirobly::Api.new params = { validation: configs.to_params } response = api.validate_shape params if response.object.fetch("valid") puts "All checks pass." else response.object.fetch("errors").each do |config_path, | puts "#{config_path}:" puts .each_with_index do |, index| puts " #{}" puts end end exit 1 end end |