Sha256: 5373d050ec1eb8d2d076cc120ab005af6f0a8466e9e0b4acd01ea71572ec63fa

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require "yaml"

module Capistrano
  module SecretsYml
    module Helpers

      def local_secrets_yml(env)
        @local_secrets_yml ||= YAML.load_file(secrets_yml_local_path)
        @local_secrets_yml[env]
      end

      def secrets_yml_env
        fetch(:secrets_yml_env).to_s
      end

      def secrets_yml_content
        { secrets_yml_env => local_secrets_yml(secrets_yml_env) }.to_yaml
      end

      # error helpers

      def check_git_tracking_error
        puts
        puts "Error - please remove '#{fetch(:secrets_yml_local_path)}' from git:"
        puts
        puts "    $ git rm --cached #{fetch(:secrets_yml_local_path)}"
        puts
        puts "and gitignore it:"
        puts
        puts "    $ echo '#{fetch(:secrets_yml_local_path)}' >> .gitignore"
        puts
      end

      def check_config_present_error
        puts
        puts "Error - '#{secrets_yml_env}' config not present in '#{fetch(:secrets_yml_local_path)}'."
        puts "Please populate it."
        puts
      end

      def check_secrets_file_exists_error
        puts
        puts "Error - '#{fetch(:secrets_yml_local_path)}' file does not exists, and it's required."
        puts
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
capistrano-secrets-yml-1.2.1 lib/capistrano/secrets_yml/helpers.rb
capistrano-secrets-yml-1.1.1 lib/capistrano/secrets_yml/helpers.rb
capistrano-secrets-yml-1.1.0 lib/capistrano/secrets_yml/helpers.rb
capistrano-secrets-yml-1.0.0 lib/capistrano/secrets_yml/helpers.rb