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.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +494 -0
  3. data/Rakefile +19 -22
  4. data/exe/simp-install +1 -1
  5. data/exe/simp-media +1 -1
  6. data/exe/simp-metadata +1 -1
  7. data/lib/simp/install/command.rb +34 -35
  8. data/lib/simp/media.rb +0 -1
  9. data/lib/simp/media/command.rb +34 -35
  10. data/lib/simp/media/engine.rb +29 -35
  11. data/lib/simp/media/type.rb +1 -2
  12. data/lib/simp/media/type/base.rb +12 -4
  13. data/lib/simp/media/type/control-repo.rb +96 -107
  14. data/lib/simp/media/type/internet.rb +8 -8
  15. data/lib/simp/media/type/iso.rb +0 -1
  16. data/lib/simp/media/type/local.rb +18 -19
  17. data/lib/simp/media/type/tar.rb +37 -37
  18. data/lib/simp/metadata.rb +240 -258
  19. data/lib/simp/metadata/bootstrap_source.rb +93 -89
  20. data/lib/simp/metadata/buildinfo.rb +23 -23
  21. data/lib/simp/metadata/command.rb +60 -58
  22. data/lib/simp/metadata/commands.rb +1 -1
  23. data/lib/simp/metadata/commands/base.rb +28 -25
  24. data/lib/simp/metadata/commands/clone.rb +3 -5
  25. data/lib/simp/metadata/commands/component.rb +128 -90
  26. data/lib/simp/metadata/commands/delete.rb +4 -5
  27. data/lib/simp/metadata/commands/pry.rb +1 -3
  28. data/lib/simp/metadata/commands/release.rb +22 -23
  29. data/lib/simp/metadata/commands/releases.rb +1 -3
  30. data/lib/simp/metadata/commands/save.rb +10 -13
  31. data/lib/simp/metadata/commands/script.rb +11 -14
  32. data/lib/simp/metadata/commands/search.rb +15 -20
  33. data/lib/simp/metadata/commands/set-write-url.rb +1 -3
  34. data/lib/simp/metadata/commands/set-write.rb +1 -3
  35. data/lib/simp/metadata/commands/update.rb +9 -10
  36. data/lib/simp/metadata/component.rb +310 -154
  37. data/lib/simp/metadata/components.rb +15 -16
  38. data/lib/simp/metadata/engine.rb +31 -39
  39. data/lib/simp/metadata/fake_uri.rb +2 -0
  40. data/lib/simp/metadata/location.rb +99 -105
  41. data/lib/simp/metadata/locations.rb +19 -21
  42. data/lib/simp/metadata/release.rb +30 -39
  43. data/lib/simp/metadata/releases.rb +14 -15
  44. data/lib/simp/metadata/source.rb +69 -79
  45. data/lib/simp/metadata/version.rb +9 -0
  46. data/spec/simp/media/command_spec.rb +4 -5
  47. data/spec/simp/media/engine_spec.rb +14 -14
  48. data/spec/simp/media/type/control_repo_spec.rb +10 -12
  49. data/spec/simp/media/type/internet_spec.rb +11 -11
  50. data/spec/simp/media/type/iso_spec.rb +6 -7
  51. data/spec/simp/media/type/local_spec.rb +6 -8
  52. data/spec/simp/media/type/tar_spec.rb +6 -8
  53. data/spec/simp/metadata/buildinfo_spec.rb +19 -17
  54. data/spec/simp/metadata/commands/clone_spec.rb +4 -3
  55. data/spec/simp/metadata/component_spec.rb +43 -54
  56. data/spec/simp/metadata/engine_spec.rb +38 -41
  57. data/spec/simp/metadata/release_spec.rb +72 -79
  58. data/spec/simp/metadata/source_spec.rb +8 -6
  59. data/spec/simp/metadata_spec.rb +95 -98
  60. data/spec/spec_helper.rb +33 -21
  61. 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
- when "enterprise"
24
- @data = {
25
- "components" => {
26
- "enterprise-metadata" => {
27
- "component-type" => "simp-metadata",
28
- "authoritative" => true,
29
- "locations" => [
30
- {
31
- "url" => "simp-enterprise:///enterprise-metadata?version=master&filetype=tgz",
32
- "method" => "file",
33
- "extract" => true,
34
- "primary" => true,
35
- }
36
- ]
37
- },
38
- "simp-metadata" => {
39
- "component-type" => "simp-metadata",
40
- "authoritative" => true,
41
- "locations" => [
42
- {
43
- "url" => "https://github.com/simp/simp-metadata",
44
- "method" => "git",
45
- "primary" => true,
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
- when "enterprise-only"
52
- @data = {
53
- "components" => {
54
- "enterprise-metadata" => {
55
- "component-type" => "simp-metadata",
56
- "authoritative" => true,
57
- "locations" => [
58
- {
59
- "url" => "simp-enterprise:///enterprise-metadata?version=master&filetype=tgz",
60
- "method" => "file",
61
- "extract" => true,
62
- "primary" => true,
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
- else
69
- @data = {
70
- "components" => {
71
- "simp-metadata" => {
72
- "component-type" => "simp-metadata",
73
- "authoritative" => true,
74
- "locations" => [
75
- {
76
- "url" => "https://github.com/simp/simp-metadata",
77
- "method" => "git",
78
- "primary" => true,
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(version)
87
+ def release(_version)
89
88
  case edition
90
- when "enterprise"
91
- {
92
- "enterprise-metadata" => {
93
- "version" => "master",
94
- },
95
- "simp-metadata" => {
96
- "branch" => "master"
97
- }
89
+ when 'enterprise'
90
+ {
91
+ 'enterprise-metadata' => {
92
+ 'version' => 'master'
93
+ },
94
+ 'simp-metadata' => {
95
+ 'branch' => 'master'
98
96
  }
99
- when "enterprise-only"
100
- {
101
- "enterprise-metadata" => {
102
- "version" => "master",
103
- }
97
+ }
98
+ when 'enterprise-only'
99
+ {
100
+ 'enterprise-metadata' => {
101
+ 'version' => 'master'
104
102
  }
105
- else
106
- {
107
- "simp-metadata" => {
108
- "branch" => "master"
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
- def writable?()
116
+
117
+ def writable?
118
118
  false
119
119
  end
120
- def dirty?()
120
+
121
+ def dirty?
121
122
  false
122
123
  end
123
- def save()
124
+
125
+ def save
124
126
  true
125
127
  end
126
- def cleanup()
128
+
129
+ def cleanup
127
130
  end
128
- def to_s()
129
- self.name
131
+
132
+ def to_s
133
+ name
130
134
  end
131
- def name()
132
- "bootstrap_metadata"
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
- ["type", "build_method"]
13
+ def keys
14
+ %w(type build_method)
15
15
  end
16
16
 
17
- def [] (index)
18
- self.send index.to_sym
17
+ def [](index)
18
+ send index.to_sym
19
19
  end
20
20
 
21
- def each(&block)
22
- self.keys.each do |key|
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("buildinfo")
28
+ component.fetch_data('buildinfo')
29
29
  end
30
30
 
31
31
  def method_defaults
32
32
  {
33
- "rpm" => {
34
- "build_method" => "simp-core",
35
- }
33
+ 'rpm' => {
34
+ 'build_method' => 'simp-core'
35
+ }
36
36
  }
37
37
  end
38
38
 
39
- def build_method()
40
- buildinfo = self.fetch_data
41
- if (buildinfo == nil)
42
- retval = method_defaults[type]["build_method"]
39
+ def build_method
40
+ buildinfo = fetch_data
41
+ if buildinfo.nil?
42
+ retval = method_defaults[type]['build_method']
43
43
  else
44
- if (buildinfo.key?(type))
45
- if (buildinfo[type].key?("build_method"))
46
- retval = buildinfo[type]["build_method"]
47
- else
48
- retval = method_defaults[type]["build_method"]
49
- end
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]["build_method"]
51
+ retval = method_defaults[type]['build_method']
52
52
  end
53
53
  end
54
- return retval
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 (command != "")
12
- if (command == "-h" || command == "help")
13
- self.help()
11
+ if command != ''
12
+ if command == '-h' || command == 'help'
13
+ help
14
14
  else
15
- unless (command =~ /^#/)
15
+ unless command =~ /^#/
16
16
  begin
17
- cmd = Module.const_get("Simp::Metadata::Commands::#{command.gsub("-", "_").capitalize}").new()
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
- self.help
21
+ help
22
22
  exit 4
23
23
  end
24
24
  cmd.run(argv)
25
25
  end
26
26
  end
27
27
  else
28
- self.help()
28
+ help
29
29
  end
30
30
  end
31
31
 
32
- def help()
33
- puts "Usage: simp-metadata [command] [options]"
32
+ def help
33
+ puts 'Usage: simp-metadata [command] [options]'
34
+
34
35
  # XXX: ToDo: make this dynamic...
35
36
  subcommands = [
36
- [
37
- "clone",
38
- "Clones one simp release into another",
39
- ],
40
- [
41
- "component",
42
- "create, view, or update a component",
43
- ],
44
- [
45
- "delete",
46
- "deletes a release",
47
- ],
48
- [
49
- "pry",
50
- "opens up pry debugger",
51
- ],
52
- [
53
- "release",
54
- "views components of a release",
55
- ],
56
- [
57
- "releases",
58
- "lists all releases",
59
- ],
60
- [
61
- "save",
62
- "Saves metadata changes",
63
- ],
64
- [
65
- "script",
66
- "Execute a script containing multiple commands",
67
- ],
68
- [
69
- "search",
70
- "searches for components based on attributes",
71
- ],
72
- [
73
- "set-write",
74
- "Sets which metadata repo to write to if there are multiple",
75
- ],
76
- [
77
- "set-write-url",
78
- "view/update/create a component",
79
- ],
80
- [
81
- "update",
82
- "updates a components attributes",
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 = "#{(components[0].ljust(38)).rjust(42)}#{components[1]}"
88
+ output_string = "#{components[0].ljust(38).rjust(42)}#{components[1]}"
87
89
  puts output_string
88
90
  end
89
91
  end
@@ -18,4 +18,4 @@ module Simp
18
18
  module Commands
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -5,59 +5,62 @@ module Simp
5
5
  class Base
6
6
  def get_engine(engine, options = {})
7
7
  root = false
8
- if (options["ssh_key"] != nil)
9
- options["ssh_key"] = File.expand_path(options["ssh_key"])
8
+ unless options['ssh_key'].nil?
9
+ options['ssh_key'] = File.expand_path(options['ssh_key'])
10
10
  end
11
- if (engine == nil)
11
+ if engine.nil?
12
12
  root = true
13
13
  metadatarepos = {}
14
- if (options["writable_urls"] != nil)
15
- array = options["writable_urls"].split(',')
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["edition"], options)
22
+ engine = Simp::Metadata::Engine.new(nil, metadatarepos, options['edition'], options)
23
23
  else
24
- engine = Simp::Metadata::Engine.new(nil, nil, options["edition"], 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
- return engine, root
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
- "edition" => ENV.fetch('SIMP_METADATA_EDITION', 'community'),
35
+ 'edition' => ENV.fetch('SIMP_METADATA_EDITION', 'community')
36
36
  }
37
- if (ENV.fetch('SIMP_METADATA_WRITABLE_URLS', nil) != nil)
38
- options["writable_urls"] = ENV['SIMP_METADATA_WRITABLE_URLS']
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 = "Usage: simp-metadata <command> [options]"
42
- opts.on("-d", "--debug [level]", "debug logging level: critical, error, warning, info, debug1, debug2") do |opt|
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("-v", "--version [release]", "release version") do |opt|
46
- options["release"] = opt
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("-i", "--identity [ssh_key_file]", "specify ssh_key to be used") do |opt|
49
- options["ssh_key"] = opt
51
+ opts.on('-w', '--writable-urls [component,url]', 'component,url') do |opt|
52
+ options['writable_urls'] = opt
50
53
  end
51
- opts.on("-w", "--writable-urls [component,url]", "component,url") do |opt|
52
- options["writable_urls"] = opt
54
+ opts.on('-e', '--edition [edition]', 'simp edition') do |opt|
55
+ options['edition'] = opt
53
56
  end
54
- opts.on("-e", "--edition [edition]", "simp edition") do |opt|
55
- options["edition"] = opt
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
- return options
63
+ options
61
64
  end
62
65
  end
63
66
  end