knife-mirror 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -2
- data/lib/chef/knife/mirror.rb +21 -1
- data/lib/knife-mirror/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6959dcdea79bcf027844a95a0f6c256ed3077ca8
|
4
|
+
data.tar.gz: 93c33862179f3ba34e8827edfa79c72ad1513a2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac65600e7f31d661f19f4172835d1e5e7562b0f6aaa125e3216ea4cb40af04da5dc2dd79de51d359d9a125860677233970141234d6ccd448f1605f4bbe188448
|
7
|
+
data.tar.gz: fc84b432fd62a404b6d11e8556ef29cb82850efc11c91f763f5774da1a8a554c88bcae5d141ec55208d704ccc01b44a47c1b9ef0b8f6cb0ba807c7fee2c9d98a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,7 @@ oh, and, this is my first ever Gem, I don't have a clue what I'm doing...
|
|
18
18
|
- specify source and target Supermarkets
|
19
19
|
- save failed cookbook versions
|
20
20
|
- configurable delay to ease load on Supermarkets
|
21
|
+
- process cookbook direct dependencies as well
|
21
22
|
|
22
23
|
Most is based on working with diffs between source and target so we do not waste too many resources.
|
23
24
|
|
@@ -64,7 +65,7 @@ gem install knife-mirror
|
|
64
65
|
or obtain this source (git clone or whatever) and
|
65
66
|
|
66
67
|
```
|
67
|
-
gem build knife-mirror.gemspec; gem install knife-mirror-0.1.
|
68
|
+
gem build knife-mirror.gemspec; gem install knife-mirror-0.1.2.gem
|
68
69
|
```
|
69
70
|
|
70
71
|
## Use
|
@@ -82,6 +83,12 @@ Then things are really simple, while we still work on more advanced stuff:
|
|
82
83
|
knife mirror apt -t https://supermarket.your.domain.tld
|
83
84
|
```
|
84
85
|
|
86
|
+
### Only most recent version for a specific cookbook, plus its dependencies
|
87
|
+
|
88
|
+
```
|
89
|
+
knife mirror apt -t https://supermarket.your.domain.tld --deps
|
90
|
+
```
|
91
|
+
|
85
92
|
### Specific cookbook version
|
86
93
|
|
87
94
|
```
|
@@ -125,7 +132,6 @@ Wow, still lots to do, lots of wishes :(
|
|
125
132
|
- proper replication of deprecation flag (not honored as part of the cookbook meta upload)
|
126
133
|
- proper replication of urls (same reason)
|
127
134
|
- replicate (and create) categories?
|
128
|
-
- process dependencies
|
129
135
|
- process replacement in case we're mirroring a deprecated cookbook
|
130
136
|
- some automated testing
|
131
137
|
- more/better docs?
|
data/lib/chef/knife/mirror.rb
CHANGED
@@ -26,6 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
deps do
|
28
28
|
require 'chef/cookbook/metadata'
|
29
|
+
require 'chef/version_constraint'
|
29
30
|
require 'chef/cookbook_site_streaming_uploader'
|
30
31
|
end
|
31
32
|
|
@@ -56,7 +57,7 @@ class Chef
|
|
56
57
|
|
57
58
|
option :deps,
|
58
59
|
long: '--deps',
|
59
|
-
description: 'Also process cookbook(s) dependencies.
|
60
|
+
description: 'Also process cookbook(s) dependencies.'
|
60
61
|
|
61
62
|
option :reps,
|
62
63
|
long: '--reps',
|
@@ -111,6 +112,21 @@ class Chef
|
|
111
112
|
# Mirror just one single cookbook, latest version
|
112
113
|
ui.info("Mirroring #{@name_args[0]} (latest version).")
|
113
114
|
mirror_cookbook
|
115
|
+
if config[:deps]
|
116
|
+
ui.info('Mirroring dependencies as well...')
|
117
|
+
print "Fetching cookbook index from #{config[:supermarket_site]} (source)... "
|
118
|
+
universe = unauthenticated_get_rest("#{config[:supermarket_site]}/universe")
|
119
|
+
ui.info('Done!')
|
120
|
+
get_cookbook_version_meta['dependencies'].each do |cookbook, version_constraint|
|
121
|
+
universe[cookbook].sort_by { |version, _versionmeta| version.split('.').map(&:to_i) }.reverse!.each do |version, _versionmeta|
|
122
|
+
next unless Chef::VersionConstraint.new(version_constraint).include?(version)
|
123
|
+
ui.info("Most recent version matching constraint (#{version_constraint}) for cookbook #{cookbook}: #{version}")
|
124
|
+
mirror_cookbook(cookbook, version)
|
125
|
+
sleep(config[:delay].to_i) if config[:delay]
|
126
|
+
break
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
114
130
|
end
|
115
131
|
end
|
116
132
|
|
@@ -172,6 +188,10 @@ class Chef
|
|
172
188
|
end
|
173
189
|
end
|
174
190
|
|
191
|
+
def get_cookbook_version_meta(cookbook = @name_args[0], version = 'latest_version', api_url = "#{config[:supermarket_site]}/api/v1/cookbooks")
|
192
|
+
version == 'latest_version' ? unauthenticated_get_rest(get_cookbook_meta(cookbook, api_url)[version]) : unauthenticated_get_rest("#{api_url}/#{cookbook}/versions/#{version.gsub('.', '_')}")
|
193
|
+
end
|
194
|
+
|
175
195
|
def cookbook_deprecated?(cookbookmeta)
|
176
196
|
cookbookmeta['deprecated'] == true
|
177
197
|
end
|
data/lib/knife-mirror/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-mirror
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- G.J. Moed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|