supermarket_sync 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +25 -21
- data/lib/supermarket_sync/cli.rb +1 -0
- data/lib/supermarket_sync/config.rb +3 -0
- data/lib/supermarket_sync/sync.rb +10 -10
- data/lib/supermarket_sync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52a518a7503723522c18fbb65db7766c9188728a8421b64a28dda5e3b65b2433
|
4
|
+
data.tar.gz: 7bf193b9587237aed34ab1272114e4046da7dc7deab0d670a5075fcbca091d66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
-
|
17
|
+
* Supermarkets can be configured individually via the configuration file.
|
34
18
|
|
35
|
-
|
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
|
data/lib/supermarket_sync/cli.rb
CHANGED
@@ -38,7 +38,7 @@ module SupermarketSync
|
|
38
38
|
puts "Checking #{cookbook}"
|
39
39
|
# => Grab Source Metadata
|
40
40
|
source_meta = begin
|
41
|
-
|
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
|
-
{
|
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 =
|
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
|
-
|
116
|
-
dest
|
115
|
+
src context[:source] || Config.source
|
116
|
+
dest context[:url]
|
117
117
|
end
|
118
118
|
|
119
119
|
#
|
120
120
|
# => API Clients
|
121
121
|
#
|
122
|
-
|
123
|
-
url ||= @
|
122
|
+
def src(url = nil)
|
123
|
+
url ||= @src&.url
|
124
124
|
raise ArgumentError, 'No URL supplied!' unless url
|
125
|
-
return @
|
126
|
-
@
|
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)
|
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.
|
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-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|