Sha256: 8c81e5621c83fa618f4c0dc975a01a1c358f9b5d8b250f08f04c66eb3ab17345

Contents?: true

Size: 1.55 KB

Versions: 337

Compression:

Stored size: 1.55 KB

Contents

require_relative 'encryption/interface'
require_relative 'encryption/openssl'

module Match
  module Encryption
    class << self
      def backends
        @backends ||= {
          "git" => lambda { |params|
            # OpenSSL is storage agnostic so this maps git_url
            # to keychain_name for the name of the keychain entry
            params[:keychain_name] = params[:git_url]
            return Encryption::OpenSSL.configure(params)
          },
          "google_cloud" => lambda { |params|
            return nil
          }
        }
      end

      def register_backend(type: nil, encryption_class: nil, &configurator)
        UI.user_error!("No type specified for encryption backend") if type.nil?

        normalized_name = type.to_s
        UI.message("Replacing Match::Encryption backend for type '#{normalized_name}'") if backends.include?(normalized_name)

        if configurator
          @backends[normalized_name] = configurator
        elsif encryption_class
          @backends[normalized_name] = ->(params) { return encryption_class.configure(params) }
        else
          UI.user_error!("Specify either a `encryption_class` or a configuration block when registering a encryption backend")
        end
      end

      # Returns the class to be used for a given `storage_mode`
      def for_storage_mode(storage_mode, params)
        configurator = backends[storage_mode.to_s]
        return configurator.call(params) if configurator

        UI.user_error!("No encryption backend for storage mode '#{storage_mode}'")
      end
    end
  end
end

Version data entries

337 entries across 337 versions & 2 rubygems

Version Path
fastlane-2.130.0.beta.20190816200015 match/lib/match/encryption.rb
fastlane-2.130.0.beta.20190815200057 match/lib/match/encryption.rb
fastlane-2.130.0.beta.20190814200010 match/lib/match/encryption.rb
fastlane-2.129.0 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190813200016 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190811200106 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190810200059 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190809200051 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190808200013 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190807200122 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190806200055 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190805200019 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190804200053 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190803200103 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190802200057 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190731200035 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190730200040 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190729200106 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190728200052 match/lib/match/encryption.rb
fastlane-2.129.0.beta.20190727200032 match/lib/match/encryption.rb