Sha256: 9d2772714b6b3c10474e17d8423bc27bbade28f90eb5dbef3ae3f48af8947cf9

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true
require 'shellwords'
require 'chamber/instance'

module  Chamber
module  Commands
module  Securable
  def initialize(options = {})
    super

    ignored_settings_options        = options.
                                      merge(files: ignored_settings_filepaths).
                                      reject { |k, _v| k == 'basepath' }
    self.ignored_settings_instance  = Chamber::Instance.new(ignored_settings_options)
    self.current_settings_instance  = Chamber::Instance.new(options)
    self.only_sensitive             = options[:only_sensitive]
  end

  protected

  attr_accessor :only_sensitive,
                :ignored_settings_instance,
                :current_settings_instance

  def securable_environment_variables
    if only_sensitive
      securable_settings.to_environment
    else
      current_settings.to_environment
    end
  end

  def insecure_environment_variables
    securable_settings.insecure.to_environment
  end

  def securable_settings
    ignored_settings.merge(current_settings.securable)
  end

  def current_settings
    current_settings_instance.settings
  end

  def ignored_settings
    ignored_settings_instance.settings
  end

  def ignored_settings_filepaths
    shell_escaped_chamber_filenames = chamber.filenames.map do |filename|
      Shellwords.escape(filename)
    end

    `
      git ls-files --other --ignored --exclude-from=.gitignore |
      sed -e "s|^|#{Shellwords.escape(rootpath.to_s)}/|" |
      grep --colour=never -E '#{shell_escaped_chamber_filenames.join('|')}'
    `.split("\n")
  end
end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chamber-2.10.2 lib/chamber/commands/securable.rb
chamber-2.10.1 lib/chamber/commands/securable.rb
chamber-2.10.0 lib/chamber/commands/securable.rb
chamber-2.9.1 lib/chamber/commands/securable.rb