Class: Kontena::Cli::Stacks::YAML::Opto::Resolvers::Certificates
- Inherits:
-
Opto::Resolver
- Object
- Opto::Resolver
- Kontena::Cli::Stacks::YAML::Opto::Resolvers::Certificates
- Includes:
- Common
- Defined in:
- lib/kontena/cli/stacks/yaml/opto/certificates_resolver.rb
Instance Method Summary collapse
- #default_indexes(certificates) ⇒ Array<Integer>
-
#get_certificates ⇒ Array<Hash>
Certificates.
- #resolve ⇒ Object
Methods included from Common
#access_token=, #add_master, #any_key_to_continue, #any_key_to_continue_with_timeout, #api_url, #api_url=, #caret, #clear_current_grid, #client, #cloud_auth?, #cloud_client, #config, #confirm, #confirm_command, #current_grid, #current_master_index, #debug?, #display_account_login_info, #display_login_info, display_logo, #display_master_login_info, #error, exit_with_error, #kontena_account, #logger, #pastel, #print, #prompt, #puts, #require_api_url, #require_token, #reset_client, #reset_cloud_client, #running_quiet?, #running_silent?, #running_verbose?, #spin_if, #spinner, #sprint, #sputs, #stdin_input, #use_refresh_token, #vfakespinner, #vputs, #vspinner, #warning
Instance Method Details
#default_indexes(certificates) ⇒ Array<Integer>
28 29 30 31 32 33 34 35 |
# File 'lib/kontena/cli/stacks/yaml/opto/certificates_resolver.rb', line 28 def default_indexes(certificates) indexes = [] option.default.to_a.each do |subject| index = certificates.index { |s| s['subject'] == subject } indexes << index.to_i + 1 if index end indexes end |
#get_certificates ⇒ Array<Hash>
Returns certificates.
20 21 22 23 24 |
# File 'lib/kontena/cli/stacks/yaml/opto/certificates_resolver.rb', line 20 def get_certificates client.get("grids/#{current_grid}/certificates")['certificates'] rescue [] end |
#resolve ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kontena/cli/stacks/yaml/opto/certificates_resolver.rb', line 5 def resolve return nil unless current_master && current_grid = hint || 'Select SSL certificates' certificates = get_certificates if certificates.size > 0 prompt.multi_select() do || .default(*default_indexes(certificates)) if option.default certificates.each do |s| .choice s['subject'] end end end end |