simp-metadata 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +0 -0
- data/Rakefile +69 -0
- data/exe/simp-install +8 -0
- data/exe/simp-media +8 -0
- data/exe/simp-metadata +8 -0
- data/lib/simp/install.rb +0 -0
- data/lib/simp/install/command.rb +70 -0
- data/lib/simp/media.rb +9 -0
- data/lib/simp/media/command.rb +69 -0
- data/lib/simp/media/engine.rb +104 -0
- data/lib/simp/media/type.rb +14 -0
- data/lib/simp/media/type/base.rb +63 -0
- data/lib/simp/media/type/control-repo.rb +211 -0
- data/lib/simp/media/type/internet.rb +38 -0
- data/lib/simp/media/type/iso.rb +9 -0
- data/lib/simp/media/type/local.rb +36 -0
- data/lib/simp/media/type/tar.rb +71 -0
- data/lib/simp/metadata.rb +416 -0
- data/lib/simp/metadata/bootstrap_source.rb +137 -0
- data/lib/simp/metadata/buildinfo.rb +58 -0
- data/lib/simp/metadata/command.rb +92 -0
- data/lib/simp/metadata/commands.rb +21 -0
- data/lib/simp/metadata/commands/base.rb +65 -0
- data/lib/simp/metadata/commands/clone.rb +26 -0
- data/lib/simp/metadata/commands/component.rb +109 -0
- data/lib/simp/metadata/commands/delete.rb +26 -0
- data/lib/simp/metadata/commands/pry.rb +19 -0
- data/lib/simp/metadata/commands/release.rb +47 -0
- data/lib/simp/metadata/commands/releases.rb +24 -0
- data/lib/simp/metadata/commands/save.rb +33 -0
- data/lib/simp/metadata/commands/script.rb +38 -0
- data/lib/simp/metadata/commands/search.rb +65 -0
- data/lib/simp/metadata/commands/set-write-url.rb +19 -0
- data/lib/simp/metadata/commands/set-write.rb +19 -0
- data/lib/simp/metadata/commands/update.rb +46 -0
- data/lib/simp/metadata/component.rb +388 -0
- data/lib/simp/metadata/components.rb +70 -0
- data/lib/simp/metadata/engine.rb +101 -0
- data/lib/simp/metadata/fake_uri.rb +19 -0
- data/lib/simp/metadata/git_ssh_wrapper.sh +6 -0
- data/lib/simp/metadata/location.rb +198 -0
- data/lib/simp/metadata/locations.rb +54 -0
- data/lib/simp/metadata/release.rb +119 -0
- data/lib/simp/metadata/releases.rb +57 -0
- data/lib/simp/metadata/source.rb +204 -0
- data/spec/simp/media/command_spec.rb +12 -0
- data/spec/simp/media/engine_spec.rb +28 -0
- data/spec/simp/media/type/control_repo_spec.rb +23 -0
- data/spec/simp/media/type/internet_spec.rb +29 -0
- data/spec/simp/media/type/iso_spec.rb +15 -0
- data/spec/simp/media/type/local_spec.rb +16 -0
- data/spec/simp/media/type/tar_spec.rb +16 -0
- data/spec/simp/metadata/buildinfo_spec.rb +64 -0
- data/spec/simp/metadata/commands/clone_spec.rb +8 -0
- data/spec/simp/metadata/component_spec.rb +90 -0
- data/spec/simp/metadata/engine_spec.rb +70 -0
- data/spec/simp/metadata/release_spec.rb +104 -0
- data/spec/simp/metadata/source_spec.rb +25 -0
- data/spec/simp/metadata_spec.rb +175 -0
- data/spec/spec_helper.rb +40 -0
- metadata +260 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Delete < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do | opts|
|
9
|
+
opts.banner = "Usage: simp-metadata delete <component_name>"
|
10
|
+
end
|
11
|
+
|
12
|
+
engine, root = get_engine(engine, options)
|
13
|
+
begin
|
14
|
+
engine.releases.delete(argv[0])
|
15
|
+
if (root == true)
|
16
|
+
engine.save((["simp-metadata", "delete"] + argv).join(" "))
|
17
|
+
end
|
18
|
+
rescue RuntimeError => e
|
19
|
+
Simp::Metadata.critical(e.message)
|
20
|
+
exit 5
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Pry < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do |opts|
|
9
|
+
opts.banner = "Usage: simp-metadata pry"
|
10
|
+
end
|
11
|
+
|
12
|
+
engine, root = get_engine(engine, options)
|
13
|
+
require 'pry'
|
14
|
+
binding.pry
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Release < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do |opts|
|
9
|
+
opts.banner = "Usage: simp-metadata release <release_name> [components]"
|
10
|
+
opts.banner = " simp-metadata release diff <release1> <release2>"
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
engine, root = get_engine(engine, options)
|
15
|
+
begin
|
16
|
+
section = argv[0]
|
17
|
+
case section
|
18
|
+
when "components"
|
19
|
+
puts engine.releases[options["release"]].components.keys.join("\n")
|
20
|
+
|
21
|
+
when "puppetfile"
|
22
|
+
type = argv[1]
|
23
|
+
puts engine.releases[options["release"]].puppetfile({ "type" => type})
|
24
|
+
|
25
|
+
when "diff"
|
26
|
+
release1 = argv[1]
|
27
|
+
release2 = argv[2]
|
28
|
+
attribute = argv[3]
|
29
|
+
release1 = engine.releases[release1]
|
30
|
+
release2 = engine.releases[release2]
|
31
|
+
diff = release1.diff(release2, attribute)
|
32
|
+
puts diff.to_yaml
|
33
|
+
else
|
34
|
+
puts "components:"
|
35
|
+
engine.releases[options["release"]].components.keys.each do |line|
|
36
|
+
puts " #{line}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
rescue RuntimeError => e
|
40
|
+
Simp::Metadata.critical(e.message)
|
41
|
+
exit 5
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Releases < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do |opts|
|
9
|
+
opts.banner = "Usage: simp-metadata releases"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
engine, root = get_engine(engine, options)
|
14
|
+
begin
|
15
|
+
puts engine.releases.keys
|
16
|
+
rescue RuntimeError => e
|
17
|
+
Simp::Metadata.critical(e.message)
|
18
|
+
exit 5
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Save < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do |opts|
|
9
|
+
opts.banner = "Usage: simp-metadata save [options] [message]"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
engine, root = get_engine(engine, options)
|
14
|
+
if (argv.size == 0)
|
15
|
+
short = "Auto-saving using simp-metadata"
|
16
|
+
else
|
17
|
+
short = argv.join(" ")
|
18
|
+
end
|
19
|
+
if ($commandqueue != nil)
|
20
|
+
message = []
|
21
|
+
while $commandqueue.empty?() == false
|
22
|
+
message << $commandqueue.pop
|
23
|
+
end
|
24
|
+
puts message
|
25
|
+
engine.save("#{short}\n\nsimp-metadata log:\n #{message.join("\n ")}")
|
26
|
+
else
|
27
|
+
engine.save(short)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require_relative '../commands'
|
3
|
+
|
4
|
+
module Simp
|
5
|
+
module Metadata
|
6
|
+
module Commands
|
7
|
+
class Script < Simp::Metadata::Commands::Base
|
8
|
+
def run(argv, engine = nil)
|
9
|
+
|
10
|
+
options = defaults(argv) do |opts|
|
11
|
+
opts.banner = "Usage: simp-metadata script [options] <filename>"
|
12
|
+
end
|
13
|
+
|
14
|
+
$commandqueue = Queue.new();
|
15
|
+
|
16
|
+
engine, root = get_engine(engine, options)
|
17
|
+
unless (argv[0] != nil)
|
18
|
+
Simp::Metadata.critical("filename must be specified")
|
19
|
+
exit 3
|
20
|
+
end
|
21
|
+
data = File.read(argv[0])
|
22
|
+
lines = data.split("\n")
|
23
|
+
lines.each do |line|
|
24
|
+
temp_argv = line.split(" ")
|
25
|
+
unless (temp_argv.size == 0)
|
26
|
+
unless (temp_argv[0] =~ /^#/)
|
27
|
+
$commandqueue.push(line);
|
28
|
+
command = Module.const_get("Simp::Metadata::Commands::#{temp_argv[0].gsub("-","_").capitalize}").new()
|
29
|
+
temp_argv.shift
|
30
|
+
command.run(temp_argv, engine)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require_relative '../commands'
|
3
|
+
|
4
|
+
module Simp
|
5
|
+
module Metadata
|
6
|
+
module Commands
|
7
|
+
class Search < Simp::Metadata::Commands::Base
|
8
|
+
|
9
|
+
def run(argv, engine = nil)
|
10
|
+
|
11
|
+
options = defaults(argv) do |opts|
|
12
|
+
opts.banner = "Usage: simp-metadata search <attribute>=<value>\n(supports multiple attributes as well as encoded URLs)"
|
13
|
+
end
|
14
|
+
|
15
|
+
engine, root = get_engine(engine, options)
|
16
|
+
begin
|
17
|
+
data = {}
|
18
|
+
argv.each do |argument|
|
19
|
+
splitted = argument.split("=")
|
20
|
+
name = splitted[0]
|
21
|
+
value = splitted[1]
|
22
|
+
case name
|
23
|
+
when name
|
24
|
+
data[name] = value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
unless (data == {}) or data.nil?
|
28
|
+
data.each do |key, value|
|
29
|
+
if value == "" or value.nil?
|
30
|
+
puts "No value specified for #{key}"
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
engine.components.each do |component|
|
35
|
+
|
36
|
+
result = data.all? do |key, value|
|
37
|
+
if key == "url"
|
38
|
+
component.locations.any? do |location|
|
39
|
+
location.url == value or location.url == CGI.unescape(value)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
component[key] == value or component[key] == CGI.unescape(value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if result
|
47
|
+
puts component.name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
else
|
51
|
+
puts "No search parameters specified"
|
52
|
+
end
|
53
|
+
if (root == true)
|
54
|
+
engine.save
|
55
|
+
end
|
56
|
+
rescue RuntimeError => e
|
57
|
+
Simp::Metadata.critical(e.message)
|
58
|
+
exit 5
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Set_write_url < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do |opts|
|
9
|
+
opts.banner = "Usage: simp-metadata set-write-url <repo_name> <url>"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
engine, root = get_engine(engine, options)
|
14
|
+
engine.writable_url(argv[0], argv[1])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Set_write < Simp::Metadata::Commands::Base
|
6
|
+
def run(argv, engine = nil)
|
7
|
+
|
8
|
+
options = defaults(argv) do |opts|
|
9
|
+
opts.banner = "Usage: simp-metadata set-write [options]"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
engine, root = get_engine(engine, options)
|
14
|
+
engine.writable_source_name = argv[0]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../commands'
|
2
|
+
module Simp
|
3
|
+
module Metadata
|
4
|
+
module Commands
|
5
|
+
class Update < Simp::Metadata::Commands::Base
|
6
|
+
|
7
|
+
def run(argv, engine = nil)
|
8
|
+
|
9
|
+
options = defaults(argv) do |opts|
|
10
|
+
opts.banner = "Usage: simp-metadata update <component> <setting> <value>"
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
engine, root = get_engine(engine, options)
|
15
|
+
begin
|
16
|
+
component = argv[0]
|
17
|
+
setting = argv[1]
|
18
|
+
value = argv[2]
|
19
|
+
if (options["release"] == nil)
|
20
|
+
object = engine.components[component]
|
21
|
+
else
|
22
|
+
object = engine.releases[options["release"]].components[component]
|
23
|
+
end
|
24
|
+
unless (object.methods.include?(setting.to_sym))
|
25
|
+
Simp::Metadata.critical("#{setting} is not a valid setting")
|
26
|
+
exit 7
|
27
|
+
end
|
28
|
+
begin
|
29
|
+
object.send("#{setting}=".to_sym, value)
|
30
|
+
rescue NoMethodError => ex
|
31
|
+
Simp::Metadata.critical("#{setting} is a read-only setting")
|
32
|
+
exit 6
|
33
|
+
end
|
34
|
+
|
35
|
+
if (root == true)
|
36
|
+
engine.save((["simp-metadata", "update"] + argv).join(" "))
|
37
|
+
end
|
38
|
+
rescue RuntimeError => e
|
39
|
+
Simp::Metadata.critical(e.message)
|
40
|
+
exit 5
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,388 @@
|
|
1
|
+
module Simp
|
2
|
+
module Metadata
|
3
|
+
class Component
|
4
|
+
include Enumerable
|
5
|
+
attr_accessor :engine
|
6
|
+
attr_accessor :release_version
|
7
|
+
|
8
|
+
def initialize(engine, name, version)
|
9
|
+
@engine = engine
|
10
|
+
@name = name
|
11
|
+
@release_version = version
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
self.name
|
16
|
+
end
|
17
|
+
|
18
|
+
def name(type = "component")
|
19
|
+
case type
|
20
|
+
when "component"
|
21
|
+
@name
|
22
|
+
when "puppetfile"
|
23
|
+
if (component_type == "rubygem")
|
24
|
+
"rubygem-#{@name.gsub(/\-/, '_')}"
|
25
|
+
elsif (component_type == "puppet-module")
|
26
|
+
@name.gsub(/pupmod\-/, '')
|
27
|
+
else
|
28
|
+
@name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def component_source()
|
34
|
+
retval = engine.sources["bootstrap_metadata"]
|
35
|
+
engine.sources.each do |name, source|
|
36
|
+
if (source.components != nil)
|
37
|
+
if (source.components.key?(self.name))
|
38
|
+
retval = source
|
39
|
+
break
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
return retval
|
44
|
+
end
|
45
|
+
|
46
|
+
def release_source()
|
47
|
+
retval = engine.sources["bootstrap_metadata"]
|
48
|
+
engine.sources.each do |name, source|
|
49
|
+
if (source.releases.key?(release_version))
|
50
|
+
if (source.releases[release_version].key?(self.name))
|
51
|
+
retval = source
|
52
|
+
break
|
53
|
+
end
|
54
|
+
else
|
55
|
+
if (source.release(release_version).key?(self.name))
|
56
|
+
retval = source
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
return retval
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Will be used to grab method based data in the future, rather
|
66
|
+
# then calling get_from_release or get_from_component directly,
|
67
|
+
#
|
68
|
+
# For now, just use it in Simp::Metadata::Buildinfo
|
69
|
+
def fetch_data(item)
|
70
|
+
component = get_from_component
|
71
|
+
release = get_from_release
|
72
|
+
if (release.key?(item))
|
73
|
+
release[item]
|
74
|
+
else
|
75
|
+
component[item]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_from_component()
|
80
|
+
return self.component_source.components[self.name]
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_from_release()
|
84
|
+
retval = {}
|
85
|
+
if (self.release_source.releases.key?(release_version))
|
86
|
+
if (self.release_source.releases[release_version].key?(self.name))
|
87
|
+
retval = self.release_source.releases[release_version][self.name]
|
88
|
+
end
|
89
|
+
else
|
90
|
+
if (self.release_source.release(release_version).key?(self.name))
|
91
|
+
retval = self.release_source.release(release_version)[self.name]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
return retval
|
95
|
+
end
|
96
|
+
|
97
|
+
def type
|
98
|
+
get_from_component["type"]
|
99
|
+
end
|
100
|
+
|
101
|
+
def extension
|
102
|
+
if (self.real_extension == nil)
|
103
|
+
case (self.component_type)
|
104
|
+
when "simp-metadata"
|
105
|
+
"tgz"
|
106
|
+
when "logstash-filter"
|
107
|
+
"gem"
|
108
|
+
when "rubygem"
|
109
|
+
"gem"
|
110
|
+
when "grafana-plugin"
|
111
|
+
"zip"
|
112
|
+
when "puppet-module"
|
113
|
+
"tgz"
|
114
|
+
else
|
115
|
+
""
|
116
|
+
end
|
117
|
+
else
|
118
|
+
self.real_extension
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def keys()
|
123
|
+
["component_type", "authoritative", "asset_name", "extension", "format", "module_name", "type", "url", "method", "extract", "branch", "tag", "ref", "version", "release_source", "component_source"]
|
124
|
+
end
|
125
|
+
|
126
|
+
def [] (index)
|
127
|
+
self.send index.to_sym
|
128
|
+
end
|
129
|
+
|
130
|
+
def each(&block)
|
131
|
+
self.keys.each do |key|
|
132
|
+
yield key, self[key]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def real_extension
|
137
|
+
get_from_component["extension"]
|
138
|
+
end
|
139
|
+
|
140
|
+
def real_asset_name
|
141
|
+
case self.component_type
|
142
|
+
when "puppet-module"
|
143
|
+
get_from_component["module_name"]
|
144
|
+
when "rubygem"
|
145
|
+
get_from_component["gem_name"]
|
146
|
+
else
|
147
|
+
get_from_component["asset_name"]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def module_name
|
152
|
+
asset_name
|
153
|
+
end
|
154
|
+
|
155
|
+
def asset_name
|
156
|
+
if (self.real_asset_name == nil)
|
157
|
+
case self.component_type
|
158
|
+
when "puppet-module"
|
159
|
+
splitted = self.name.split("-")
|
160
|
+
splitted[splitted.size - 1]
|
161
|
+
else
|
162
|
+
self.name
|
163
|
+
end
|
164
|
+
else
|
165
|
+
self.real_asset_name
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
def output_type
|
171
|
+
if (self.compiled?)
|
172
|
+
return :file
|
173
|
+
else
|
174
|
+
return :directory
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def output_filename
|
179
|
+
if (self.compiled?)
|
180
|
+
return "#{self.name}-#{self.version}.#{self.extension}"
|
181
|
+
else
|
182
|
+
return self.name
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def primary
|
187
|
+
self.locations.primary
|
188
|
+
end
|
189
|
+
|
190
|
+
def url
|
191
|
+
self.locations.primary.url
|
192
|
+
end
|
193
|
+
|
194
|
+
def method
|
195
|
+
self.locations.primary.method
|
196
|
+
end
|
197
|
+
|
198
|
+
def extract
|
199
|
+
self.locations.primary.extract
|
200
|
+
end
|
201
|
+
|
202
|
+
def locations
|
203
|
+
# XXX: ToDo Allow manifest.yaml to override locations
|
204
|
+
# XXX: ToDo Use primary_source and mirrors here if locations is empty
|
205
|
+
Simp::Metadata::Locations.new({"locations" => get_from_component["locations"], "primary_source" => get_from_component["primary_source"], "mirrors" => get_from_component["mirrors"]}, self)
|
206
|
+
end
|
207
|
+
|
208
|
+
# XXX: ToDo Generate a filename, and output file type; ie, directory or file
|
209
|
+
|
210
|
+
|
211
|
+
def format
|
212
|
+
get_from_component["format"]
|
213
|
+
end
|
214
|
+
|
215
|
+
def component_type
|
216
|
+
get_from_component["component-type"]
|
217
|
+
end
|
218
|
+
|
219
|
+
def authoritative?
|
220
|
+
get_from_component["authoritative"]
|
221
|
+
end
|
222
|
+
|
223
|
+
def authoritative
|
224
|
+
get_from_component["authoritative"]
|
225
|
+
end
|
226
|
+
|
227
|
+
def ref
|
228
|
+
get_from_release["ref"]
|
229
|
+
end
|
230
|
+
|
231
|
+
def ref=(value)
|
232
|
+
release = self.release_source.releases[release_version]
|
233
|
+
if (release != nil)
|
234
|
+
if (release.key?(name))
|
235
|
+
release[name]["ref"] = value
|
236
|
+
else
|
237
|
+
release[name] = {"ref" => value}
|
238
|
+
end
|
239
|
+
end
|
240
|
+
self.release_source.dirty = true
|
241
|
+
end
|
242
|
+
|
243
|
+
def branch
|
244
|
+
get_from_release["branch"]
|
245
|
+
end
|
246
|
+
|
247
|
+
def branch=(value)
|
248
|
+
release = self.release_source.releases[release_version]
|
249
|
+
if (release != nil)
|
250
|
+
if (release.key?(name))
|
251
|
+
release[name]["branch"] = value
|
252
|
+
else
|
253
|
+
release[name] = {"branch" => value}
|
254
|
+
end
|
255
|
+
end
|
256
|
+
self.release_source.dirty = true
|
257
|
+
end
|
258
|
+
|
259
|
+
def tag
|
260
|
+
get_from_release["tag"]
|
261
|
+
end
|
262
|
+
|
263
|
+
def tag=(value)
|
264
|
+
release = self.release_source.releases[release_version]
|
265
|
+
if (release != nil)
|
266
|
+
if (release.key?(name))
|
267
|
+
release[name]["tag"] = value
|
268
|
+
else
|
269
|
+
release[name] = {"tag" => value}
|
270
|
+
end
|
271
|
+
end
|
272
|
+
self.release_source.dirty = true
|
273
|
+
end
|
274
|
+
|
275
|
+
def version
|
276
|
+
ver = ""
|
277
|
+
["version", "tag", "ref", "branch"].each do |item|
|
278
|
+
if (get_from_release[item] != nil)
|
279
|
+
ver = get_from_release[item]
|
280
|
+
break
|
281
|
+
end
|
282
|
+
end
|
283
|
+
return ver
|
284
|
+
end
|
285
|
+
|
286
|
+
def rpm_basename
|
287
|
+
if component_type == 'puppet-module'
|
288
|
+
if name.match(/pupmod-*/)
|
289
|
+
"#{name}"
|
290
|
+
else
|
291
|
+
"pupmod-#{name}"
|
292
|
+
end
|
293
|
+
else
|
294
|
+
"#{name}"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
def rpm_version
|
299
|
+
if version.match(/[v][0-9]+.[0-9]+.[0-9]+/)
|
300
|
+
version.split('v')[1]
|
301
|
+
else
|
302
|
+
version
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
def rpm_name
|
307
|
+
"#{rpm_basename}-#{rpm_version}.rpm"
|
308
|
+
end
|
309
|
+
|
310
|
+
def compiled?
|
311
|
+
if get_from_release.key?("compiled")
|
312
|
+
get_from_release["compiled"]
|
313
|
+
else
|
314
|
+
false
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
def binaryname
|
319
|
+
"#{asset_name}-#{version}.#{extension}"
|
320
|
+
end
|
321
|
+
|
322
|
+
def view(attribute)
|
323
|
+
comp = self
|
324
|
+
view_hash = {}
|
325
|
+
if attribute.nil?
|
326
|
+
comp.each do |key, value|
|
327
|
+
unless value.nil? or value == ""
|
328
|
+
view_hash[key] = value.to_s
|
329
|
+
end
|
330
|
+
end
|
331
|
+
location_hash = {}
|
332
|
+
comp.locations.each do |location|
|
333
|
+
location.each do |key, value|
|
334
|
+
unless value.nil?
|
335
|
+
location_hash.merge!(key => value.to_s)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
buildinfo_hash = {}
|
340
|
+
comp.buildinfo.each do |buildinfo|
|
341
|
+
buildinfo.each do |key, value|
|
342
|
+
end
|
343
|
+
end
|
344
|
+
view_hash['location'] = location_hash
|
345
|
+
else
|
346
|
+
view_hash[attribute] = comp[attribute].to_s
|
347
|
+
end
|
348
|
+
return view_hash
|
349
|
+
end
|
350
|
+
|
351
|
+
def diff(component, attribute)
|
352
|
+
diff = {}
|
353
|
+
|
354
|
+
if attribute.nil?
|
355
|
+
current_hash = {}
|
356
|
+
comp_hash = {}
|
357
|
+
self.each do |attribute, value|
|
358
|
+
current_hash.merge!(attribute => value)
|
359
|
+
end
|
360
|
+
component.each do |attribute, value|
|
361
|
+
comp_hash.merge!(attribute => value)
|
362
|
+
end
|
363
|
+
unless current_hash == comp_hash
|
364
|
+
current_hash.each do |attribute, value|
|
365
|
+
diff[attribute] = {"original" => "#{current_hash[attribute]}",
|
366
|
+
"changed" => "#{comp_hash[attribute]}"} if comp_hash[attribute] != value
|
367
|
+
end
|
368
|
+
end
|
369
|
+
return diff
|
370
|
+
else
|
371
|
+
v1 = self["#{attribute}"]
|
372
|
+
v2 = component["#{attribute}"]
|
373
|
+
unless (v1 == v2)
|
374
|
+
diff[attribute] = {"original" => "#{v1}", "changed" => "#{v2}"}
|
375
|
+
return diff
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
def buildinfo(type = nil)
|
380
|
+
if (type == nil)
|
381
|
+
{}
|
382
|
+
else
|
383
|
+
Simp::Metadata::Buildinfo.new(self, type)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|