Sha256: 59513750abe040ae08c7e871cc4139390cb42bd630f3e0a1b5536a2d8622109a

Contents?: true

Size: 459 Bytes

Versions: 1

Compression:

Stored size: 459 Bytes

Contents

require 'metaractor'
require 'consul_stockpile/logger'

module ConsulStockpile
  class LoadJsonKV
    include Metaractor

    optional :json

    def call
      Logger.info 'Loading json backup into consul kv store'

      return if json.nil?
      ary = JSON.parse(json)
      return if ary.empty?

      ary.each do |item|
        Diplomat::Kv.put(item['key'], item['value'])
      end
    end

    private
    def json
      context.json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
consul_stockpile-0.1.5 lib/consul_stockpile/load_json_kv.rb