Class: DPL::Provider::Atlas

Inherits:
DPL::Provider show all
Defined in:
lib/dpl/provider/atlas.rb

Constant Summary collapse

GIMME_URL =
'https://raw.githubusercontent.com/meatballhat/gimme/master/gimme'
ATLAS_UPLOAD_CLI_GO_REMOTE =
'github.com/hashicorp/atlas-upload-cli'
ATLAS_UPLOAD_BOOL_ARGS =
%w(vcs debug).map(&:to_sym).freeze
ATLAS_UPLOAD_KV_ARGS =
%w(address).map(&:to_sym).freeze
ATLAS_UPLOAD_KV_MULTI_ARGS =
%w(exclude include metadata).map(&:to_sym).freeze
ATLAS_UPLOAD_INSTALL_SCRIPT =
<<-EOF.gsub(/^ {8}/, '').strip
  if ! command -v atlas-upload &>/dev/null ; then
    mkdir -p $HOME/bin $HOME/gopath/src
    export PATH="$HOME/bin:$PATH"

    if ! command -v gimme &>/dev/null ; then
      curl -sL -o $HOME/bin/gimme #{GIMME_URL}
      chmod +x $HOME/bin/gimme
    fi

    export GOPATH="$HOME/gopath:$GOPATH"
    eval "$(gimme 1.4.2)" &>/dev/null

    go get #{ATLAS_UPLOAD_CLI_GO_REMOTE}
    pushd $HOME/gopath/src/#{ATLAS_UPLOAD_CLI_GO_REMOTE} &>/dev/null
    make &>/dev/null
    cp bin/atlas-upload $HOME/bin/atlas-upload
    popd &>/dev/null
  fi
EOF

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from DPL::Provider

apt_get, #check_app, #cleanup, #commit_msg, context, #create_key, #detect_encoding?, #encoding_for, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn

Constructor Details

This class inherits a constructor from DPL::Provider

Instance Method Details

#check_authObject



38
39
40
41
# File 'lib/dpl/provider/atlas.rb', line 38

def check_auth
  ENV['ATLAS_TOKEN'] = options[:token] if options[:token]
  error 'Missing ATLAS_TOKEN' unless ENV['ATLAS_TOKEN']
end

#deployObject



32
33
34
35
36
# File 'lib/dpl/provider/atlas.rb', line 32

def deploy
  assert_app_present!
  install_atlas_upload
  super
end

#needs_key?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/dpl/provider/atlas.rb', line 43

def needs_key?
  false
end

#push_appObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dpl/provider/atlas.rb', line 47

def push_app
  unless options[:paths]
    here = Dir.pwd
    warn "No paths specified.  Using #{here.inspect}."
    options[:paths] = here
  end

  Array(options[:paths]).each do |path|
    context.shell "atlas-upload #{atlas_upload_args} #{atlas_app} #{path}"
  end
end