Sha256: 14392f2d7249238af513012b3ea26fda93a916ab569ba72ab045b5baaf9f3eff

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module UmbrellioUtils
  module Vault
    extend self

    def secret_engine_present?(engine_path)
      ::Vault.logical.read("sys/mounts").data.key?(:"#{engine_path}/")
    end

    def create_kv_engine(path)
      ::Vault.logical.write(
        "sys/mounts/#{path}",
        config: {},
        generate_signing_key: true,
        options: { version: 2 },
        path: path.to_s,
        type: "kv",
      )
    end

    def write_to_kv(engine_path:, secret_path:, data:)
      full_data_path = File.join(engine_path, "data", secret_path)
      full_meta_path = File.join(engine_path, "metadata", secret_path)
      ::Vault.logical.write(full_data_path, data: data)
      ::Vault.logical.write(full_meta_path, id: secret_path, max_versions: 1, cas_required: false)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
umbrellio-utils-1.4.0 lib/umbrellio_utils/vault.rb
umbrellio-utils-1.3.0 lib/umbrellio_utils/vault.rb