supermarket_sync 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 818056b410af5497f35e4e401e0d527890627e1be89b43733c8c2572b20fecd1
4
- data.tar.gz: c003e878b9c3986ac4d1996ca37a097af0133475c3913add3c16a5b8b564f0b4
3
+ metadata.gz: 52a518a7503723522c18fbb65db7766c9188728a8421b64a28dda5e3b65b2433
4
+ data.tar.gz: 7bf193b9587237aed34ab1272114e4046da7dc7deab0d670a5075fcbca091d66
5
5
  SHA512:
6
- metadata.gz: e5063cfe32685f9f93794fa626608963d2aa1432749f9406d6a6ba5b84492384ccec8e4dd16c089a06200e881237a9da9fe8933da4d230ca91e646b6bc3cb018
7
- data.tar.gz: 9b12d8f1b4dceda17a36783eae45004bd9ff3fa7644ff35e8ab503edba66ad640478432f6a0457723612e66f9bd4cb6c3951c9c190abac5b1f7c271b2f64ac23
6
+ metadata.gz: 4d1b8edab2bf62739d39ea24a1b5b984043118548c54d3827a875316bacde7f347df17f463931ac026407069597599a665e161a918b86822d6008b3bd7f458b8
7
+ data.tar.gz: 2a550526c4a2e07b7c185bc81bb92c57b571bab389612b69d7057322b95642d49541ca510bb15c18c96a1f00f66c6f214293d8da106ea983d544f0dbc746c70a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@ SupermarketSync Changelog
2
2
  =========================
3
3
  This file is used to list changes made in each version of the `supermarket_sync` gem.
4
4
 
5
+ v0.1.1 (2016-11-12)
6
+ -------------------
7
+ - Fix for non-existing cookbooks
8
+ - Rename function to avoid potential namespace collision
9
+ - Add a read-only mode for testing purposes
10
+
5
11
  v0.1.0 (2016-11-09)
6
12
  -------------------
7
- - Initial Release TBD
13
+ - Initial Release
data/README.md CHANGED
@@ -2,25 +2,9 @@
2
2
  * Ruby Gem to programmatically synchronize Chef Supermarkets
3
3
 
4
4
  ## Background
5
- This gem was built from a need to synchronize a private, internal Chef Supermarket from the Public Chef Supermarket.
5
+ This gem was built from a need to synchronize approved cookbooks to a private, internal Chef Supermarket from the Public Chef Supermarket.
6
6
 
7
- At the same time, being able to send notifications of changes and deprecations was also desired.
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'supermarket_sync'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install supermarket_sync
7
+ It was also desired to send notifications upon changes and deprecations.
24
8
 
25
9
  ## Usage
26
10
 
@@ -30,15 +14,21 @@ Usage: supermarket_sync (options)
30
14
  --cookbooks-json CONFIG List of cookbooks to synchronize
31
15
  ```
32
16
 
33
- You can supply individual configuration for supermarkets invidivually via the configuration file.
17
+ * Supermarkets can be configured individually via the configuration file.
34
18
 
35
- Otherwise, you can configure global Chef parameters via environment variables. This may prove handy in a CI pipeline scenario.
19
+ * If left unspecified, global Supermarket parameters can be passed in via environment variables.
36
20
 
37
21
  ```
22
+ # Set Supermarket Globals
38
23
  export SM_USER='supermarket_user'
39
24
  export SM_KEY='/path/to/my/key.pem'
25
+
26
+ # Sync the Supermarkets
27
+ supermarket_sync -c config.json --cookbooks-json cookbooks.json
40
28
  ```
41
29
 
30
+ * Slack notifications are optional and can be configured via notification hash in `config.json`.
31
+
42
32
  #### Configuration Samples
43
33
 
44
34
  `config.json`
@@ -77,7 +67,21 @@ export SM_KEY='/path/to/my/key.pem'
77
67
  }
78
68
  ```
79
69
 
80
- ####
70
+ ## Installation
71
+
72
+ Add this line to your application's Gemfile:
73
+
74
+ ```ruby
75
+ gem 'supermarket_sync'
76
+ ```
77
+
78
+ And then execute:
79
+
80
+ $ bundle
81
+
82
+ Or install it yourself as:
83
+
84
+ $ gem install supermarket_sync
81
85
 
82
86
 
83
87
  ## Development
@@ -60,6 +60,7 @@ module SupermarketSync
60
60
  cfg.notification = config[:notification]
61
61
  cfg.supermarkets = config[:supermarkets]
62
62
  cfg.source = config[:source]
63
+ cfg.read_only = config[:read_only]
63
64
  end
64
65
 
65
66
  # => Start the Sync
@@ -44,6 +44,9 @@ module SupermarketSync
44
44
  user: ENV['SM_USER'],
45
45
  key: ENV['SM_KEY']
46
46
 
47
+ # => Read-Only Mode
48
+ define_setting :read_only, ENV['SM_SYNC_READONLY']
49
+
47
50
  #
48
51
  # Facilitate Dynamic Addition of Configuration Values
49
52
  #
@@ -38,7 +38,7 @@ module SupermarketSync
38
38
  puts "Checking #{cookbook}"
39
39
  # => Grab Source Metadata
40
40
  source_meta = begin
41
- source.get("/api/v1/cookbooks/#{cookbook}")
41
+ src.get("/api/v1/cookbooks/#{cookbook}")
42
42
  rescue Net::HTTPServerException => e
43
43
  raise e unless e.response.code == '404'
44
44
  puts 'Cookbook not available on Source Supermarket'
@@ -53,7 +53,7 @@ module SupermarketSync
53
53
  rescue Net::HTTPServerException => e
54
54
  raise e unless e.response.code == '404'
55
55
  # => Cookbook not found -- Initial Upload
56
- {}['latest_version'] = '0.0.0'
56
+ { 'latest_version' => '0.0.0' }
57
57
  end
58
58
  # => Determine Current Version
59
59
  current = ::Gem::Version.new(::File.basename(dest_meta['latest_version']))
@@ -64,10 +64,10 @@ module SupermarketSync
64
64
  puts "Destination: #{current}"
65
65
 
66
66
  # => Retrieve the Cookbook
67
- tgz = source.streaming_request("/api/v1/cookbooks/#{cookbook}/versions/#{latest}/download")
67
+ tgz = src.streaming_request("/api/v1/cookbooks/#{cookbook}/versions/#{latest}/download")
68
68
 
69
69
  # => Upload the Cookbook
70
- upload(source_meta['category'], tgz)
70
+ upload(source_meta['category'], tgz) unless Config.read_only
71
71
 
72
72
  # => Remove the Tempfile
73
73
  begin
@@ -112,18 +112,18 @@ module SupermarketSync
112
112
  end
113
113
  end
114
114
 
115
- source context[:source] || Config.source
116
- dest context[:url]
115
+ src context[:source] || Config.source
116
+ dest context[:url]
117
117
  end
118
118
 
119
119
  #
120
120
  # => API Clients
121
121
  #
122
- private def source(url = nil)
123
- url ||= @source&.url
122
+ def src(url = nil)
123
+ url ||= @src&.url
124
124
  raise ArgumentError, 'No URL supplied!' unless url
125
- return @source if @source&.url == url
126
- @source = Chef::HTTP::SimpleJSON.new(url)
125
+ return @src if @src&.url == url
126
+ @src = Chef::HTTP::SimpleJSON.new(url)
127
127
  end
128
128
 
129
129
  private def dest(url = nil)
@@ -1,3 +1,3 @@
1
1
  module SupermarketSync
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supermarket_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dwyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-10 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef