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 =
"  if ! command -v atlas-upload &>/dev/null ; then\n    mkdir -p $HOME/bin $HOME/gopath/src\n    export PATH=\"$HOME/bin:$PATH\"\n\n    if ! command -v gimme &>/dev/null ; then\n      curl -sL -o $HOME/bin/gimme \#{GIMME_URL}\n      chmod +x $HOME/bin/gimme\n    fi\n\n    if [ -z $GOPATH ]; then\n      export GOPATH=\"$HOME/gopath\"\n    else\n      export GOPATH=\"$HOME/gopath:$GOPATH\"\n    fi\n    eval \"$(gimme 1.6)\" &> /dev/null\n\n    go get \#{ATLAS_UPLOAD_CLI_GO_REMOTE}\n    cp $HOME/gopath/bin/atlas-upload-cli $HOME/bin/atlas-upload\n  fi\n".gsub(/^ {8}/, '').strip

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, #default_text_charset, #default_text_charset?, #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



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

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

#deployObject



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

def deploy
  assert_app_present!
  install_atlas_upload
  super
end

#needs_key?Boolean



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

def needs_key?
  false
end

#push_appObject



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

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