simp-metadata 0.4.4 → 0.5.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 +5 -5
- data/README.md +494 -0
- data/Rakefile +19 -22
- data/exe/simp-install +1 -1
- data/exe/simp-media +1 -1
- data/exe/simp-metadata +1 -1
- data/lib/simp/install/command.rb +34 -35
- data/lib/simp/media.rb +0 -1
- data/lib/simp/media/command.rb +34 -35
- data/lib/simp/media/engine.rb +29 -35
- data/lib/simp/media/type.rb +1 -2
- data/lib/simp/media/type/base.rb +12 -4
- data/lib/simp/media/type/control-repo.rb +96 -107
- data/lib/simp/media/type/internet.rb +8 -8
- data/lib/simp/media/type/iso.rb +0 -1
- data/lib/simp/media/type/local.rb +18 -19
- data/lib/simp/media/type/tar.rb +37 -37
- data/lib/simp/metadata.rb +240 -258
- data/lib/simp/metadata/bootstrap_source.rb +93 -89
- data/lib/simp/metadata/buildinfo.rb +23 -23
- data/lib/simp/metadata/command.rb +60 -58
- data/lib/simp/metadata/commands.rb +1 -1
- data/lib/simp/metadata/commands/base.rb +28 -25
- data/lib/simp/metadata/commands/clone.rb +3 -5
- data/lib/simp/metadata/commands/component.rb +128 -90
- data/lib/simp/metadata/commands/delete.rb +4 -5
- data/lib/simp/metadata/commands/pry.rb +1 -3
- data/lib/simp/metadata/commands/release.rb +22 -23
- data/lib/simp/metadata/commands/releases.rb +1 -3
- data/lib/simp/metadata/commands/save.rb +10 -13
- data/lib/simp/metadata/commands/script.rb +11 -14
- data/lib/simp/metadata/commands/search.rb +15 -20
- data/lib/simp/metadata/commands/set-write-url.rb +1 -3
- data/lib/simp/metadata/commands/set-write.rb +1 -3
- data/lib/simp/metadata/commands/update.rb +9 -10
- data/lib/simp/metadata/component.rb +310 -154
- data/lib/simp/metadata/components.rb +15 -16
- data/lib/simp/metadata/engine.rb +31 -39
- data/lib/simp/metadata/fake_uri.rb +2 -0
- data/lib/simp/metadata/location.rb +99 -105
- data/lib/simp/metadata/locations.rb +19 -21
- data/lib/simp/metadata/release.rb +30 -39
- data/lib/simp/metadata/releases.rb +14 -15
- data/lib/simp/metadata/source.rb +69 -79
- data/lib/simp/metadata/version.rb +9 -0
- data/spec/simp/media/command_spec.rb +4 -5
- data/spec/simp/media/engine_spec.rb +14 -14
- data/spec/simp/media/type/control_repo_spec.rb +10 -12
- data/spec/simp/media/type/internet_spec.rb +11 -11
- data/spec/simp/media/type/iso_spec.rb +6 -7
- data/spec/simp/media/type/local_spec.rb +6 -8
- data/spec/simp/media/type/tar_spec.rb +6 -8
- data/spec/simp/metadata/buildinfo_spec.rb +19 -17
- data/spec/simp/metadata/commands/clone_spec.rb +4 -3
- data/spec/simp/metadata/component_spec.rb +43 -54
- data/spec/simp/metadata/engine_spec.rb +38 -41
- data/spec/simp/metadata/release_spec.rb +72 -79
- data/spec/simp/metadata/source_spec.rb +8 -6
- data/spec/simp/metadata_spec.rb +95 -98
- data/spec/spec_helper.rb +33 -21
- metadata +5 -3
@@ -10,45 +10,43 @@ module Simp
|
|
10
10
|
@component = component
|
11
11
|
end
|
12
12
|
|
13
|
-
def data
|
14
|
-
if
|
15
|
-
|
13
|
+
def data
|
14
|
+
if locationinfo['locations'].nil?
|
15
|
+
[locationinfo['primary_source']] + locationinfo['mirrors']
|
16
16
|
else
|
17
|
-
|
17
|
+
locationinfo['locations']
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def to_s
|
22
|
-
|
21
|
+
def to_s
|
22
|
+
data.to_s
|
23
23
|
end
|
24
24
|
|
25
|
-
def size
|
26
|
-
|
25
|
+
def size
|
26
|
+
data.size
|
27
27
|
end
|
28
28
|
|
29
|
-
def each
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
def each
|
30
|
+
data.each_index do |location|
|
31
|
+
yield self[location]
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def [](location)
|
36
|
-
Simp::Metadata::Location.new(locationinfo,data[location], component)
|
36
|
+
Simp::Metadata::Location.new(locationinfo, data[location], component)
|
37
37
|
end
|
38
38
|
|
39
39
|
def primary
|
40
|
-
|
41
|
-
retval
|
42
|
-
|
43
|
-
|
44
|
-
retval = Simp::Metadata::Location.new(self.locationinfo, self.locationinfo["primary_source"], component)
|
40
|
+
retval = find(&:primary)
|
41
|
+
if retval.nil?
|
42
|
+
if locationinfo.key?('primary_source')
|
43
|
+
retval = Simp::Metadata::Location.new(locationinfo, locationinfo['primary_source'], component)
|
45
44
|
else
|
46
|
-
retval =
|
45
|
+
retval = first
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
48
|
+
retval
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
54
|
-
|
@@ -14,48 +14,48 @@ module Simp
|
|
14
14
|
Simp::Metadata::Components.new(engine, version, type)
|
15
15
|
end
|
16
16
|
|
17
|
-
def puppetfile_component(component,
|
17
|
+
def puppetfile_component(component, _options)
|
18
18
|
contents = []
|
19
|
-
contents << "mod '#{component.name(
|
19
|
+
contents << "mod '#{component.name('puppetfile')}',"
|
20
20
|
contents << " :git => '#{component.primary.url}',"
|
21
|
-
if
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
contents <<
|
21
|
+
contents << if component.tag.nil?
|
22
|
+
" :ref => '#{component.ref}'"
|
23
|
+
else
|
24
|
+
" :tag => '#{component.tag}'"
|
25
|
+
end
|
26
|
+
contents << ''
|
27
27
|
contents
|
28
28
|
end
|
29
29
|
|
30
30
|
def puppetfile(options = {})
|
31
31
|
contents = []
|
32
|
-
if
|
32
|
+
if options['type'] == 'simp-core'
|
33
33
|
contents << "moduledir 'src'"
|
34
|
-
contents <<
|
34
|
+
contents << ''
|
35
35
|
contents << puppetfile_component(components['simp-doc'], options)
|
36
36
|
contents << "moduledir 'src/assets'"
|
37
|
-
contents <<
|
37
|
+
contents << ''
|
38
38
|
components.each do |component|
|
39
|
-
if
|
39
|
+
if component.component_type == 'rpm'
|
40
40
|
contents << puppetfile_component(component, options)
|
41
41
|
end
|
42
|
-
if
|
42
|
+
if component.component_type == 'rubygem'
|
43
43
|
contents << puppetfile_component(component, options)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
contents << "moduledir 'src/puppet/modules'"
|
47
|
-
contents <<
|
47
|
+
contents << ''
|
48
48
|
end
|
49
49
|
components.each do |component|
|
50
|
-
if
|
50
|
+
if component.component_type == 'puppet-module'
|
51
51
|
contents << puppetfile_component(component, options)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
contents.join("\n")
|
55
55
|
end
|
56
56
|
|
57
|
-
def to_s
|
58
|
-
|
57
|
+
def to_s
|
58
|
+
components.to_s
|
59
59
|
end
|
60
60
|
|
61
61
|
def diff(compare_release, attribute)
|
@@ -63,13 +63,11 @@ module Simp
|
|
63
63
|
|
64
64
|
current_hash = {}
|
65
65
|
compare_hash = {}
|
66
|
-
|
66
|
+
components.each do |comp|
|
67
67
|
self_component_hash = {}
|
68
68
|
comp.each do |key, value|
|
69
|
-
if
|
70
|
-
if
|
71
|
-
self_component_hash[key] = value.to_s
|
72
|
-
end
|
69
|
+
if !attribute.nil?
|
70
|
+
self_component_hash[key] = value.to_s if key.to_s == attribute
|
73
71
|
else
|
74
72
|
self_component_hash[key] = value.to_s
|
75
73
|
end
|
@@ -80,10 +78,8 @@ module Simp
|
|
80
78
|
compare_release.components.each do |comp|
|
81
79
|
self_component_hash = {}
|
82
80
|
comp.each do |key, value|
|
83
|
-
if
|
84
|
-
if
|
85
|
-
self_component_hash[key] = value.to_s
|
86
|
-
end
|
81
|
+
if !attribute.nil?
|
82
|
+
self_component_hash[key] = value.to_s if key.to_s == attribute
|
87
83
|
else
|
88
84
|
self_component_hash[key] = value.to_s
|
89
85
|
end
|
@@ -91,23 +87,18 @@ module Simp
|
|
91
87
|
end
|
92
88
|
end
|
93
89
|
current_hash.each do |comp, hash|
|
94
|
-
|
95
90
|
diff_hash = {}
|
96
91
|
hash.each do |key, value|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
unless diff_hash.empty?
|
107
|
-
diff[comp] = diff_hash
|
92
|
+
next unless compare_hash.key?(comp)
|
93
|
+
next unless compare_hash[comp][key] != value
|
94
|
+
diff_hash[key] = {
|
95
|
+
'original' => value.to_s,
|
96
|
+
'changed' => (compare_hash[comp][key]).to_s
|
97
|
+
}
|
108
98
|
end
|
99
|
+
diff[comp] = diff_hash unless diff_hash.empty?
|
109
100
|
end
|
110
|
-
|
101
|
+
diff
|
111
102
|
end
|
112
103
|
end
|
113
104
|
end
|
@@ -10,8 +10,8 @@ module Simp
|
|
10
10
|
@engine = engine
|
11
11
|
end
|
12
12
|
|
13
|
-
def each
|
14
|
-
|
13
|
+
def each
|
14
|
+
keys.each do |version|
|
15
15
|
yield self[version]
|
16
16
|
end
|
17
17
|
end
|
@@ -20,9 +20,9 @@ module Simp
|
|
20
20
|
Simp::Metadata::Release.new(engine, index)
|
21
21
|
end
|
22
22
|
|
23
|
-
def keys
|
23
|
+
def keys
|
24
24
|
result = {}
|
25
|
-
engine.sources.each do |
|
25
|
+
engine.sources.each do |_name, source|
|
26
26
|
source.releases.keys.each do |name|
|
27
27
|
result[name] = true
|
28
28
|
end
|
@@ -30,23 +30,23 @@ module Simp
|
|
30
30
|
result.keys
|
31
31
|
end
|
32
32
|
|
33
|
-
def size
|
34
|
-
|
33
|
+
def size
|
34
|
+
keys.size
|
35
35
|
end
|
36
36
|
|
37
|
-
def to_s
|
38
|
-
|
37
|
+
def to_s
|
38
|
+
keys.to_s
|
39
39
|
end
|
40
|
+
|
40
41
|
def delete(version)
|
41
|
-
engine.sources.each do |
|
42
|
-
if
|
43
|
-
metadata_source.delete_release(version)
|
44
|
-
end
|
42
|
+
engine.sources.each do |_name, metadata_source|
|
43
|
+
metadata_source.delete_release(version) if metadata_source.writable?
|
45
44
|
end
|
46
45
|
end
|
46
|
+
|
47
47
|
def create(destination, source = 'master')
|
48
|
-
engine.sources.each do |
|
49
|
-
if
|
48
|
+
engine.sources.each do |_name, metadata_source|
|
49
|
+
if metadata_source.writable?
|
50
50
|
metadata_source.create_release(destination, source)
|
51
51
|
end
|
52
52
|
end
|
@@ -54,4 +54,3 @@ module Simp
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
data/lib/simp/metadata/source.rb
CHANGED
@@ -4,7 +4,6 @@ require 'uri'
|
|
4
4
|
module Simp
|
5
5
|
module Metadata
|
6
6
|
class Source
|
7
|
-
|
8
7
|
attr_accessor :url
|
9
8
|
attr_accessor :cachepath
|
10
9
|
attr_accessor :components
|
@@ -18,17 +17,17 @@ module Simp
|
|
18
17
|
attr_accessor :engine
|
19
18
|
|
20
19
|
def initialize(args)
|
21
|
-
unless
|
22
|
-
raise
|
20
|
+
unless args.key?(:engine)
|
21
|
+
raise ':engine must be specified when initializing a metadata source'
|
23
22
|
end
|
24
|
-
unless
|
25
|
-
raise
|
23
|
+
unless args.key?(:name)
|
24
|
+
raise ':name must be specified when initializing a metadata source'
|
26
25
|
end
|
27
|
-
unless
|
28
|
-
raise
|
26
|
+
unless args.key?(:component)
|
27
|
+
raise ':component must be specified when initializing a metadata source'
|
29
28
|
end
|
30
|
-
unless
|
31
|
-
raise
|
29
|
+
unless args.key?(:edition)
|
30
|
+
raise ':edition must be specified when initializing a metadata source'
|
32
31
|
end
|
33
32
|
|
34
33
|
@engine = args[:engine]
|
@@ -36,11 +35,11 @@ module Simp
|
|
36
35
|
@component = args[:component]
|
37
36
|
@edition = args[:edition]
|
38
37
|
|
39
|
-
if
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
@url = if args[:url]
|
39
|
+
args[:url]
|
40
|
+
else
|
41
|
+
@component.primary.url
|
42
|
+
end
|
44
43
|
@write_url = @url
|
45
44
|
cachepath = args[:cachepath]
|
46
45
|
@components = {}
|
@@ -48,111 +47,107 @@ module Simp
|
|
48
47
|
@data = {}
|
49
48
|
@cleanup = []
|
50
49
|
|
51
|
-
if
|
52
|
-
@cachepath = Dir.mktmpdir(
|
50
|
+
if cachepath.nil?
|
51
|
+
@cachepath = Dir.mktmpdir('cachedir')
|
53
52
|
@cleanup << @cachepath
|
54
53
|
else
|
55
|
-
@cachepath = File.absolute_path(cachepath)
|
54
|
+
@cachepath = File.absolute_path(cachepath)
|
56
55
|
end
|
57
|
-
retval = Simp::Metadata.download_component(@component,
|
58
|
-
load_from_dir(retval[
|
56
|
+
retval = Simp::Metadata.download_component(@component, 'target' => @cachepath)
|
57
|
+
load_from_dir(retval['path'])
|
59
58
|
|
60
59
|
@dirty = false
|
61
60
|
end
|
62
61
|
|
63
|
-
def to_s
|
64
|
-
|
62
|
+
def to_s
|
63
|
+
name
|
65
64
|
end
|
66
65
|
|
67
|
-
def writable?
|
66
|
+
def writable?
|
68
67
|
true
|
69
68
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
|
70
|
+
attr_reader :write_url
|
71
|
+
|
73
72
|
def write_url=(value)
|
74
|
-
if
|
73
|
+
if value != @url
|
75
74
|
@write_url = value
|
76
75
|
FileUtils.rm_r("#{@cachepath}/#{@component.name}")
|
77
|
-
retval = Simp::Metadata.download_component(@component,
|
78
|
-
load_from_dir(retval[
|
76
|
+
retval = Simp::Metadata.download_component(@component, 'target' => @cachepath, 'url' => value)
|
77
|
+
load_from_dir(retval['path'])
|
79
78
|
end
|
80
79
|
end
|
80
|
+
|
81
81
|
def release(version)
|
82
|
-
if
|
83
|
-
|
82
|
+
if releases.key?(version)
|
83
|
+
releases[version]
|
84
84
|
else
|
85
85
|
{}
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
def delete_release(version)
|
90
|
-
if
|
90
|
+
if @releases.key?(version)
|
91
91
|
self.dirty = true
|
92
92
|
@releases.delete(version)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
def create_release(destination, source = 'master')
|
97
|
-
if
|
97
|
+
if @releases.key?(destination)
|
98
98
|
raise "destination version #{destination} already exists"
|
99
99
|
end
|
100
|
-
unless
|
100
|
+
unless @releases.key?(source)
|
101
101
|
raise "source version #{source} doesn't exist"
|
102
102
|
end
|
103
103
|
self.dirty = true
|
104
104
|
@releases[destination] = Marshal.load(Marshal.dump(@releases[source]))
|
105
105
|
end
|
106
106
|
|
107
|
-
def dirty?
|
107
|
+
def dirty?
|
108
108
|
@dirty
|
109
109
|
end
|
110
110
|
|
111
|
-
|
112
|
-
@dirty = value
|
113
|
-
end
|
111
|
+
attr_writer :dirty
|
114
112
|
|
115
|
-
def save(message =
|
116
|
-
if
|
113
|
+
def save(message = 'Auto-saving using simp-metadata')
|
114
|
+
if dirty?
|
117
115
|
puts @load_path
|
118
116
|
# XXX ToDo: Write files to yaml, commit and push (where appropriate)
|
119
117
|
|
120
|
-
|
121
|
-
|
122
118
|
Simp::Metadata.run("cd #{@load_path} && rm -rf v1")
|
123
119
|
FileUtils.mkdir_p("#{@load_path}/v1")
|
124
|
-
File.open("#{@load_path}/v1/components.yaml", 'w') {|file| file.write({
|
120
|
+
File.open("#{@load_path}/v1/components.yaml", 'w') { |file| file.write({ 'components' => @components }.to_yaml) }
|
125
121
|
@releases.each do |releasename, data|
|
126
|
-
directory =
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
122
|
+
directory = case releasename
|
123
|
+
when /.*-[Aa][Ll][Pp][Hh][Aa].*/
|
124
|
+
'prereleases'
|
125
|
+
when /.*-[Bb][Ee][Tt][Aa].*/
|
126
|
+
'prereleases'
|
127
|
+
when /.*-[Rr][Cc].*/
|
128
|
+
'prereleases'
|
129
|
+
when /^nightly-/
|
130
|
+
'nightlies'
|
131
|
+
when /develop/
|
132
|
+
'channels'
|
133
|
+
when /development/
|
134
|
+
'channels'
|
135
|
+
when /master/
|
136
|
+
'channels'
|
137
|
+
when /^test-/
|
138
|
+
'tests'
|
139
|
+
else
|
140
|
+
'releases'
|
141
|
+
end
|
147
142
|
FileUtils.mkdir_p("#{@load_path}/v1/#{directory}")
|
148
|
-
File.open("#{@load_path}/v1/#{directory}/#{releasename}.yaml", 'w') {|file| file.write({
|
143
|
+
File.open("#{@load_path}/v1/#{directory}/#{releasename}.yaml", 'w') { |file| file.write({ 'releases' => { releasename.to_s => data } }.to_yaml) }
|
149
144
|
end
|
150
145
|
Simp::Metadata.run("cd #{@load_path} && git remote add upstream #{write_url}")
|
151
146
|
Simp::Metadata.run("cd #{@load_path} && git remote set-url upstream #{write_url}")
|
152
147
|
exitcode = Simp::Metadata.run("cd #{@load_path} && git add -A && git commit -m '#{message}'; git push upstream master")
|
153
|
-
if
|
154
|
-
Simp::Metadata.critical(
|
155
|
-
raise
|
148
|
+
if exitcode != 0
|
149
|
+
Simp::Metadata.critical('error committing changes')
|
150
|
+
raise exitcode.to_s
|
156
151
|
else
|
157
152
|
puts "Successfully updated #{name}"
|
158
153
|
end
|
@@ -163,26 +158,22 @@ module Simp
|
|
163
158
|
def load_from_dir(path)
|
164
159
|
@load_path = path
|
165
160
|
Dir.chdir(path) do
|
166
|
-
Dir.glob(
|
161
|
+
Dir.glob('**/*.yaml') do |filename|
|
167
162
|
begin
|
168
163
|
hash = YAML.load_file(filename)
|
169
164
|
@data = deep_merge(@data, hash)
|
170
165
|
end
|
171
166
|
end
|
172
167
|
end
|
173
|
-
|
174
|
-
|
175
|
-
end
|
176
|
-
unless @data['components'] == nil
|
177
|
-
@components = @data['components']
|
178
|
-
end
|
168
|
+
@releases = @data['releases'] unless @data['releases'].nil?
|
169
|
+
@components = @data['components'] unless @data['components'].nil?
|
179
170
|
end
|
180
171
|
|
181
172
|
def deep_merge(target_hash, source_hash)
|
182
173
|
source_hash.each do |key, value|
|
183
|
-
if
|
184
|
-
if
|
185
|
-
|
174
|
+
if target_hash.key?(key)
|
175
|
+
if value.class == Hash
|
176
|
+
deep_merge(target_hash[key], value)
|
186
177
|
else
|
187
178
|
target_hash[key] = value
|
188
179
|
end
|
@@ -193,7 +184,7 @@ module Simp
|
|
193
184
|
target_hash
|
194
185
|
end
|
195
186
|
|
196
|
-
def cleanup
|
187
|
+
def cleanup
|
197
188
|
@cleanup.each do |path|
|
198
189
|
FileUtils.rmtree(path)
|
199
190
|
end
|
@@ -201,4 +192,3 @@ module Simp
|
|
201
192
|
end
|
202
193
|
end
|
203
194
|
end
|
204
|
-
|