Sha256: 871eb5e73cdd97b80db485bf537e6a4a664dc7587635b0ad3c9536b8e26bd91c

Contents?: true

Size: 1.5 KB

Versions: 3

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 being 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

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-orchestrate-0.7.0.pre.5 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.7.0.pre.3 lib/vagrant-managed-servers/action/track_deployment_start.rb
vagrant-orchestrate-0.7.0.pre.2 lib/vagrant-managed-servers/action/track_deployment_start.rb