Class: KubesAws::Secrets
- Inherits:
-
Object
- Object
- KubesAws::Secrets
- Includes:
- Services
- Defined in:
- lib/kubes_aws/secrets.rb,
lib/kubes_aws/secrets/fetcher.rb
Defined Under Namespace
Classes: Fetcher
Constant Summary collapse
- PAGE_SIZE =
20
Instance Method Summary collapse
- #call ⇒ Object
- #data ⇒ Object
-
#initialize(upcase: false, base64: false, prefix: nil, filters: []) ⇒ Secrets
constructor
A new instance of Secrets.
-
#items ⇒ Object
Returns flattened lazy Enumerator.
Methods included from Services
Constructor Details
#initialize(upcase: false, base64: false, prefix: nil, filters: []) ⇒ Secrets
Returns a new instance of Secrets.
7 8 9 10 |
# File 'lib/kubes_aws/secrets.rb', line 7 def initialize(upcase: false, base64: false, prefix: nil, filters: []) @upcase, @base64, @filters = upcase, base64, filters @prefix = ENV['AWS_SECRET_PREFIX'] || prefix # IE: prefix: demo/dev/ end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kubes_aws/secrets.rb', line 12 def call items.each do |item| next unless item.name.include?(@prefix) if @prefix secret_value = secrets.get_secret_value(secret_id: item.name) value = secret_value.secret_string value = Base64.strict_encode64(value).strip if @base64 key = item.name key = key.sub(@prefix,'') if @prefix key = key.upcase if @upcase self.class.data[key] = value end end |
#data ⇒ Object
49 50 51 |
# File 'lib/kubes_aws/secrets.rb', line 49 def data self.class.data end |
#items ⇒ Object
Returns flattened lazy Enumerator
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kubes_aws/secrets.rb', line 28 def items Enumerator.new do |y| next_token = nil loop do args = {max_results: PAGE_SIZE, sort_order: "asc"} args[:next_token] = next_token if next_token args.merge!(filters: @filters) resp = secrets.list_secrets(args) items = resp.secret_list next_token = resp.next_token y.yield(items, resp) # also provided the original resp always in case it is useful break unless next_token end end.lazy.flat_map { |v| v } end |