dapp 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/dapp.rb +1 -0
- data/lib/dapp/builder.rb +12 -1
- data/lib/dapp/builder/cascade_tagging.rb +2 -2
- data/lib/dapp/builder/centos7.rb +1 -1
- data/lib/dapp/builder/chefify.rb +3 -3
- data/lib/dapp/docker.rb +1 -1
- data/lib/dapp/git_artifact.rb +14 -16
- data/lib/dapp/git_repo/base.rb +10 -7
- data/lib/dapp/git_repo/chronicler.rb +1 -0
- data/lib/dapp/git_repo/own.rb +14 -0
- data/lib/dapp/git_repo/remote.rb +7 -0
- data/lib/dapp/version.rb +1 -1
- metadata +25 -10
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWI0MGM4MWU0MjU2MWUxZWY0NWNkMTczNzEyNzJmMWQ2NDhjMzlkYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDdmMzhiNTE1ZTM0MjcyMDFmNGEzMzYyNjI2ZmNiNjZlYjA2ZGU0MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDlmZDU3NDYzYTA5YzgwZDRkOGI0MmJmMjU3ZTc1ZGEyOGRkYWQyM2I3NTI3
|
10
|
+
MmI2YzRmNmNhM2JjZjZmMzQxNzk1YjZmNGNiZjJhODI0YjU1MWMzODE5YjJi
|
11
|
+
ZDcwMGNiNmQ5Y2M3NTU0ZGNjZTg5OTRiZjE4M2I0YTAwMWE1ZDg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTQ5OGJhMjRkZjI2MTU0ZDEzNzE5ZTdlMjVmYzI2MzcyODkxMThmM2NiMDMx
|
14
|
+
NTE0MTM2YTc4MzhjOWJmMmI2OGRjNDA5ZmU2NmU0ZTcwZjNmOTMxZDhiNjVl
|
15
|
+
MTk2MmRiODU1YjRkN2U0M2I3ZDIzMjAyM2M4ZDkyMGE5NTJhN2Q=
|
data/lib/dapp.rb
CHANGED
data/lib/dapp/builder.rb
CHANGED
@@ -127,7 +127,18 @@ module Dapp
|
|
127
127
|
[opts[:basename], opts[:name]].compact.join '-'
|
128
128
|
end
|
129
129
|
|
130
|
-
def
|
130
|
+
def add_git_artifact(where_to_add, **kwargs)
|
131
|
+
log "Adding artifact (to #{where_to_add})"
|
132
|
+
|
133
|
+
# own repo
|
134
|
+
repo = GitRepo::Own.new(self)
|
135
|
+
|
136
|
+
# add artifact
|
137
|
+
artifact = GitArtifact.new(self, repo, where_to_add, flush_cache: opts[:flush_cache], branch: home_branch, **kwargs)
|
138
|
+
artifact.add_multilayer!
|
139
|
+
end
|
140
|
+
|
141
|
+
def add_remote_git_artifact(url, where_to_add, branch: opts[:git_artifact_branch] || home_branch, ssh_key_path: nil, **kwargs)
|
131
142
|
log "Adding artifact from git (#{url} to #{where_to_add}, branch: #{branch})"
|
132
143
|
|
133
144
|
# extract git repo name from url
|
@@ -31,13 +31,13 @@ module Dapp
|
|
31
31
|
(opts[:build_history_length] - 1).downto(1).each do |n|
|
32
32
|
origin = i.merge(tag: "#{i[:tag]}_#{n}")
|
33
33
|
|
34
|
-
if docker.
|
34
|
+
if docker.image_exist?(**origin)
|
35
35
|
docker.tag origin, i.merge(tag: "#{i[:tag]}_#{n + 1}")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
# shift top -> 1
|
40
|
-
docker.tag i, i.merge(tag: "#{i[:tag]}_1") if docker.
|
40
|
+
docker.tag i, i.merge(tag: "#{i[:tag]}_1") if docker.image_exist?(**i)
|
41
41
|
|
42
42
|
# tag top
|
43
43
|
docker.tag image_id, i
|
data/lib/dapp/builder/centos7.rb
CHANGED
data/lib/dapp/builder/chefify.rb
CHANGED
@@ -11,7 +11,7 @@ module Dapp
|
|
11
11
|
[:prepare, :build, :setup].each do |step|
|
12
12
|
# run chef-solo for extra dapps
|
13
13
|
extra_dapps.each do |extra_dapp|
|
14
|
-
if dapp_chef_cookbooks_artifact.
|
14
|
+
if dapp_chef_cookbooks_artifact.exist_in_step? "cookbooks/#{extra_dapp}/recipes/#{step}.rb", step
|
15
15
|
# FIXME: env ???
|
16
16
|
docker.run "chef-solo -c /usr/share/dapp/chef_solo.rb -o #{extra_dapp}::#{step},env-#{opts[:basename]}::void", step: step
|
17
17
|
end
|
@@ -20,7 +20,7 @@ module Dapp
|
|
20
20
|
# run chef-solo for app
|
21
21
|
recipe = [opts[:name], step].compact.join '-'
|
22
22
|
# FIXME: env ???
|
23
|
-
if dapp_chef_cookbooks_artifact.
|
23
|
+
if dapp_chef_cookbooks_artifact.exist_in_step? "cookbooks/env-#{opts[:basename]}/recipes/#{recipe}.rb", step
|
24
24
|
docker.run "chef-solo -c /usr/share/dapp/chef_solo.rb -o env-#{opts[:basename]}::#{recipe}", step: step
|
25
25
|
end
|
26
26
|
end
|
@@ -71,7 +71,7 @@ module Dapp
|
|
71
71
|
|
72
72
|
def run_chef_solo_for_dapp_common
|
73
73
|
[:prepare, :build, :setup].each do |step|
|
74
|
-
if dapp_chef_cookbooks_artifact.
|
74
|
+
if dapp_chef_cookbooks_artifact.exist_in_step? "cookbooks/dapp-common/recipes/#{step}.rb", step
|
75
75
|
# FIXME: env ???
|
76
76
|
docker.run "chef-solo -c /usr/share/dapp/chef_solo.rb -o dapp-common::#{step},env-#{opts[:basename]}::void", step: step
|
77
77
|
end
|
data/lib/dapp/docker.rb
CHANGED
data/lib/dapp/git_artifact.rb
CHANGED
@@ -71,12 +71,8 @@ module Dapp
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
repo.
|
76
|
-
end
|
77
|
-
|
78
|
-
def exists_in_step?(path, step)
|
79
|
-
exists_in_commit?(path, commit_by_step(step))
|
74
|
+
def exist_in_step?(path, step)
|
75
|
+
repo.exist_in_commit?(path, commit_by_step(step))
|
80
76
|
end
|
81
77
|
|
82
78
|
def prepare_step_commit
|
@@ -96,12 +92,9 @@ module Dapp
|
|
96
92
|
end
|
97
93
|
|
98
94
|
def any_changes?(from)
|
99
|
-
!repo.git_bare("diff --quiet #{from}..#{repo_latest_commit}#{" --relative=#{cwd}" if cwd} #{paths(true)}", returns: [0, 1]).status.success?
|
95
|
+
!repo.git_bare("diff --quiet #{from}..#{repo_latest_commit}#{" --relative=#{cwd}" if cwd} -- #{paths(true)}", returns: [0, 1]).status.success?
|
100
96
|
end
|
101
97
|
|
102
|
-
protected
|
103
|
-
|
104
|
-
attr_reader :builder
|
105
98
|
attr_reader :repo
|
106
99
|
attr_reader :name
|
107
100
|
attr_reader :where_to_add
|
@@ -110,6 +103,10 @@ module Dapp
|
|
110
103
|
attr_reader :owner
|
111
104
|
attr_reader :group
|
112
105
|
attr_reader :interlayer_period
|
106
|
+
|
107
|
+
protected
|
108
|
+
|
109
|
+
attr_reader :builder
|
113
110
|
attr_reader :atomizer
|
114
111
|
|
115
112
|
def lock_with_repo(&blk)
|
@@ -119,7 +116,7 @@ module Dapp
|
|
119
116
|
end
|
120
117
|
|
121
118
|
def create_and_add_archive
|
122
|
-
create_archive! unless
|
119
|
+
create_archive! unless archive_exist?
|
123
120
|
add_archive
|
124
121
|
end
|
125
122
|
|
@@ -221,7 +218,7 @@ module Dapp
|
|
221
218
|
File.write archive_commitfile_path, repo_latest_commit
|
222
219
|
end
|
223
220
|
|
224
|
-
def
|
221
|
+
def archive_exist?
|
225
222
|
File.exist? archive_commitfile_path
|
226
223
|
end
|
227
224
|
|
@@ -248,17 +245,18 @@ module Dapp
|
|
248
245
|
def add_patch(filename, step:)
|
249
246
|
builder.docker.add_artifact(build_path(filename), filename, '/tmp', step: step)
|
250
247
|
|
251
|
-
builder.docker.run
|
248
|
+
builder.docker.run(
|
252
249
|
"zcat /tmp/#{filename} | #{sudo}git apply --whitespace=nowarn --directory=#{where_to_add}",
|
253
|
-
"rm /tmp/#{filename}"
|
254
|
-
|
250
|
+
"rm /tmp/#{filename}",
|
251
|
+
step: step
|
252
|
+
)
|
255
253
|
end
|
256
254
|
|
257
255
|
def create_patch!(from, filename, commitfile_path)
|
258
256
|
atomizer << build_path(filename)
|
259
257
|
atomizer << commitfile_path
|
260
258
|
|
261
|
-
repo.git_bare "diff --binary #{from}..#{repo_latest_commit}#{" --relative=#{cwd}" if cwd} #{paths(true)} | gzip > #{build_path filename}"
|
259
|
+
repo.git_bare "diff --binary #{from}..#{repo_latest_commit}#{" --relative=#{cwd}" if cwd} -- #{paths(true)} | gzip > #{build_path filename}"
|
262
260
|
File.write commitfile_path, repo_latest_commit
|
263
261
|
end
|
264
262
|
|
data/lib/dapp/git_repo/base.rb
CHANGED
@@ -20,10 +20,6 @@ module Dapp
|
|
20
20
|
build_path "#{name}.git"
|
21
21
|
end
|
22
22
|
|
23
|
-
def git(command, **kwargs)
|
24
|
-
builder.shellout "git #{command}", **kwargs
|
25
|
-
end
|
26
|
-
|
27
23
|
def git_bare(command, **kwargs)
|
28
24
|
git "--git-dir=#{dir_path} #{command}", **kwargs
|
29
25
|
end
|
@@ -36,15 +32,22 @@ module Dapp
|
|
36
32
|
git_bare("rev-parse #{branch}").stdout.strip
|
37
33
|
end
|
38
34
|
|
35
|
+
def exist_in_commit?(path, commit)
|
36
|
+
git_bare("cat-file -e #{commit}:#{path}", returns: [0, 128]).status.success?
|
37
|
+
end
|
38
|
+
|
39
39
|
def cleanup!
|
40
|
-
lock do
|
41
|
-
FileUtils.rm_rf dir_path
|
42
|
-
end
|
43
40
|
end
|
44
41
|
|
45
42
|
def lock(**kwargs, &block)
|
46
43
|
builder.filelock(build_path("#{name}.lock"), error_message: "Repository #{name} in use! Try again later.", **kwargs, &block)
|
47
44
|
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def git(command, **kwargs)
|
49
|
+
builder.shellout "git #{command}", **kwargs
|
50
|
+
end
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Dapp
|
2
|
+
module GitRepo
|
3
|
+
# Own Git repo
|
4
|
+
class Own < Base
|
5
|
+
def initialize(builder, **kwargs)
|
6
|
+
super(builder, 'own', **kwargs)
|
7
|
+
end
|
8
|
+
|
9
|
+
def dir_path
|
10
|
+
@dir_path ||= git("-C #{builder.home_path} rev-parse --git-dir").stdout.strip
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/dapp/git_repo/remote.rb
CHANGED
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mixlib-shellout
|
@@ -103,16 +103,30 @@ dependencies:
|
|
103
103
|
name: test_construct
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ~>
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
108
|
+
version: '2'
|
109
109
|
type: :development
|
110
110
|
prerelease: false
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- -
|
113
|
+
- - ~>
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: '
|
115
|
+
version: '2'
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: timecop
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0.8'
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ~>
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0.8'
|
116
130
|
- !ruby/object:Gem::Dependency
|
117
131
|
name: pry
|
118
132
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,16 +191,16 @@ dependencies:
|
|
177
191
|
name: codeclimate-test-reporter
|
178
192
|
requirement: !ruby/object:Gem::Requirement
|
179
193
|
requirements:
|
180
|
-
- -
|
194
|
+
- - ~>
|
181
195
|
- !ruby/object:Gem::Version
|
182
|
-
version: '0'
|
196
|
+
version: '0.5'
|
183
197
|
type: :development
|
184
198
|
prerelease: false
|
185
199
|
version_requirements: !ruby/object:Gem::Requirement
|
186
200
|
requirements:
|
187
|
-
- -
|
201
|
+
- - ~>
|
188
202
|
- !ruby/object:Gem::Version
|
189
|
-
version: '0'
|
203
|
+
version: '0.5'
|
190
204
|
description: Build docker packaged apps using chef or shell
|
191
205
|
email:
|
192
206
|
- dmitry.stolyarov@flant.com
|
@@ -210,6 +224,7 @@ files:
|
|
210
224
|
- lib/dapp/git_artifact.rb
|
211
225
|
- lib/dapp/git_repo/base.rb
|
212
226
|
- lib/dapp/git_repo/chronicler.rb
|
227
|
+
- lib/dapp/git_repo/own.rb
|
213
228
|
- lib/dapp/git_repo/remote.rb
|
214
229
|
- lib/dapp/version.rb
|
215
230
|
homepage: https://github.com/flant/dapp
|