berks2env 0.0.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjMzY2NmYTlmNjdjZjdmMDA5NWEwMjc3OWRmYTRmNDc5MzVkMTA0ZA==
5
+ data.tar.gz: !binary |-
6
+ MjJlNWI0YmFmODc1ODk4YWQyNGU1NTU4NWRlZDMxNTlhOGNhNjkyNg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODA4M2JkNzYyM2VlMjZhNzJjOTUyYTgwNjUyYjc0YjQ2M2Y4NjAxYzc1MDY0
10
+ OTAzNGUzOGJiYzA2NmUwYTg4MWVmZWY4NDQzYTMxMGU0ZDUzNjA4YTlkOTli
11
+ ZDQwYzZlZWY2ODc4MjQwYTJhZDNjYzE1MzRhZWE4ZDJhZGRjMGI=
12
+ data.tar.gz: !binary |-
13
+ MWY5MTM4MTMxZDZlOGNhYzljZDFmY2E4N2RiODBmNWNkOTdlZmZlMzc4ZDI0
14
+ NWQ3MjRiMzhiN2QwNjkwY2QxMDhjZWZkNDI5NTgwYjVhNTBiN2YwNjcxNTMy
15
+ MjI4ZjNiMzU5OTQ1OGYyMzExZmVjZWM1Y2NkOTExZDY5YjAwMzQ=
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ LineLength:
2
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.0.0
5
+ - 1.9.3
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: kY/p1rEAm3M5i6xthmU6zR1xQ4y2puHCRj6lhMjlo5eF9/jOqjBVE2GfyOZ+ZA3yuenBKO5kixesc/0zIWfxQakqjsFlW1h0Wl6+w67Rrphbbr9PPXoUuQ/QJ8Hic7v8xv2wefhtkLJ3B0b7DP3jlyuE02qAzBATae/kHS27AtM=
10
+ gem: berks2env
11
+ on:
12
+ tags: true
13
+ repo: petecheslock/berks2env
14
+ script:
15
+ - bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in redphone.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ berks2env (0.0.1)
5
+ berkshelf (~> 3.1)
6
+ chef (~> 11.8)
7
+ json (~> 1.7.7)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ addressable (2.3.6)
13
+ ast (2.0.0)
14
+ berkshelf (3.1.1)
15
+ addressable (~> 2.3.4)
16
+ berkshelf-api-client (~> 1.2)
17
+ buff-config (~> 0.2)
18
+ buff-extensions (~> 0.4)
19
+ buff-shell_out (~> 0.1)
20
+ celluloid (~> 0.16.0.pre)
21
+ celluloid-io (~> 0.16.0.pre)
22
+ faraday (~> 0.9.0)
23
+ minitar (~> 0.5.4)
24
+ octokit (~> 3.0)
25
+ retryable (~> 1.3.3)
26
+ ridley (~> 3.1)
27
+ solve (~> 1.1)
28
+ thor (~> 0.18)
29
+ berkshelf-api-client (1.2.0)
30
+ faraday (~> 0.9.0)
31
+ buff-config (0.4.0)
32
+ buff-extensions (~> 0.3)
33
+ varia_model (~> 0.1)
34
+ buff-extensions (0.5.0)
35
+ buff-ignore (1.1.1)
36
+ buff-ruby_engine (0.1.0)
37
+ buff-shell_out (0.1.1)
38
+ buff-ruby_engine (~> 0.1.0)
39
+ celluloid (0.16.0.pre)
40
+ timers (~> 2.0.0)
41
+ celluloid-io (0.16.0.pre)
42
+ celluloid (>= 0.16.0.pre)
43
+ nio4r (>= 1.0.0)
44
+ chef (11.12.2)
45
+ chef-zero (~> 2.0, >= 2.0.2)
46
+ diff-lcs (~> 1.2, >= 1.2.4)
47
+ erubis (~> 2.7)
48
+ highline (~> 1.6, >= 1.6.9)
49
+ json (>= 1.4.4, <= 1.8.1)
50
+ mime-types (~> 1.16)
51
+ mixlib-authentication (~> 1.3)
52
+ mixlib-cli (~> 1.4)
53
+ mixlib-config (~> 2.0)
54
+ mixlib-log (~> 1.3)
55
+ mixlib-shellout (~> 1.4)
56
+ net-ssh (~> 2.6)
57
+ net-ssh-multi (~> 1.1)
58
+ ohai (~> 7.0)
59
+ pry (~> 0.9)
60
+ rest-client (>= 1.0.4, < 1.7.0)
61
+ yajl-ruby (~> 1.1)
62
+ chef-zero (2.0.2)
63
+ hashie (~> 2.0)
64
+ json
65
+ mixlib-log (~> 1.3)
66
+ rack
67
+ coderay (1.1.0)
68
+ dep-selector-libgecode (1.0.0)
69
+ dep_selector (1.0.3)
70
+ dep-selector-libgecode (~> 1.0)
71
+ ffi (~> 1.9)
72
+ diff-lcs (1.2.5)
73
+ erubis (2.7.0)
74
+ faraday (0.9.0)
75
+ multipart-post (>= 1.2, < 3)
76
+ ffi (1.9.3)
77
+ hashie (2.1.1)
78
+ highline (1.6.21)
79
+ hitimes (1.2.1)
80
+ ipaddress (0.8.0)
81
+ json (1.7.7)
82
+ method_source (0.8.2)
83
+ mime-types (1.25.1)
84
+ minitar (0.5.4)
85
+ mixlib-authentication (1.3.0)
86
+ mixlib-log
87
+ mixlib-cli (1.5.0)
88
+ mixlib-config (2.1.0)
89
+ mixlib-log (1.6.0)
90
+ mixlib-shellout (1.4.0)
91
+ multipart-post (2.0.0)
92
+ net-http-persistent (2.9.4)
93
+ net-ssh (2.8.0)
94
+ net-ssh-gateway (1.2.0)
95
+ net-ssh (>= 2.6.5)
96
+ net-ssh-multi (1.2.0)
97
+ net-ssh (>= 2.6.5)
98
+ net-ssh-gateway (>= 1.2.0)
99
+ nio4r (1.0.0)
100
+ octokit (3.1.0)
101
+ sawyer (~> 0.5.3)
102
+ ohai (7.0.2)
103
+ ipaddress
104
+ mime-types (~> 1.16)
105
+ mixlib-cli
106
+ mixlib-config (~> 2.0)
107
+ mixlib-log
108
+ mixlib-shellout (~> 1.2)
109
+ systemu (~> 2.5.2)
110
+ yajl-ruby
111
+ parser (2.1.9)
112
+ ast (>= 1.1, < 3.0)
113
+ slop (~> 3.4, >= 3.4.5)
114
+ powerpack (0.0.9)
115
+ pry (0.9.12.6)
116
+ coderay (~> 1.0)
117
+ method_source (~> 0.8)
118
+ slop (~> 3.4)
119
+ rack (1.5.2)
120
+ rainbow (2.0.0)
121
+ rake (10.3.1)
122
+ rest-client (1.6.7)
123
+ mime-types (>= 1.16)
124
+ retryable (1.3.5)
125
+ ridley (3.1.0)
126
+ addressable
127
+ buff-config (~> 0.2)
128
+ buff-extensions (~> 0.3)
129
+ buff-ignore (~> 1.1)
130
+ buff-shell_out (~> 0.1)
131
+ celluloid (~> 0.16.0.pre)
132
+ celluloid-io (~> 0.16.0.pre)
133
+ erubis
134
+ faraday (~> 0.9.0)
135
+ hashie (>= 2.0.2)
136
+ json (>= 1.7.7)
137
+ mixlib-authentication (>= 1.3.0)
138
+ net-http-persistent (>= 2.8)
139
+ retryable
140
+ semverse (~> 1.1)
141
+ varia_model (~> 0.3)
142
+ rubocop (0.21.0)
143
+ json (>= 1.7.7, < 2)
144
+ parser (~> 2.1.9)
145
+ powerpack (~> 0.0.6)
146
+ rainbow (>= 1.99.1, < 3.0)
147
+ ruby-progressbar (~> 1.4)
148
+ ruby-progressbar (1.4.2)
149
+ sawyer (0.5.4)
150
+ addressable (~> 2.3.5)
151
+ faraday (~> 0.8, < 0.10)
152
+ semverse (1.1.0)
153
+ slop (3.5.0)
154
+ solve (1.2.0)
155
+ dep_selector (~> 1.0)
156
+ semverse (~> 1.1)
157
+ systemu (2.5.2)
158
+ thor (0.19.1)
159
+ timers (2.0.0)
160
+ hitimes
161
+ varia_model (0.3.2)
162
+ buff-extensions (~> 0.2)
163
+ hashie (>= 2.0.2)
164
+ yajl-ruby (1.2.0)
165
+
166
+ PLATFORMS
167
+ ruby
168
+
169
+ DEPENDENCIES
170
+ berks2env!
171
+ rake
172
+ rubocop (~> 0.21.0)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Pete Cheslock
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ [![Build Status](https://travis-ci.org/petecheslock/berks2env.svg?branch=master)](https://travis-ci.org/petecheslock/berks2env)
2
+ berks2env
3
+ =========
4
+ Convert a Berkshelf Lockfile to a Chef Environment json
5
+
6
+ With Berks3 - ```berks apply``` is an awesome feature - but doesn't work if you want to create a net new environment (via your CI system)
7
+
8
+ What this does is allows you to pass in a branch or version number (or any arbitrary data really) and a Berksfile.lock and convert them
9
+ into a Chef server supported envrionment json.
10
+
11
+ TODO
12
+ ========
13
+ Currently this is the raw, original version of the script we use to create environment files per our workflow
14
+ that was discussed at ChefConf 2014 - You can watch this talk here.
15
+
16
+ https://www.youtube.com/watch?v=L__8o02od6Q
17
+
18
+ Use [this link](http://youtu.be/L__8o02od6Q?t=21m16s) to jump directly to the section I talk about Jenkins/CI workflows
19
+ If you just want the original script we used on CI (per the talk above) - you can [find it here](https://github.com/petecheslock/berks2env/blob/4fa764134c11912a9c82391540903697fe7fe5a6/berks2env.rb)
20
+
21
+ * Going to eventually convert this into a rubygem, and maybe even propose as a feature update to Berks3
22
+ * Going to support another command option to injest json into the resultant environment json
23
+ * General cleanup and refactor to make it more flexible.
24
+ * This is raw and has only a single specific use case - Watch my talk if you want
25
+ more info about how and why this is used.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ Rake::TestTask.new do |test|
7
+ test.pattern = 'test/*_tests.rb'
8
+ end
9
+
10
+ task default: 'test'
data/berks2env.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'berks2env/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'berks2env'
7
+ s.version = Berks2Env::VERSION
8
+ s.authors = ['Pete Cheslock']
9
+ s.email = 'petecheslock@gmail.com'
10
+ s.homepage = 'https://github.com/petecheslock/berks2env'
11
+ s.summary = %q(Convert a Berkshelf Lockfile to a Chef Environment json)
12
+ s.description = %q(Convert a Berkshelf Lockfile to a Chef Environment json)
13
+ s.has_rdoc = false
14
+ s.license = 'MIT'
15
+
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.require_paths = ['lib']
20
+
21
+ s.add_dependency('chef', ['~> 11.8'])
22
+ s.add_dependency('json', ['~> 1.7.7'])
23
+ s.add_dependency('berkshelf', ['~> 3.1'])
24
+ s.add_development_dependency('rubocop', ['~> 0.21.0'])
25
+ s.add_development_dependency('rake')
26
+
27
+ end
data/bin/berks2env ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), %w(.. lib)))
5
+
6
+ require 'berks2env'
7
+
8
+ if ARGV.length != 2
9
+ puts 'Usage: berks2env <version/branch> <berkslock>'
10
+ exit 1
11
+ end
12
+
13
+ Berks2Env::Convert.new(ARGV[0], ARGV[1]).run
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ # This module holds the Berks2Env version info
4
+ module Berks2Env
5
+ VERSION = '0.0.1'
6
+ end
data/lib/berks2env.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'berks2env/version'
2
+
3
+ require 'berkshelf'
4
+ require 'chef/environment'
5
+
6
+ module Berks2Env
7
+ # This class takes and dumps out environment json files
8
+ class Convert
9
+ attr_reader :branch, :berkslockfile
10
+
11
+ def initialize(branch, berkslockfile)
12
+ @branch = branch
13
+ @berkslockfile = berkslockfile
14
+ end
15
+
16
+ def run
17
+ environment = Chef::Environment.new
18
+ environment.name(sanitize)
19
+ berksfile = Berkshelf::Lockfile.from_file(@berkslockfile)
20
+ locks = berksfile.graph.locks.inject({}) do |hash, (name, dependency)|
21
+ hash[name] = "= #{dependency.locked_version.to_s}"
22
+ hash
23
+ end
24
+ environment.cookbook_versions(locks)
25
+
26
+ environment.override_attributes({ :server_env => { :version => { :real => @branch, :virt => @branch }}})
27
+ envfile = File.open("#{@branch}.json", 'w')
28
+ envfile.write(environment.to_json)
29
+ envfile.close
30
+ if @branch.match(/\d+\.\d+\.\d+\z/)
31
+ xver = @branch.split('.')
32
+ xver = "#{xver[0]}.#{xver[1]}.LATEST"
33
+ # Create the major.minor.X environment to go with the major.minor.patch environment
34
+ environment.name(xver.gsub('.', '_'))
35
+ environment.override_attributes({ :server_env => { :version => { :real => @branch, :virt => xver }}})
36
+ envfile = File.open("#{xver.gsub('.', '_')}.json", 'w')
37
+ envfile.write(environment.to_json)
38
+ envfile.close
39
+ end
40
+ end
41
+
42
+ def sanitize
43
+ if @branch =~ /\d+\.\d+\.\d+/
44
+ @branch.gsub('.','_')
45
+ else
46
+ @branch.gsub(/[\-;:,.\/\\']/,'_')
47
+ end
48
+ end
49
+
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: berks2env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pete Cheslock
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '11.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '11.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: berkshelf
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.21.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.21.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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
+ description: Convert a Berkshelf Lockfile to a Chef Environment json
84
+ email: petecheslock@gmail.com
85
+ executables:
86
+ - berks2env
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .rubocop.yml
91
+ - .travis.yml
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - berks2env.gemspec
98
+ - bin/berks2env
99
+ - lib/berks2env.rb
100
+ - lib/berks2env/version.rb
101
+ homepage: https://github.com/petecheslock/berks2env
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Convert a Berkshelf Lockfile to a Chef Environment json
125
+ test_files: []