opskeleton 0.8.12 → 0.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b848a2b49c73f2d6aecda373d9c63b6427d543e9
4
- data.tar.gz: d85182e5a25bb0cfd1f05d9db9033f8c614181bb
3
+ metadata.gz: 508174515b38f87c8e376b887939b4d15e6c5b7d
4
+ data.tar.gz: a06b48dcaf9022a15330ceb46aef1325a87f5fd4
5
5
  SHA512:
6
- metadata.gz: e77123719efaba63d69afafe0fe4268e8be39f88ded9d5ca0fa7f26dab3a8f64f910742ed18924fb86c1b986575782810fe69c9daa77fe20281ed4cd8df28233
7
- data.tar.gz: 3594893f6c1e027ac790b96870cadc18fb4da011299725f943727fa6ae152378eaf9d55b91ec728b49e8afad460057cacf98b8790f469e27c1772bb6fc1c36b1
6
+ metadata.gz: 52409252bfa751e825d48f429da25bcf868c65c896508781dc5e205ae0c33d9efe780373287e51d356e6b17665456de95905c99f95eb3bfd81bb6659231f26e3
7
+ data.tar.gz: 024cf29ff87a4773f384c47a887bdeb589d7642c1ca47c5f37572992b8de3026eb216a954ccbf5cf434b287d8863f0e3c74062b4e38a9bdda569de51ff26e010
data/.travis.yml CHANGED
@@ -2,6 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.2
4
4
  script:
5
+ - "git config --global user.email 'you@example.com'"
6
+ - "git config --global user.name 'Your Name'"
5
7
  - "touch ~/.configuration.rb"
6
8
  - "bundle install"
7
9
  - "bundle exec rake test"
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # Changes to opskeleton in version 0.9.0
2
+
3
+ Adding support for puppet modules commit and push actions.
4
+
1
5
  # Changes to opskeleton in version 0.8.11
2
6
 
3
7
  exit 1 when package is missing on different deploy options.
data/bin/opsk CHANGED
@@ -21,6 +21,7 @@ module Opsk
21
21
  register Opsk::Package, 'package', 'package', 'packages current module for celestial'
22
22
  register Opsk::Dockerize, 'dockerize', 'dockerize [from] [os_type]', 'Creates a docker image from the current sandbox'
23
23
  register Opsk::Commit, 'commit', 'commit [message]', 'commit each changed puppet module under modules folder'
24
+ register Opsk::Push, 'push', 'push', 'push each changed puppet module under modules folder'
24
25
  register Opsk::Clean, 'clean', 'clean', 'cleans up packaging products'
25
26
  register Opsk::Bump, 'bump', 'bump', 'bumps up version (clearing old version also)'
26
27
  register Opsk::DeployBintray, 'deploy_bintray', 'deploy_bintray [repo]', 'deploy packge into bintray.com'
@@ -37,5 +38,7 @@ end
37
38
  # not sure that this is the cleanest way
38
39
  Opsk::Root.tasks['generate_puppet'].options = Opsk::GeneratePuppet.class_options
39
40
  Opsk::Root.tasks['generate_chef'].options = Opsk::GenerateChef.class_options
41
+ Opsk::Root.tasks['push'].options = Opsk::Push.class_options
42
+ Opsk::Root.tasks['commit'].options = Opsk::Commit.class_options
40
43
 
41
44
  Opsk::Root.start ARGV
@@ -1,31 +1,40 @@
1
+
1
2
  module Opsk
2
3
  class Commit < Thor::Group
3
4
  include Thorable, Thor::Actions
4
5
 
5
6
  class_option :message, :type=> :string, :desc => 'optional commit message'
7
+ class_option :all, :type=> :boolean, :desc => 'commit all', :default => false
6
8
 
7
9
  def validate
8
10
  check_root
9
11
  end
10
12
 
13
+
11
14
  def commit
12
15
  Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
13
16
  if File.exists?("#{d}/.git")
14
17
  g = Git.init(d)
15
18
  if g.status.changed.keys.length > 0
16
- puts "Changes found for #{d}:\n\n"
17
- puts "#{g.show}\n"
18
- g.checkout('master')
19
- if options['message']
20
- g.commit_all(options['message'])
21
- else
22
- puts 'Please provide commit message:'
23
- g.commit_all(STDIN.gets.chomp)
19
+ puts "Listing changes for #{d}:\n\n"
20
+ puts "#{g.show}\n\n"
21
+ puts "Commit the changes under #{d}? (y/n)\n\n" unless options['all']
22
+ if(options['all'] or STDIN.gets.chomp.eql?('y'))
23
+ g.checkout('master')
24
+ if options['message']
25
+ g.commit_all(options['message'])
26
+ else
27
+ puts 'Please provide commit message:\n'
28
+ g.commit_all(STDIN.gets.chomp)
29
+ end
24
30
  end
31
+ else
32
+ puts 'no changes detected'
25
33
  end
26
34
  end
27
35
  end
28
36
  end
29
37
 
38
+
30
39
  end
31
40
  end
@@ -0,0 +1,52 @@
1
+
2
+ GIT_PROTO = { ssh:'git@', https: 'https://' }
3
+
4
+ def add_pre(url)
5
+ res = url.split('/')
6
+ res[0] = "#{res[0]}:"
7
+ res.join('/')
8
+ end
9
+
10
+ def add_writable(g,proto)
11
+ readonly = g.remotes.find{|r|r.name.eql?('origin')}.url
12
+ writable = readonly.gsub(/git\:\/\//,GIT_PROTO[proto])
13
+ writable = add_pre(writable) if proto.eql?(:ssh)
14
+ remote_exists = g.remotes.map {|r| r.name}.include?('writable')
15
+ unless readonly.eql?(writable) or remote_exists
16
+ g.add_remote('writable',writable)
17
+ end
18
+ end
19
+
20
+ module Opsk
21
+ class Push < Thor::Group
22
+ include Thorable, Thor::Actions
23
+
24
+ class_option :protocol, :type=> :string, :desc => 'remote ssh protocol (https or ssh)', :default => 'ssh'
25
+ class_option :dry, :type=> :boolean, :desc => 'dry mode', :default => false
26
+ class_option :all, :type=> :boolean, :desc => 'push all without asking', :default => false
27
+
28
+ def validate
29
+ check_root
30
+ end
31
+
32
+
33
+ def push
34
+ Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
35
+ if File.exists?("#{d}/.git")
36
+ g = Git.init(d)
37
+ add_writable(g,options['protocol'].to_sym)
38
+ if !options['dry'] and g.diff('origin').stats[:files].keys.length > 0
39
+ puts "push #{d}? (y/n)" unless options['all']
40
+ if(options['all'] or STDIN.gets.chomp.eql?('y'))
41
+ puts "Pushing #{d} .."
42
+ g.push('writable')
43
+ g.pull
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Opskeleton
2
- VERSION = '0.8.12'
2
+ VERSION = '0.9.0'
3
3
  end
data/lib/opskeleton.rb CHANGED
@@ -16,4 +16,5 @@ require 'opskeleton/deploy_s3'
16
16
  require 'opskeleton/deploy_scp'
17
17
  require 'opskeleton/module'
18
18
  require 'opskeleton/commit'
19
+ require 'opskeleton/push'
19
20
 
@@ -7,7 +7,7 @@ require 'git'
7
7
 
8
8
  SANDBOX = 'commit'
9
9
  ROOT = "#{SANDBOX}-sandbox/modules/foo"
10
- class CommitTest < MiniTest::Unit::TestCase
10
+ class GitTest < MiniTest::Unit::TestCase
11
11
  include FileUtils
12
12
 
13
13
  def setup
@@ -15,6 +15,7 @@ class CommitTest < MiniTest::Unit::TestCase
15
15
  mkdir_p(ROOT)
16
16
  mkdir_p("#{SANDBOX}-sandbox/modules/non-git")
17
17
  g = Git.init(ROOT)
18
+ g.add_remote('origin','git://github.com/foo/bar.git')
18
19
  touch("#{ROOT}/bla.txt")
19
20
  g.add('bla.txt')
20
21
  g.commit_all('message')
@@ -33,9 +34,17 @@ class CommitTest < MiniTest::Unit::TestCase
33
34
 
34
35
  def test_commit
35
36
  with_cwd "#{SANDBOX}-sandbox" do
36
- Opsk::Root.start ['commit', '--message', 'some message']
37
+ Opsk::Root.start ['commit', '--message', 'some message', '--all', 'true']
37
38
  end
38
39
  g = Git.init(ROOT)
39
40
  assert g.show.include? 'some message'
40
41
  end
42
+
43
+ def test_writeable
44
+ with_cwd "#{SANDBOX}-sandbox" do
45
+ Opsk::Root.start ['push', '--dry', 'true']
46
+ end
47
+ g = Git.init(ROOT)
48
+ assert g.remotes.length == 2
49
+ end
41
50
  end
data/test/test_helper.rb CHANGED
@@ -10,6 +10,7 @@ module Opsk
10
10
  register Opsk::GenerateChef, 'generate_chef', 'generate_chef [name] [box]', 'generates opskelaton project structure'
11
11
  register Opsk::Package, 'package', 'package', 'packages current module for celestial'
12
12
  register Opsk::Commit, 'commit', 'commit', 'commits current module for celestial'
13
+ register Opsk::Push, 'push', 'push', 'push changed repos'
13
14
 
14
15
  end
15
16
  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.8.12
4
+ version: 0.9.0
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-08 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -204,6 +204,7 @@ files:
204
204
  - lib/opskeleton/generate_puppet.rb
205
205
  - lib/opskeleton/module.rb
206
206
  - lib/opskeleton/package.rb
207
+ - lib/opskeleton/push.rb
207
208
  - lib/opskeleton/thorable.rb
208
209
  - lib/opskeleton/version.rb
209
210
  - opskeleton.gemspec
@@ -249,7 +250,7 @@ files:
249
250
  - templates/ruby-version.erb
250
251
  - templates/spec.erb
251
252
  - test/chef_package_test.rb
252
- - test/commit_test.rb
253
+ - test/git_test.rb
253
254
  - test/puppet_package_test.rb
254
255
  - test/test_helper.rb
255
256
  homepage: https://github.com/narkisr/opskeleton
@@ -271,12 +272,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
272
  version: '0'
272
273
  requirements: []
273
274
  rubyforge_project:
274
- rubygems_version: 2.4.7
275
+ rubygems_version: 2.2.2
275
276
  signing_key:
276
277
  specification_version: 4
277
278
  summary: A generator for ops projects that include vagrant puppet and fpm
278
279
  test_files:
279
280
  - test/chef_package_test.rb
280
- - test/commit_test.rb
281
+ - test/git_test.rb
281
282
  - test/puppet_package_test.rb
282
283
  - test/test_helper.rb