opskeleton 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +18 -14
- data/docs/doc.adoc +34 -3
- data/lib/opskeleton/push.rb +19 -11
- data/lib/opskeleton/version.rb +1 -1
- data/opskeleton.gemspec +1 -0
- data/test/git_test.rb +10 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23dd029f2dfd870048e84db9f1697b4e70345807
|
4
|
+
data.tar.gz: aad74fe64226e511e7f4e81510cee8a7daa4d120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba347ecad77000f8de4708550b9cb2f19db7fddc1bd36974d68c4b705b3e46c5c6a7a05b6314d69293c4aed69e1678d66bfba8771c9a515e18239beeebd320a
|
7
|
+
data.tar.gz: a275be5c7b3b534ebd522463a030d4ea8c2e1c16fe4aa265993486949873a7c2be8a467bf36a57d9cd4cd459e01ab008797196e6976ba8c55ea4f5dca36683bc
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
opskeleton (0.9.
|
4
|
+
opskeleton (0.9.4)
|
5
5
|
aws-sdk (~> 2)
|
6
6
|
bintray_deploy
|
7
7
|
git
|
8
|
+
git_clone_url
|
8
9
|
net-scp
|
9
10
|
thor
|
10
11
|
|
@@ -22,12 +23,12 @@ GEM
|
|
22
23
|
thread_safe (~> 0.3, >= 0.3.4)
|
23
24
|
tzinfo (~> 1.1)
|
24
25
|
asciidoctor (1.5.2)
|
25
|
-
aws-sdk (2.1.
|
26
|
-
aws-sdk-resources (= 2.1.
|
27
|
-
aws-sdk-core (2.1.
|
26
|
+
aws-sdk (2.1.7)
|
27
|
+
aws-sdk-resources (= 2.1.7)
|
28
|
+
aws-sdk-core (2.1.7)
|
28
29
|
jmespath (~> 1.0)
|
29
|
-
aws-sdk-resources (2.1.
|
30
|
-
aws-sdk-core (= 2.1.
|
30
|
+
aws-sdk-resources (2.1.7)
|
31
|
+
aws-sdk-core (= 2.1.7)
|
31
32
|
bintray_deploy (0.0.4)
|
32
33
|
configuration
|
33
34
|
rest-client
|
@@ -76,11 +77,13 @@ GEM
|
|
76
77
|
faraday (0.9.1)
|
77
78
|
multipart-post (>= 1.2, < 3)
|
78
79
|
ffi (1.9.10)
|
79
|
-
ffi-yajl (2.2.
|
80
|
+
ffi-yajl (2.2.2)
|
80
81
|
libyajl2 (~> 1.2)
|
81
82
|
formatador (0.2.5)
|
82
83
|
git (1.2.9.1)
|
83
|
-
|
84
|
+
git_clone_url (0.1.0)
|
85
|
+
uri-ssh_git
|
86
|
+
guard (2.12.9)
|
84
87
|
formatador (>= 0.2.4)
|
85
88
|
listen (>= 2.7, <= 4.0)
|
86
89
|
lumberjack (~> 1.0)
|
@@ -201,15 +204,15 @@ GEM
|
|
201
204
|
rspec-core (~> 3.3.0)
|
202
205
|
rspec-expectations (~> 3.3.0)
|
203
206
|
rspec-mocks (~> 3.3.0)
|
204
|
-
rspec-core (3.3.
|
207
|
+
rspec-core (3.3.2)
|
205
208
|
rspec-support (~> 3.3.0)
|
206
|
-
rspec-expectations (3.3.
|
209
|
+
rspec-expectations (3.3.1)
|
207
210
|
diff-lcs (>= 1.2.0, < 2.0)
|
208
211
|
rspec-support (~> 3.3.0)
|
209
212
|
rspec-its (1.2.0)
|
210
213
|
rspec-core (>= 3.0.0)
|
211
214
|
rspec-expectations (>= 3.0.0)
|
212
|
-
rspec-mocks (3.3.
|
215
|
+
rspec-mocks (3.3.2)
|
213
216
|
diff-lcs (>= 1.2.0, < 2.0)
|
214
217
|
rspec-support (~> 3.3.0)
|
215
218
|
rspec-puppet (2.2.0)
|
@@ -219,15 +222,15 @@ GEM
|
|
219
222
|
builder (< 4)
|
220
223
|
rspec-core (>= 2, < 4, != 2.12.0)
|
221
224
|
rsync (1.0.9)
|
222
|
-
serverspec (2.
|
225
|
+
serverspec (2.20.0)
|
223
226
|
multi_json
|
224
227
|
rspec (~> 3.0)
|
225
228
|
rspec-its
|
226
|
-
specinfra (~> 2.
|
229
|
+
specinfra (~> 2.38)
|
227
230
|
sfl (2.2)
|
228
231
|
shellany (0.0.1)
|
229
232
|
slop (3.6.0)
|
230
|
-
specinfra (2.
|
233
|
+
specinfra (2.38.1)
|
231
234
|
net-scp
|
232
235
|
net-ssh (~> 2.7)
|
233
236
|
net-telnet
|
@@ -241,6 +244,7 @@ GEM
|
|
241
244
|
unf (0.1.4)
|
242
245
|
unf_ext
|
243
246
|
unf_ext (0.0.7.1)
|
247
|
+
uri-ssh_git (0.1.1)
|
244
248
|
uuidtools (2.1.5)
|
245
249
|
wmi-lite (1.0.0)
|
246
250
|
yajl-ruby (1.2.1)
|
data/docs/doc.adoc
CHANGED
@@ -33,7 +33,7 @@ Perquisites (on Ubuntu):
|
|
33
33
|
|
34
34
|
* Vagrant 1.7.x
|
35
35
|
* RVM
|
36
|
-
* Ruby 2.1.
|
36
|
+
* Ruby >= 2.1.2
|
37
37
|
|
38
38
|
```bash
|
39
39
|
$ rvm use system
|
@@ -83,7 +83,7 @@ Opskelaton defines a module life cycle:
|
|
83
83
|
|
84
84
|
1. Internal non reusable modules (usually specific to a client site) go under static-modules
|
85
85
|
2. If we create a general reusable module which is ready for prime time we pull out to a new git repository.
|
86
|
-
3. The extracted module is added
|
86
|
+
3. The extracted module is added (using link:https://github.com/rodjek/librarian-puppet[librarian-puppet]) back as a third party module under modules folder.
|
87
87
|
|
88
88
|
Life cycle scheme:
|
89
89
|
|
@@ -151,6 +151,20 @@ Commit message:
|
|
151
151
|
This is a nice change
|
152
152
|
```
|
153
153
|
|
154
|
+
For more commit options:
|
155
|
+
|
156
|
+
```bash
|
157
|
+
$ opsk help commit
|
158
|
+
|
159
|
+
Usage:
|
160
|
+
opsk commit [message]
|
161
|
+
|
162
|
+
Options:
|
163
|
+
[--message=MESSAGE] # optional commit message
|
164
|
+
[--all], [--no-all] # commit all
|
165
|
+
|
166
|
+
commit each changed puppet module under modules folder
|
167
|
+
```
|
154
168
|
|
155
169
|
Once commits are made we can push the changes:
|
156
170
|
|
@@ -160,7 +174,24 @@ Push modules/artifactory? (y/n) y
|
|
160
174
|
pushing modules/artifactory ..
|
161
175
|
```
|
162
176
|
|
177
|
+
Opsk will add a remote writable repository for each submodule substituting the readonly protocol with a write enabled one, the default protocol is ssh (customizable by using --protocol).
|
163
178
|
|
179
|
+
For more options:
|
180
|
+
|
181
|
+
```bash
|
182
|
+
$ opsk help push
|
183
|
+
|
184
|
+
Usage:
|
185
|
+
opsk push
|
186
|
+
|
187
|
+
Options:
|
188
|
+
[--protocol=PROTOCOL] # remote ssh protocol (https or ssh)
|
189
|
+
# Default: ssh
|
190
|
+
[--dry], [--no-dry] # dry mode
|
191
|
+
[--all], [--no-all] # push all without asking
|
192
|
+
|
193
|
+
push each changed puppet module under modules folder
|
194
|
+
```
|
164
195
|
=== Testing
|
165
196
|
|
166
197
|
Opskelaton supports two levels of testing:
|
@@ -292,7 +323,7 @@ Opskelaton defines a simple cookbook life cycle:
|
|
292
323
|
|
293
324
|
1. Internal non reusable cookbooks (usually specific to a client site) go under static-cookbooks
|
294
325
|
2. If we create a general reusable cookbook which is ready for prime time we pull out to a new git repository.
|
295
|
-
3. The extracted cookbook is added back as a third party (using
|
326
|
+
3. The extracted cookbook is added back as a third party (using link:https://github.com/applicationsonline/librarian-chef[librarian-chef]) cookbook under cookbooks folder).
|
296
327
|
|
297
328
|
Life cycle scheme:
|
298
329
|
|
data/lib/opskeleton/push.rb
CHANGED
@@ -1,28 +1,36 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
require 'git_clone_url'
|
3
3
|
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def normalize_url(readonly,options)
|
5
|
+
url = GitCloneUrl.parse(readonly)
|
6
|
+
proto = options['protocol'] || 'ssh'
|
7
|
+
port = options['port']? ":#{options['port']}" : ''
|
8
|
+
user = options['user']? "#{options['user']}@" : ''
|
9
|
+
"#{proto}://#{user}#{url.host}#{port}#{url.path}"
|
8
10
|
end
|
9
11
|
|
10
|
-
def add_writable(g,
|
12
|
+
def add_writable(g,options)
|
11
13
|
readonly = g.remotes.find{|r|r.name.eql?('origin')}.url
|
12
|
-
writable = readonly
|
13
|
-
writable = add_pre(writable) if proto.eql?(:ssh)
|
14
|
+
writable = normalize_url(readonly,options)
|
14
15
|
remote_exists = g.remotes.map {|r| r.name}.include?('writable')
|
15
16
|
unless readonly.eql?(writable) or remote_exists
|
16
17
|
g.add_remote('writable',writable)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
# ruby-git cannot do this (lame)
|
22
|
+
def local_ahead?(d)
|
23
|
+
%x{git --git-dir=#{d}/.git --work-tree=#{d}}.include?('ahead')
|
24
|
+
end
|
25
|
+
|
20
26
|
module Opsk
|
21
27
|
class Push < Thor::Group
|
22
28
|
include Thorable, Thor::Actions
|
23
29
|
|
24
30
|
class_option :protocol, :type=> :string, :desc => 'remote ssh protocol (https or ssh)', :default => 'ssh'
|
25
31
|
class_option :dry, :type=> :boolean, :desc => 'dry mode', :default => false
|
32
|
+
class_option :user, :type=> :string, :desc => 'ssh protocol user'
|
33
|
+
class_option :port, :type=> :string, :desc => 'remote repo port'
|
26
34
|
class_option :all, :type=> :boolean, :desc => 'push all without asking', :default => false
|
27
35
|
|
28
36
|
def validate
|
@@ -34,9 +42,9 @@ module Opsk
|
|
34
42
|
Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
|
35
43
|
begin
|
36
44
|
if File.exists?("#{d}/.git")
|
37
|
-
g = Git.
|
38
|
-
add_writable(g,options
|
39
|
-
if !options['dry'] and
|
45
|
+
g = Git.open(d)
|
46
|
+
add_writable(g,options)
|
47
|
+
if !options['dry'] and local_ahead?(d)
|
40
48
|
resp = yes?("Push #{d}? (y/n)") unless options['all']
|
41
49
|
if(options['all'] or resp)
|
42
50
|
say "pushing #{d} .."
|
data/lib/opskeleton/version.rb
CHANGED
data/opskeleton.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.add_dependency('aws-sdk', '~> 2')
|
17
17
|
gem.add_dependency('net-scp')
|
18
18
|
gem.add_dependency('git')
|
19
|
+
gem.add_dependency('git_clone_url')
|
19
20
|
gem.add_development_dependency('puppet','=3.7.5')
|
20
21
|
gem.add_development_dependency('chef')
|
21
22
|
gem.add_development_dependency('rspec-puppet')
|
data/test/git_test.rb
CHANGED
@@ -47,4 +47,14 @@ class GitTest < MiniTest::Unit::TestCase
|
|
47
47
|
g = Git.init(ROOT)
|
48
48
|
assert g.remotes.length == 2
|
49
49
|
end
|
50
|
+
|
51
|
+
def test_urls
|
52
|
+
readonly = 'git://github.com/pulling-strings/puppet-jdk.git'
|
53
|
+
norm = normalize_url(readonly,{})
|
54
|
+
assert norm == 'ssh://github.com/pulling-strings/puppet-jdk.git'
|
55
|
+
norm = normalize_url(readonly,{'protocol' => 'https','port' => '1234'})
|
56
|
+
assert norm == 'https://github.com:1234/pulling-strings/puppet-jdk.git'
|
57
|
+
norm = normalize_url(readonly,{'user' => 'ronen', 'protocol' => 'ssh','port' => '1234'})
|
58
|
+
assert norm == 'ssh://ronen@github.com:1234/pulling-strings/puppet-jdk.git'
|
59
|
+
end
|
50
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opskeleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- narkisr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: git_clone_url
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: puppet
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|