Sha256: 80ab6c081e7cafcd469c265664647a59f8da11234f6b524cda8c59af0ed0a412

Contents?: true

Size: 1.5 KB

Versions: 7

Compression:

Stored size: 1.5 KB

Contents

require "log4r"
require "vagrant-orchestrate/version"

module VagrantPlugins
  module ManagedServers
    module Action
      class TrackDeploymentStart
        def initialize(app, _env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_managed_servers::action::track_deployment_start")
        end

        def call(env)
          track_deployment_start(env[:tracker_host], env[:status], env[:ui], env[:args])
          @app.call(env)
        end

        def track_deployment_start(host, status, ui, args)
          return unless host
          id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
          ui.info("Deployment tracked in deployment-tracker with ID: #{id}")
          @logger.debug("Tracking deployment start to #{host}.")
          hostname = `hostname`.chomp
          deployment = {
            deployment_id: id,
            engine: "vagrant_orchestrate",
            engine_version: VagrantPlugins::Orchestrate::VERSION,
            user: status.user, host: hostname,
            environment: status.branch,
            package: status.repo,
            package_url: status.remote_origin_url,
            version: status.ref, arguments: args
          }
          DeploymentTrackerClient::DefaultApi.post_deployment(id, deployment)
        rescue => ex
          ui.warn("There was an error notifying deployment tracker. See error log for details.")
          @logger.warn("Error tracking deployment start for deployment #{id}")
          @logger.warn(ex)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-orchestrate-0.8.0 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.8.0.pre.3 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.8.0.pre.2 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.8.0.pre.1 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.7.2 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.7.1 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.7.0 lib/vagrant-managed-servers/action/track_deployment_start.rb