Sha256: 284669a8b3d56c9b4d70acf84bdcdc2948a8f3fde24a588d0b5331d11f300c95

Contents?: true

Size: 1.04 KB

Versions: 59

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'bolt/plugin'

module Bolt
  class Secret
    KNOWN_KEYS = {
      'createkeys' => %w[keysize private_key public_key],
      'encrypt'    => %w[public_key],
      'decrypt'    => %w[private_key public_key]
    }.freeze

    def self.execute(plugins, outputter, options)
      name   = options[:plugin] || 'pkcs7'
      plugin = plugins.by_name(name)

      unless plugin
        raise Bolt::Plugin::PluginError::Unknown, name
      end

      case options[:action]
      when 'createkeys'
        opts = { 'force' => options[:force] }.compact
        result = plugins.get_hook(name, :secret_createkeys).call(opts)
        outputter.print_message(result)
      when 'encrypt'
        encrypted = plugins.get_hook(name, :secret_encrypt).call('plaintext_value' => options[:object])
        outputter.print_message(encrypted)
      when 'decrypt'
        decrypted = plugins.get_hook(name, :secret_decrypt).call('encrypted_value' => options[:object])
        outputter.print_message(decrypted)
      end

      0
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
bolt-3.15.0 lib/bolt/secret.rb
bolt-3.14.1 lib/bolt/secret.rb
bolt-3.13.0 lib/bolt/secret.rb
bolt-3.12.0 lib/bolt/secret.rb
bolt-3.11.0 lib/bolt/secret.rb
bolt-3.10.0 lib/bolt/secret.rb
bolt-3.9.2 lib/bolt/secret.rb
bolt-3.9.1 lib/bolt/secret.rb
bolt-3.9.0 lib/bolt/secret.rb
bolt-3.8.1 lib/bolt/secret.rb
bolt-3.8.0 lib/bolt/secret.rb
bolt-3.7.1 lib/bolt/secret.rb
bolt-3.7.0 lib/bolt/secret.rb
bolt-3.6.1 lib/bolt/secret.rb
bolt-3.6.0 lib/bolt/secret.rb
bolt-3.5.0 lib/bolt/secret.rb
bolt-3.4.0 lib/bolt/secret.rb
bolt-3.3.0 lib/bolt/secret.rb
bolt-3.1.0 lib/bolt/secret.rb
bolt-3.0.1 lib/bolt/secret.rb