dpl-atlas 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/dpl-atlas.gemspec +3 -0
- data/lib/dpl/provider/atlas.rb +108 -0
- data/spec/provider/atlas_spec.rb +99 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 042c04dce8703f61343ff668967458b8e0cbdb65
|
4
|
+
data.tar.gz: 375531f986ddc6d3ea4c020b77533819c756fbc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1051fa98a7854189d572dc4b3c0f9b91cd22fadcbba00e460bc3222a214ab984199a820e0a2feafeda4dac5044e883b9ec85fe89a24dd4cc57f31a136c05fa5f
|
7
|
+
data.tar.gz: 205776aebabfb0156e8d87dadf3a348809d6572f602d0827e5360621686f2dbc96ae6513a08bd676341088507ba9b575d6b50a0dfb2d83c6cfb40bcdfd1fc302
|
data/dpl-atlas.gemspec
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
module DPL
|
2
|
+
class Provider
|
3
|
+
class Atlas < Provider
|
4
|
+
GIMME_URL = 'https://raw.githubusercontent.com/meatballhat/gimme/master/gimme'
|
5
|
+
ATLAS_UPLOAD_CLI_GO_REMOTE = 'github.com/hashicorp/atlas-upload-cli'
|
6
|
+
ATLAS_UPLOAD_BOOL_ARGS = %w(vcs debug).map(&:to_sym).freeze
|
7
|
+
ATLAS_UPLOAD_KV_ARGS = %w(address).map(&:to_sym).freeze
|
8
|
+
ATLAS_UPLOAD_KV_MULTI_ARGS = %w(exclude include metadata).map(&:to_sym).freeze
|
9
|
+
ATLAS_UPLOAD_INSTALL_SCRIPT = <<-EOF.gsub(/^ {8}/, '').strip
|
10
|
+
if ! command -v atlas-upload &>/dev/null ; then
|
11
|
+
mkdir -p $HOME/bin $HOME/gopath/src
|
12
|
+
export PATH="$HOME/bin:$PATH"
|
13
|
+
|
14
|
+
if ! command -v gimme &>/dev/null ; then
|
15
|
+
curl -sL -o $HOME/bin/gimme #{GIMME_URL}
|
16
|
+
chmod +x $HOME/bin/gimme
|
17
|
+
fi
|
18
|
+
|
19
|
+
if [ -z $GOPATH ]; then
|
20
|
+
export GOPATH="$HOME/gopath"
|
21
|
+
else
|
22
|
+
export GOPATH="$HOME/gopath:$GOPATH"
|
23
|
+
fi
|
24
|
+
eval "$(gimme 1.6)" &> /dev/null
|
25
|
+
|
26
|
+
go get #{ATLAS_UPLOAD_CLI_GO_REMOTE}
|
27
|
+
cp $HOME/gopath/bin/atlas-upload-cli $HOME/bin/atlas-upload
|
28
|
+
fi
|
29
|
+
EOF
|
30
|
+
|
31
|
+
experimental 'Atlas'
|
32
|
+
|
33
|
+
def deploy
|
34
|
+
assert_app_present!
|
35
|
+
install_atlas_upload
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_auth
|
40
|
+
ENV['ATLAS_TOKEN'] = options[:token] if options[:token]
|
41
|
+
error 'Missing ATLAS_TOKEN' unless ENV['ATLAS_TOKEN']
|
42
|
+
end
|
43
|
+
|
44
|
+
def needs_key?
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def push_app
|
49
|
+
unless options[:paths]
|
50
|
+
here = Dir.pwd
|
51
|
+
warn "No paths specified. Using #{here.inspect}."
|
52
|
+
options[:paths] = here
|
53
|
+
end
|
54
|
+
|
55
|
+
Array(options[:paths]).each do |path|
|
56
|
+
context.shell "atlas-upload #{atlas_upload_args} #{atlas_app} #{path}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def install_atlas_upload
|
63
|
+
without_git_http_user_agent do
|
64
|
+
context.shell ATLAS_UPLOAD_INSTALL_SCRIPT
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def assert_app_present!
|
69
|
+
error 'Missing Atlas app name' unless options.key?(:app)
|
70
|
+
end
|
71
|
+
|
72
|
+
def atlas_upload_args
|
73
|
+
return options[:args] if options.key?(:args)
|
74
|
+
return @atlas_upload_args if @atlas_upload_args
|
75
|
+
|
76
|
+
args = []
|
77
|
+
|
78
|
+
ATLAS_UPLOAD_BOOL_ARGS.each do |arg|
|
79
|
+
args << "-#{arg}" if options.key?(arg)
|
80
|
+
end
|
81
|
+
|
82
|
+
ATLAS_UPLOAD_KV_ARGS.each do |arg|
|
83
|
+
args << ["-#{arg}", options[arg].inspect].join('=') if options.key?(arg)
|
84
|
+
end
|
85
|
+
|
86
|
+
ATLAS_UPLOAD_KV_MULTI_ARGS.each do |arg|
|
87
|
+
next unless options.key?(arg)
|
88
|
+
Array(options[arg]).each do |arg_entry|
|
89
|
+
args << ["-#{arg}", arg_entry.inspect].join('=')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
@atlas_upload_args = args.join(' ')
|
94
|
+
end
|
95
|
+
|
96
|
+
def atlas_app
|
97
|
+
@atlas_app ||= options.fetch(:app).to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
def without_git_http_user_agent(&block)
|
101
|
+
git_http_user_agent = ENV.delete("GIT_HTTP_USER_AGENT")
|
102
|
+
yield
|
103
|
+
ENV["GIT_HTTP_USER_AGENT"] = git_http_user_agent
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'dpl/provider/atlas'
|
5
|
+
|
6
|
+
describe DPL::Provider::Atlas do
|
7
|
+
before :all do
|
8
|
+
@origwd = Dir.pwd
|
9
|
+
@tmpdir = Dir.mktmpdir
|
10
|
+
@home = ENV['HOME']
|
11
|
+
ENV['HOME'] = @tmpdir
|
12
|
+
Dir.chdir(@tmpdir)
|
13
|
+
end
|
14
|
+
|
15
|
+
after :all do
|
16
|
+
FileUtils.rm_rf(@tmpdir) if @tmpdir
|
17
|
+
Dir.chdir(@origwd) if @origwd
|
18
|
+
ENV['HOME'] = @home
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:context) { DummyContext.new }
|
22
|
+
let(:options) { { token: SecureRandom.hex(16), include: 'bin/*', exclude: 'tmp/*' } }
|
23
|
+
|
24
|
+
subject(:provider) { described_class.new(context, options) }
|
25
|
+
|
26
|
+
describe '#check_auth' do
|
27
|
+
specify 'without ATLAS_TOKEN' do
|
28
|
+
provider.options.delete(:token)
|
29
|
+
expect { provider.check_auth }.to raise_error(DPL::Error)
|
30
|
+
end
|
31
|
+
|
32
|
+
specify 'with ATLAS_TOKEN' do
|
33
|
+
provider.options.update(token: SecureRandom.hex(16))
|
34
|
+
expect { provider.check_auth }.to_not raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#needs_key?' do
|
39
|
+
it { expect(provider.needs_key?).to eq(false) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#deploy' do
|
43
|
+
specify 'without :app aborts' do
|
44
|
+
provider.options.delete(:app)
|
45
|
+
expect { provider.deploy }.to raise_error(DPL::Error)
|
46
|
+
end
|
47
|
+
|
48
|
+
specify 'with :app does not abort' do
|
49
|
+
provider.options.update(app: 'dpl/testapp')
|
50
|
+
expect { provider.deploy }.to_not raise_error
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'building atlas-upload args' do
|
55
|
+
context 'when full args are provided' do
|
56
|
+
let(:options) { { args: '-whatever' } }
|
57
|
+
|
58
|
+
it 'returns full args directly' do
|
59
|
+
expect(provider.send(:atlas_upload_args)).to eql('-whatever')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when no arg keys are provided' do
|
64
|
+
let(:options) { {} }
|
65
|
+
|
66
|
+
it 'returns empty args' do
|
67
|
+
expect(provider.send(:atlas_upload_args)).to eql('')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
[
|
72
|
+
{
|
73
|
+
options: { wat: true, debug: true },
|
74
|
+
args: '-debug'
|
75
|
+
},
|
76
|
+
{
|
77
|
+
options: { vcs: nil },
|
78
|
+
args: '-vcs'
|
79
|
+
},
|
80
|
+
{
|
81
|
+
options: { include: ['build/*', 'bin/*'], exclude: '*.log' },
|
82
|
+
args: '-exclude="*.log" -include="build/*" -include="bin/*"'
|
83
|
+
},
|
84
|
+
{
|
85
|
+
options: {
|
86
|
+
include: 'bin/*',
|
87
|
+
exclude: ['*.log', '*.out'],
|
88
|
+
metadata: ['foo=bar', 'whatever=else']
|
89
|
+
},
|
90
|
+
args: '-exclude="*.log" -exclude="*.out" -include="bin/*" -metadata="foo=bar" -metadata="whatever=else"'
|
91
|
+
}
|
92
|
+
].each_with_index do |example, i|
|
93
|
+
context "with options #{example[:options].inspect}" do
|
94
|
+
let(:options) { example[:options] }
|
95
|
+
it { expect(provider.send(:atlas_upload_args)).to eql(example[:args]) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dpl-atlas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Haase
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dpl
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-its
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json_pure
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tins
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: highline
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: deploy tool abstraction for clients
|
126
|
+
email: konstantin.mailinglists@googlemail.com
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
131
|
+
- dpl-atlas.gemspec
|
132
|
+
- lib/dpl/provider/atlas.rb
|
133
|
+
- spec/provider/atlas_spec.rb
|
134
|
+
homepage: https://github.com/travis-ci/dpl
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.2'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.6.13
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: deploy tool
|
158
|
+
test_files:
|
159
|
+
- spec/provider/atlas_spec.rb
|