Class: Bim::Subcommands::Ssl

Inherits:
Thor
  • Object
show all
Defined in:
lib/bim/subcommands/ssl.rb

Overview

Ssl class defines subcommands

Instance Method Summary collapse

Instance Method Details

#bundlesObject



9
10
11
# File 'lib/bim/subcommands/ssl.rb', line 9

def bundles
  puts Bim::Action::SSL.bundles
end

#create_ssl_profile(profilename, chain) ⇒ Object



66
67
68
# File 'lib/bim/subcommands/ssl.rb', line 66

def create_ssl_profile(profilename, chain)
  puts Bim::Action::SSL.create_ssl_profile(profilename, chain)
end

#deploy(old_ssl_profilename, new_ssl_profilename, key_file, crt_file, chain) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/bim/subcommands/ssl.rb', line 89

def deploy(old_ssl_profilename, new_ssl_profilename, key_file, crt_file, chain)
  if options[:test] && !ENV['TEST_VS']
    puts 'You have to set TEST_VS environment variable.'
    return
  end

  log('start deploy')
  log('start upload private key and certificate')
  upload(new_ssl_profilename, key_file, crt_file)
  log('finish upload private key and certificate')
  log('start create ssl profile')
  create_ssl_profile(new_ssl_profilename, chain)
  log('finish create ssl profile')
  log('start replace ssl profile')
  replace(old_ssl_profilename, new_ssl_profilename)
  log('finish replace ssl profile')
  log('finish deploy')
end

#detail(profile_name) ⇒ Object



25
26
27
# File 'lib/bim/subcommands/ssl.rb', line 25

def detail(profile_name)
  puts Bim::Action::SSL.detail(profile_name)
end

#profilesObject



17
18
19
# File 'lib/bim/subcommands/ssl.rb', line 17

def profiles
  puts Bim::Action::SSL.profiles
end

#replace(old_ssl_profilename, new_ssl_profilename) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/bim/subcommands/ssl.rb', line 75

def replace(old_ssl_profilename, new_ssl_profilename)
  if options[:test] && !ENV['TEST_VS']
    puts 'You have to set TEST_VS environment variable.'
    return
  end

  puts Bim::Action::SSL.replace(old_ssl_profilename, new_ssl_profilename, options[:test])
end

#upload(crt_name, key_file, crt_file) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/bim/subcommands/ssl.rb', line 51

def upload(crt_name, key_file, crt_file)
  result = []
  r = Bim::Action::SSL.upload(key_file)
  result.push Bim::Action::SSL.install(:key, crt_name, JSON.parse(r)['localFilePath'])

  r = Bim::Action::SSL.upload(crt_file)
  result.push Bim::Action::SSL.install(:crt, crt_name, JSON.parse(r)['localFilePath'])

  puts result.map { |res| JSON.parse(res) }.to_json
end

#upload_crt(crt_name, crt_file) ⇒ Object



42
43
44
45
# File 'lib/bim/subcommands/ssl.rb', line 42

def upload_crt(crt_name, crt_file)
  r = Bim::Action::SSL.upload(crt_file)
  puts Bim::Action::SSL.install(:crt, crt_name, JSON.parse(r)['localFilePath'])
end

#upload_key(crt_name, key_file) ⇒ Object



33
34
35
36
# File 'lib/bim/subcommands/ssl.rb', line 33

def upload_key(crt_name, key_file)
  r = Bim::Action::SSL.upload(key_file)
  puts Bim::Action::SSL.install(:key, crt_name, JSON.parse(r)['localFilePath'])
end