simp-metadata 0.4.4 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -4,7 +4,6 @@ require 'uri'
|
|
4
4
|
module Simp
|
5
5
|
module Metadata
|
6
6
|
class Bootstrap_source
|
7
|
-
|
8
7
|
attr_accessor :url
|
9
8
|
attr_accessor :cachepath
|
10
9
|
attr_accessor :components
|
@@ -20,118 +19,123 @@ module Simp
|
|
20
19
|
@edition = edition
|
21
20
|
|
22
21
|
case edition
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
22
|
+
when 'enterprise'
|
23
|
+
@data = {
|
24
|
+
'components' => {
|
25
|
+
'enterprise-metadata' => {
|
26
|
+
'component-type' => 'simp-metadata',
|
27
|
+
'authoritative' => true,
|
28
|
+
'locations' => [
|
29
|
+
{
|
30
|
+
'url' => 'simp-enterprise:///enterprise-metadata?version=master&filetype=tgz',
|
31
|
+
'method' => 'file',
|
32
|
+
'extract' => true,
|
33
|
+
'primary' => true
|
34
|
+
}
|
35
|
+
]
|
36
|
+
},
|
37
|
+
'simp-metadata' => {
|
38
|
+
'component-type' => 'simp-metadata',
|
39
|
+
'authoritative' => true,
|
40
|
+
'locations' => [
|
41
|
+
{
|
42
|
+
'url' => 'https://github.com/simp/simp-metadata',
|
43
|
+
'method' => 'git',
|
44
|
+
'primary' => true
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
50
48
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
49
|
+
}
|
50
|
+
when 'enterprise-only'
|
51
|
+
@data = {
|
52
|
+
'components' => {
|
53
|
+
'enterprise-metadata' => {
|
54
|
+
'component-type' => 'simp-metadata',
|
55
|
+
'authoritative' => true,
|
56
|
+
'locations' => [
|
57
|
+
{
|
58
|
+
'url' => 'simp-enterprise:///enterprise-metadata?version=master&filetype=tgz',
|
59
|
+
'method' => 'file',
|
60
|
+
'extract' => true,
|
61
|
+
'primary' => true
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
67
65
|
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
66
|
+
}
|
67
|
+
else
|
68
|
+
@data = {
|
69
|
+
'components' => {
|
70
|
+
'simp-metadata' => {
|
71
|
+
'component-type' => 'simp-metadata',
|
72
|
+
'authoritative' => true,
|
73
|
+
'locations' => [
|
74
|
+
{
|
75
|
+
'url' => 'https://github.com/simp/simp-metadata',
|
76
|
+
'method' => 'git',
|
77
|
+
'primary' => true
|
78
|
+
}
|
79
|
+
]
|
80
|
+
}
|
83
81
|
}
|
82
|
+
}
|
84
83
|
end
|
85
84
|
@components = @data['components']
|
86
85
|
end
|
87
86
|
|
88
|
-
def release(
|
87
|
+
def release(_version)
|
89
88
|
case edition
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
89
|
+
when 'enterprise'
|
90
|
+
{
|
91
|
+
'enterprise-metadata' => {
|
92
|
+
'version' => 'master'
|
93
|
+
},
|
94
|
+
'simp-metadata' => {
|
95
|
+
'branch' => 'master'
|
98
96
|
}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
97
|
+
}
|
98
|
+
when 'enterprise-only'
|
99
|
+
{
|
100
|
+
'enterprise-metadata' => {
|
101
|
+
'version' => 'master'
|
104
102
|
}
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
}
|
104
|
+
else
|
105
|
+
{
|
106
|
+
'simp-metadata' => {
|
107
|
+
'branch' => 'master'
|
110
108
|
}
|
109
|
+
}
|
111
110
|
end
|
112
111
|
end
|
113
|
-
# Stub out 'writing' methods as they don't apply to bootstrap_source
|
114
|
-
def create_release(destination, source = 'master')
|
115
112
|
|
113
|
+
# Stub out 'writing' methods as they don't apply to bootstrap_source
|
114
|
+
def create_release(_destination, _source = 'master')
|
116
115
|
end
|
117
|
-
|
116
|
+
|
117
|
+
def writable?
|
118
118
|
false
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
|
+
def dirty?
|
121
122
|
false
|
122
123
|
end
|
123
|
-
|
124
|
+
|
125
|
+
def save
|
124
126
|
true
|
125
127
|
end
|
126
|
-
|
128
|
+
|
129
|
+
def cleanup
|
127
130
|
end
|
128
|
-
|
129
|
-
|
131
|
+
|
132
|
+
def to_s
|
133
|
+
name
|
130
134
|
end
|
131
|
-
|
132
|
-
|
135
|
+
|
136
|
+
def name
|
137
|
+
'bootstrap_metadata'
|
133
138
|
end
|
134
139
|
end
|
135
140
|
end
|
136
141
|
end
|
137
|
-
|
@@ -10,49 +10,49 @@ module Simp
|
|
10
10
|
@component = component
|
11
11
|
end
|
12
12
|
|
13
|
-
def keys
|
14
|
-
|
13
|
+
def keys
|
14
|
+
%w(type build_method)
|
15
15
|
end
|
16
16
|
|
17
|
-
def []
|
18
|
-
|
17
|
+
def [](index)
|
18
|
+
send index.to_sym
|
19
19
|
end
|
20
20
|
|
21
|
-
def each
|
22
|
-
|
21
|
+
def each
|
22
|
+
keys.each do |key|
|
23
23
|
yield key, self[key]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def fetch_data
|
28
|
-
component.fetch_data(
|
28
|
+
component.fetch_data('buildinfo')
|
29
29
|
end
|
30
30
|
|
31
31
|
def method_defaults
|
32
32
|
{
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
'rpm' => {
|
34
|
+
'build_method' => 'simp-core'
|
35
|
+
}
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
-
def build_method
|
40
|
-
buildinfo =
|
41
|
-
if
|
42
|
-
retval = method_defaults[type][
|
39
|
+
def build_method
|
40
|
+
buildinfo = fetch_data
|
41
|
+
if buildinfo.nil?
|
42
|
+
retval = method_defaults[type]['build_method']
|
43
43
|
else
|
44
|
-
if
|
45
|
-
if
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
if buildinfo.key?(type)
|
45
|
+
retval = if buildinfo[type].key?('build_method')
|
46
|
+
buildinfo[type]['build_method']
|
47
|
+
else
|
48
|
+
method_defaults[type]['build_method']
|
49
|
+
end
|
50
50
|
else
|
51
|
-
retval = method_defaults[type][
|
51
|
+
retval = method_defaults[type]['build_method']
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
retval
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
end
|
58
|
+
end
|
@@ -8,82 +8,84 @@ module Simp
|
|
8
8
|
command = argv[0]
|
9
9
|
argv.shift
|
10
10
|
# XXX ToDo: Make this dynamic, just instantiate a class named the subcommand
|
11
|
-
if
|
12
|
-
if
|
13
|
-
|
11
|
+
if command != ''
|
12
|
+
if command == '-h' || command == 'help'
|
13
|
+
help
|
14
14
|
else
|
15
|
-
unless
|
15
|
+
unless command =~ /^#/
|
16
16
|
begin
|
17
|
-
cmd = Module.const_get("Simp::Metadata::Commands::#{command.
|
17
|
+
cmd = Module.const_get("Simp::Metadata::Commands::#{command.tr('-', '_').capitalize}").new
|
18
18
|
|
19
19
|
rescue
|
20
20
|
Simp::Metadata.critical("Unable to find command: #{command}")
|
21
|
-
|
21
|
+
help
|
22
22
|
exit 4
|
23
23
|
end
|
24
24
|
cmd.run(argv)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
else
|
28
|
-
|
28
|
+
help
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def help
|
33
|
-
puts
|
32
|
+
def help
|
33
|
+
puts 'Usage: simp-metadata [command] [options]'
|
34
|
+
|
34
35
|
# XXX: ToDo: make this dynamic...
|
35
36
|
subcommands = [
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
37
|
+
[
|
38
|
+
'clone',
|
39
|
+
'Clones one simp release into another'
|
40
|
+
],
|
41
|
+
[
|
42
|
+
'component',
|
43
|
+
'create, view, or update a component'
|
44
|
+
],
|
45
|
+
[
|
46
|
+
'delete',
|
47
|
+
'deletes a release'
|
48
|
+
],
|
49
|
+
[
|
50
|
+
'pry',
|
51
|
+
'opens up pry debugger'
|
52
|
+
],
|
53
|
+
[
|
54
|
+
'release',
|
55
|
+
'views components of a release'
|
56
|
+
],
|
57
|
+
[
|
58
|
+
'releases',
|
59
|
+
'lists all releases'
|
60
|
+
],
|
61
|
+
[
|
62
|
+
'save',
|
63
|
+
'Saves metadata changes'
|
64
|
+
],
|
65
|
+
[
|
66
|
+
'script',
|
67
|
+
'Execute a script containing multiple commands'
|
68
|
+
],
|
69
|
+
[
|
70
|
+
'search',
|
71
|
+
'searches for components based on attributes'
|
72
|
+
],
|
73
|
+
[
|
74
|
+
'set-write',
|
75
|
+
'Sets which metadata repo to write to if there are multiple'
|
76
|
+
],
|
77
|
+
[
|
78
|
+
'set-write-url',
|
79
|
+
'view/update/create a component'
|
80
|
+
],
|
81
|
+
[
|
82
|
+
'update',
|
83
|
+
'updates a components attributes'
|
84
|
+
]
|
84
85
|
]
|
86
|
+
|
85
87
|
subcommands.each do |components|
|
86
|
-
output_string = "#{
|
88
|
+
output_string = "#{components[0].ljust(38).rjust(42)}#{components[1]}"
|
87
89
|
puts output_string
|
88
90
|
end
|
89
91
|
end
|
@@ -5,59 +5,62 @@ module Simp
|
|
5
5
|
class Base
|
6
6
|
def get_engine(engine, options = {})
|
7
7
|
root = false
|
8
|
-
|
9
|
-
options[
|
8
|
+
unless options['ssh_key'].nil?
|
9
|
+
options['ssh_key'] = File.expand_path(options['ssh_key'])
|
10
10
|
end
|
11
|
-
if
|
11
|
+
if engine.nil?
|
12
12
|
root = true
|
13
13
|
metadatarepos = {}
|
14
|
-
if
|
15
|
-
array = options[
|
16
|
-
elements = array.size / 2
|
14
|
+
if !options['writable_urls'].nil?
|
15
|
+
array = options['writable_urls'].split(',')
|
16
|
+
elements = array.size / 2
|
17
17
|
(0...elements).each do |offset|
|
18
18
|
comp = array[offset * 2]
|
19
19
|
url = array[(offset * 2) + 1]
|
20
20
|
metadatarepos[comp] = url
|
21
21
|
end
|
22
|
-
engine = Simp::Metadata::Engine.new(nil, metadatarepos, options[
|
22
|
+
engine = Simp::Metadata::Engine.new(nil, metadatarepos, options['edition'], options)
|
23
23
|
else
|
24
|
-
engine = Simp::Metadata::Engine.new(nil, nil, options[
|
24
|
+
engine = Simp::Metadata::Engine.new(nil, nil, options['edition'], options)
|
25
25
|
end
|
26
26
|
else
|
27
27
|
root = false
|
28
28
|
end
|
29
|
-
|
29
|
+
[engine, root]
|
30
30
|
end
|
31
|
-
# Defines default arguments for commands
|
32
|
-
def defaults(argv, &block)
|
33
31
|
|
32
|
+
# Defines default arguments for commands
|
33
|
+
def defaults(argv)
|
34
34
|
options = {
|
35
|
-
|
35
|
+
'edition' => ENV.fetch('SIMP_METADATA_EDITION', 'community')
|
36
36
|
}
|
37
|
-
if
|
38
|
-
options[
|
37
|
+
if ENV.fetch('SIMP_METADATA_WRITABLE_URLS', nil) != nil
|
38
|
+
options['writable_urls'] = ENV['SIMP_METADATA_WRITABLE_URLS']
|
39
39
|
end
|
40
40
|
option_parser = OptionParser.new do |opts|
|
41
|
-
opts.banner =
|
42
|
-
opts.on(
|
41
|
+
opts.banner = 'Usage: simp-metadata <command> [options]'
|
42
|
+
opts.on('-d', '--debug [level]', 'debug logging level: critical, error, warning, info, debug1, debug2') do |opt|
|
43
43
|
$simp_metadata_debug_level = opt
|
44
44
|
end
|
45
|
-
opts.on(
|
46
|
-
options[
|
45
|
+
opts.on('-v', '--version [release]', 'release version') do |opt|
|
46
|
+
options['release'] = opt
|
47
|
+
end
|
48
|
+
opts.on('-i', '--identity [ssh_key_file]', 'specify ssh_key to be used') do |opt|
|
49
|
+
options['ssh_key'] = opt
|
47
50
|
end
|
48
|
-
opts.on(
|
49
|
-
options[
|
51
|
+
opts.on('-w', '--writable-urls [component,url]', 'component,url') do |opt|
|
52
|
+
options['writable_urls'] = opt
|
50
53
|
end
|
51
|
-
opts.on(
|
52
|
-
options[
|
54
|
+
opts.on('-e', '--edition [edition]', 'simp edition') do |opt|
|
55
|
+
options['edition'] = opt
|
53
56
|
end
|
54
|
-
opts.on(
|
55
|
-
options[
|
57
|
+
opts.on('-p', '--platform [platform]', 'el_version to use', 'valid platforms:', ' - el6', ' - el7') do |opt|
|
58
|
+
options['platform'] = opt
|
56
59
|
end
|
57
60
|
yield(opts) if block_given?
|
58
61
|
end
|
59
62
|
option_parser.parse!(argv)
|
60
|
-
|
63
|
+
options
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|