Sha256: ae9a02e776c3bd424addd60fe971bfc47f0c18f79d6cbb0bed4cabd3406ef7e5

Contents?: true

Size: 882 Bytes

Versions: 13

Compression:

Stored size: 882 Bytes

Contents

# frozen_string_literal: true

module Bolt
  class Plugin
    class EnvVar
      def initialize(*_args); end

      def name
        'env_var'
      end

      def hooks
        hook_descriptions.keys
      end

      def hook_descriptions
        {
          resolve_reference: 'Read values stored in environment variables.',
          validate_resolve_reference: nil
        }
      end

      def validate_resolve_reference(opts)
        unless opts['var']
          raise Bolt::ValidationError, "env_var plugin requires that the 'var' is specified"
        end
        return if opts['optional'] || opts['default']
        unless ENV[opts['var']]
          raise Bolt::ValidationError, "env_var plugin requires that the var '#{opts['var']}' be set"
        end
      end

      def resolve_reference(opts)
        ENV[opts['var']] || opts['default']
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bolt-3.21.0 lib/bolt/plugin/env_var.rb
bolt-3.20.0 lib/bolt/plugin/env_var.rb
bolt-3.19.0 lib/bolt/plugin/env_var.rb
bolt-3.18.0 lib/bolt/plugin/env_var.rb
bolt-3.17.0 lib/bolt/plugin/env_var.rb
bolt-3.16.1 lib/bolt/plugin/env_var.rb
bolt-3.16.0 lib/bolt/plugin/env_var.rb
bolt-3.15.0 lib/bolt/plugin/env_var.rb
bolt-3.14.1 lib/bolt/plugin/env_var.rb
bolt-3.13.0 lib/bolt/plugin/env_var.rb
bolt-3.12.0 lib/bolt/plugin/env_var.rb
bolt-3.11.0 lib/bolt/plugin/env_var.rb
bolt-3.10.0 lib/bolt/plugin/env_var.rb