Sha256: 31eec939b54988c631e763d202b81e6673be1d8fadeef6b863beff12a30e7e67

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 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

1 entries across 1 versions & 1 rubygems

Version Path
chamber-2.9.0 lib/chamber/commands/securable.rb