Sha256: 48f5f053055d6bcfd34a025e9b9de14c659d1c071a25e322055099d493ccc0c0

Contents?: true

Size: 730 Bytes

Versions: 54

Compression:

Stored size: 730 Bytes

Contents

# frozen_string_literal: true

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

      def name
        'env_var'
      end

      def hooks
        %i[resolve_reference validate_resolve_reference]
      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

54 entries across 54 versions & 1 rubygems

Version Path
bolt-3.9.2 lib/bolt/plugin/env_var.rb
bolt-3.9.1 lib/bolt/plugin/env_var.rb
bolt-3.9.0 lib/bolt/plugin/env_var.rb
bolt-3.8.1 lib/bolt/plugin/env_var.rb
bolt-3.8.0 lib/bolt/plugin/env_var.rb
bolt-3.7.1 lib/bolt/plugin/env_var.rb
bolt-3.7.0 lib/bolt/plugin/env_var.rb
bolt-3.6.1 lib/bolt/plugin/env_var.rb
bolt-3.6.0 lib/bolt/plugin/env_var.rb
bolt-3.5.0 lib/bolt/plugin/env_var.rb
bolt-3.4.0 lib/bolt/plugin/env_var.rb
bolt-3.3.0 lib/bolt/plugin/env_var.rb
bolt-3.1.0 lib/bolt/plugin/env_var.rb
bolt-3.0.1 lib/bolt/plugin/env_var.rb
bolt-3.0.0 lib/bolt/plugin/env_var.rb
bolt-2.44.0 lib/bolt/plugin/env_var.rb
bolt-2.42.0 lib/bolt/plugin/env_var.rb
bolt-2.40.2 lib/bolt/plugin/env_var.rb
bolt-2.40.1 lib/bolt/plugin/env_var.rb
bolt-2.38.0 lib/bolt/plugin/env_var.rb