Sha256: df35ed5dc4d82a20940375f1be4d8a7bc6eb0e2dddd51d4a7a58a2e3be1f18db
Contents?: true
Size: 1 KB
Versions: 42
Compression:
Stored size: 1 KB
Contents
module Kontena::Cli::Stacks::YAML::Opto::Resolvers class VaultCertPrompt < ::Opto::Resolver include Kontena::Cli::Common def resolve return nil unless current_master && current_grid message = hint || 'Select SSL certs' secrets = get_secrets.select{ |s| s['name'].match(/(ssl|cert)/i) } if secrets.size > 0 prompt.multi_select(message) do |menu| menu.default(*default_indexes(secrets)) if option.default secrets.each do |s| menu.choice s['name'] end end end end # @return [Array<Hash>] secrets def get_secrets client.get("grids/#{current_grid}/secrets")['secrets'] rescue [] end # @param [Array<Hash>] secrets # @return [Array<Integer>] def default_indexes(secrets) indexes = [] option.default.to_a.each do |name| index = secrets.index { |s| s['name'] == name } indexes << index.to_i + 1 if index end indexes end end end
Version data entries
42 entries across 42 versions & 2 rubygems