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-2.37.0 lib/bolt/plugin/env_var.rb
bolt-2.36.0 lib/bolt/plugin/env_var.rb
bolt-2.35.0 lib/bolt/plugin/env_var.rb
bolt-2.34.0 lib/bolt/plugin/env_var.rb
bolt-2.33.2 lib/bolt/plugin/env_var.rb
bolt-2.33.1 lib/bolt/plugin/env_var.rb
bolt-2.32.0 lib/bolt/plugin/env_var.rb
bolt-2.31.0 lib/bolt/plugin/env_var.rb
bolt-2.30.0 lib/bolt/plugin/env_var.rb
bolt-2.29.0 lib/bolt/plugin/env_var.rb
bolt-2.28.0 lib/bolt/plugin/env_var.rb
bolt-2.27.0 lib/bolt/plugin/env_var.rb
bolt-2.26.0 lib/bolt/plugin/env_var.rb
bolt-2.25.0 lib/bolt/plugin/env_var.rb
bolt-2.24.1 lib/bolt/plugin/env_var.rb
bolt-2.24.0 lib/bolt/plugin/env_var.rb
bolt-2.23.0 lib/bolt/plugin/env_var.rb
bolt-2.22.0 lib/bolt/plugin/env_var.rb
bolt-2.21.0 lib/bolt/plugin/env_var.rb
bolt-2.20.0 lib/bolt/plugin/env_var.rb