Sha256: 9fabdc63cae7b78761a5f965db21f78e6df78f3ca8a65794b577580662d5bd6d

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

module VagrantPlugins
  module LocalExecPush
    class Config < Vagrant.plugin("2", :config)
      # The path (relative to the machine root) to a local script that will be
      # executed.
      # @return [String]
      attr_accessor :script

      # The command (as a string) to execute.
      # @return [String]
      attr_accessor :inline

      def initialize
        @script = UNSET_VALUE
        @inline = UNSET_VALUE
      end

      def finalize!
        @script = nil if @script == UNSET_VALUE
        @inline = nil if @inline == UNSET_VALUE
      end

      def validate(machine)
        errors = _detected_errors

        if missing?(@script) && missing?(@inline)
          errors << I18n.t("local_exec_push.errors.missing_attribute",
            attribute: "script",
          )
        end

        if !missing?(@script) && !missing?(@inline)
          errors << I18n.t("local_exec_push.errors.cannot_specify_script_and_inline")
        end

        { "Local Exec push" => errors }
      end

      private

      # Determine if the given string is "missing" (blank)
      # @return [true, false]
      def missing?(obj)
        obj.to_s.strip.empty?
      end
    end
  end
end

Version data entries

4 entries across 1 versions & 1 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/pushes/local-exec/config.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/pushes/local-exec/config.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/pushes/local-exec/config.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/pushes/local-exec/config.rb