vanagon 0.15.38 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ffa8bb7c327a5b46f5403c9fb77cf396c8a9e09fb8d7c7558927bd99830483b
4
- data.tar.gz: 8bc7b97f25d0fa5405af34ecddc6e6b00d6c57605d85a16fe232c7477a3083a8
3
+ metadata.gz: 2fff2c855cb0a9c8555e584f43fe29baa5cc6da9c9d2e938cc077c7049c8e2bf
4
+ data.tar.gz: 1ee6759c62df9a9eb6c5bf1614c8543ab8a0ff625f444e67471499638745322c
5
5
  SHA512:
6
- metadata.gz: f63aa10d3742e370faaaaf2c7dd5d7720f6598e60944a4d4917cc1e19b761a606a44fac5809f801bbae99b23f3f0221c958b70e7afb2a619d6fe32c0110a052c
7
- data.tar.gz: 4303abc3598c0558b349dee95ad81c1f6354845971323ccbaa73f24d841c4eab7e5df39225ea9f58ae305470ec143f849feb7e0adae296430873263729a536ff
6
+ metadata.gz: 3fe34a4441dd96772e3c9e6b7a824090b27b898b059f7b08996d8ab8dc5ad695c889e91bbe322829fb2b2359a53a191cf78ac8cfba0ac68a0ce938cc12d5b5db
7
+ data.tar.gz: 996e0265bfb18a929a44348ef287139fb076d9b351b80e4b99e3a26b16624efafb246bff9fb7a90fdc699b004f934df677a0fc0cee8fd71eee4cb8b984f1c353
data/bin/build CHANGED
@@ -1,29 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
2
 
4
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name>[,<platform-name>...] [<target>,<target>...] [options]",
5
- %i[workdir configdir engine preserve verbose skipcheck only_build remote-workdir])
6
- options = optparse.parse! ARGV
3
+ script = File.basename($0)
7
4
 
8
- project = ARGV[0]
9
- platforms = ARGV[1]
10
- targets = ARGV[2]
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
11
7
 
12
- if project.nil? or platforms.nil?
13
- warn "project and platform are both required arguments."
14
- warn optparse
15
- exit 1
16
- end
17
-
18
- platform_list = platforms.split(',')
19
- if targets
20
- target_list = targets.split(',')
21
- else
22
- target_list = []
23
- end
24
-
25
- platform_list.zip(target_list).each do |pair|
26
- platform, target = pair
27
- artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
28
- artifact.run
29
- end
8
+ exec "vanagon", script, *ARGV
@@ -1,21 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'json'
3
2
 
4
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
+ script = File.basename($0)
5
4
 
6
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
7
- options = optparse.parse! ARGV
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
8
7
 
9
- project = ARGV[0]
10
- platforms = ARGV[1]
11
-
12
- if project.nil? or platforms.nil?
13
- warn "project and platform are both required arguments."
14
- warn optparse
15
- exit 1
16
- end
17
-
18
- platforms.split(',').each do |platform|
19
- driver = Vanagon::Driver.new(platform, project, options)
20
- $stdout.puts JSON.generate(driver.build_host_info)
21
- end
8
+ exec "vanagon", script, *ARGV
@@ -1,35 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'json'
3
- require 'vanagon/extensions/ostruct/json'
4
- require 'vanagon/extensions/set/json'
5
- require 'vanagon/extensions/hashable'
6
2
 
7
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
+ script = File.basename($0)
8
4
 
9
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
10
- optparse.parse! ARGV
11
-
12
- project = ARGV[0]
13
- platform = ARGV[1]
14
-
15
- unless project and platform
16
- warn "project and platform are both required arguments."
17
- warn optparse
18
- exit 1
19
- end
20
-
21
- driver = Vanagon::Driver.new(platform, project)
22
- components = driver.project.components
23
- component_names = components.map(&:name)
24
- build_requirements = []
25
- components.each do |component|
26
- build_requirements << component.build_requires.reject do |req|
27
- # only include external requirements: i.e. those that do not match
28
- # other components in the project
29
- component_names.include?(req)
30
- end
31
- end
32
- $stdout.puts
33
- $stdout.puts "**** External packages required to build #{project} on #{platform}: ***"
34
- $stdout.puts JSON.pretty_generate(build_requirements.flatten.uniq.sort)
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
35
7
 
8
+ exec "vanagon", script, *ARGV
@@ -1,25 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'json'
3
- require 'vanagon/extensions/ostruct/json'
4
- require 'vanagon/extensions/set/json'
5
- require 'vanagon/extensions/hashable'
6
2
 
7
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
+ script = File.basename($0)
8
4
 
9
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
10
- options = optparse.parse! ARGV
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
11
7
 
12
- project = ARGV[0]
13
- platforms = ARGV[1]
14
-
15
- unless project or platforms
16
- warn "project and platform are both required arguments."
17
- warn optparse
18
- exit 1
19
- end
20
-
21
- platforms.split(',').each do |platform|
22
- driver = Vanagon::Driver.new(platform, project, options)
23
- components = driver.project.components.map(&:to_hash)
24
- $stdout.puts JSON.pretty_generate(components)
25
- end
8
+ exec "vanagon", script, *ARGV
data/bin/render CHANGED
@@ -1,26 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
2
 
4
- optparse = Vanagon::OptParse.new(
5
- "#{File.basename(__FILE__)} <project-name> <platform-name> [options]",
6
- %i[workdir configdir engine]
7
- )
8
- options = optparse.parse! ARGV
3
+ script = File.basename($0)
9
4
 
10
- project = ARGV[0]
11
- platforms = ARGV[1]
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
12
7
 
13
- if project.nil? or platforms.nil?
14
- warn "project and platform are both required arguments."
15
- warn optparse
16
- exit 1
17
- end
18
-
19
- platform_list = platforms.split(',')
20
- target_list = []
21
-
22
- platform_list.zip(target_list).each do |pair|
23
- platform, target = pair
24
- artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
25
- artifact.render
26
- end
8
+ exec "vanagon", script, *ARGV
data/bin/ship CHANGED
@@ -1,32 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV["PROJECT_ROOT"] = Dir.pwd
3
+ script = File.basename($0)
4
4
 
5
- # Begin warning: This ship script is an internal tool.
6
- # This is not intended to function outside of Puppet Labs' infrastructure.
7
- # End of warning.
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
8
7
 
9
- artifactory_warning = <<-DOC
10
- Unable to ship packages to artifactory. Please make sure you are pointing to a
11
- recent version of packaging in your Gemfile. Please also make sure you include
12
- the artifactory gem in your Gemfile.
13
-
14
- i.e.,
15
- gem 'packaging', :github => 'puppetlabs/packaging', branch: '1.0.x'
16
- gem 'artifactory'
17
- DOC
18
-
19
- if Dir["output/**/*"].select { |entry| File.file?(entry) }.empty?
20
- fail "No packages to ship in the output directory. Maybe you want to build some first?"
21
- else
22
- require 'packaging'
23
- Pkg::Util::RakeUtils.load_packaging_tasks
24
- Pkg::Util::RakeUtils.invoke_task('pl:jenkins:ship', 'artifacts', 'output')
25
- begin
26
- Pkg::Util::RakeUtils.invoke_task('pl:jenkins:ship_to_artifactory', 'output')
27
- rescue LoadError
28
- warn artifactory_warning
29
- rescue StandardError
30
- warn artifactory_warning
31
- end
32
- end
8
+ exec "vanagon", script, *ARGV
data/bin/sign CHANGED
@@ -1,15 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV["PROJECT_ROOT"] = Dir.pwd
3
+ script = File.basename($0)
4
4
 
5
- # Begin warning: This sign script is an internal tool.
6
- # This is not intended to function outside of Puppet Labs' infrastructure.
7
- # End of warning.
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
8
7
 
9
- if Dir["output/**/*"].select { |entry| File.file?(entry) }.empty?
10
- fail "No packages to sign in the output directory. Maybe you want to build some first?"
11
- end
12
-
13
- require 'packaging'
14
- Pkg::Util::RakeUtils.load_packaging_tasks
15
- Pkg::Util::RakeUtils.invoke_task('pl:jenkins:sign_all', 'output')
8
+ exec "vanagon", script, *ARGV
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
4
+
5
+ vanagon = Vanagon::CLI.new
6
+
7
+ vanagon.run(vanagon.parse(ARGV))
@@ -8,7 +8,7 @@ VANAGON_VERSION = Gem.loaded_specs["vanagon"].version.to_s
8
8
  $:.unshift(LIBDIR) unless
9
9
  $:.include?(File.dirname(__FILE__)) || $:.include?(LIBDIR)
10
10
 
11
- require 'vanagon/optparse'
11
+ require 'vanagon/cli'
12
12
  require 'vanagon/driver'
13
13
 
14
14
  # The main entry point is {Vanagon::Driver}.
@@ -0,0 +1,94 @@
1
+ require 'docopt'
2
+ require 'json'
3
+
4
+ require 'vanagon/extensions/ostruct/json'
5
+ require 'vanagon/extensions/set/json'
6
+ require 'vanagon/extensions/hashable'
7
+
8
+ require 'vanagon/cli/build'
9
+ require 'vanagon/cli/build_host_info'
10
+ require 'vanagon/cli/build_requirements'
11
+ require 'vanagon/cli/inspect'
12
+ require 'vanagon/cli/render'
13
+ require 'vanagon/cli/ship'
14
+ require 'vanagon/cli/sign'
15
+
16
+
17
+ class Vanagon
18
+ class InvalidArgument < StandardError
19
+ end
20
+
21
+ class CLI
22
+ DOCUMENTATION = <<~DOCOPT.freeze
23
+ Usage:
24
+ vanagon <command> [<args>]...
25
+
26
+ Commands are:
27
+ build build a package given a project and platform
28
+ build_host_info print information about build hosts
29
+ build_requirements print external packages required to build project
30
+ inspect a build dry-run, printing lots of information about the build
31
+ render create local versions of packaging artifacts for project
32
+ sign sign a package
33
+ ship upload a package to a distribution server
34
+ help print this help
35
+ DOCOPT
36
+
37
+ def parse(argv) # rubocop:disable Metrics/AbcSize
38
+ parsed_options = parse_options(argv)
39
+ sub_command = parsed_options['<command>']
40
+ sub_argv = parsed_options['<args>']
41
+
42
+ case sub_command
43
+ when 'build'
44
+ @sub_parser = Vanagon::CLI::Build.new
45
+ when 'build_host_info'
46
+ @sub_parser = Vanagon::CLI::BuildHostInfo.new
47
+ when 'build_requirements'
48
+ @sub_parser = Vanagon::CLI::BuildRequirements.new
49
+ when 'inspect'
50
+ @sub_parser = Vanagon::CLI::Inspect.new
51
+ when 'render'
52
+ @sub_parser = Vanagon::CLI::Render.new
53
+ when 'sign'
54
+ @sub_parser = Vanagon::CLI::Sign.new
55
+ when 'ship'
56
+ @sub_parser = Vanagon::CLI::Ship.new
57
+ when 'help'
58
+ puts DOCUMENTATION
59
+ exit 0
60
+ else
61
+ warn "vanagon: Error: unknown command: \"#{sub_command}\"\n\n#{DOCUMENTATION}"
62
+ exit 1
63
+ end
64
+
65
+ raw_options = @sub_parser.parse(sub_argv)
66
+ options = @sub_parser.options_translate(raw_options)
67
+ @sub_parser.options_validate(options)
68
+ return options
69
+ end
70
+
71
+ def run(options)
72
+ @sub_parser.run(options)
73
+ end
74
+
75
+ # Do validation of options
76
+ def options_validate(options)
77
+ options
78
+ end
79
+
80
+ # Provide a translation from parsed docopt options to older optparse options
81
+ def options_translate(docopt_options)
82
+ docopt_options
83
+ end
84
+
85
+ private
86
+
87
+ def parse_options(argv)
88
+ Docopt.docopt(DOCUMENTATION, { argv: argv, options_first: true })
89
+ rescue Docopt::Exit => e
90
+ puts e.message
91
+ exit 1
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,75 @@
1
+ require 'docopt'
2
+
3
+ class Vanagon
4
+ class CLI
5
+ class Build < Vanagon::CLI
6
+ DOCUMENTATION = <<~DOCOPT.freeze
7
+ Usage:
8
+ build [options] <project-name> <platforms> [<targets>]
9
+
10
+ Options:
11
+ -h, --help Display help
12
+ -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
13
+ -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
14
+ -o, --only-build COMPONENT,COMPONENT,...
15
+ Only build listed COMPONENTs
16
+ -p, --preserve [RULE] Rule for VM preservation: never, on-failure, always
17
+ [Default: always]
18
+ -r, --remote-workdir DIRECTORY Working directory on the remote host
19
+ -s, --skipcheck Skip the "check" stage when building components
20
+ -w, --workdir DIRECTORY Working directory on the local host
21
+ -v, --verbose Only here for backwards compatibility. Does nothing.
22
+ DOCOPT
23
+
24
+ def parse(argv)
25
+ Docopt.docopt(DOCUMENTATION, { argv: argv })
26
+ rescue Docopt::Exit => e
27
+ puts e.message
28
+ exit 1
29
+ end
30
+
31
+ def run(options) # rubocop:disable Metrics/AbcSize
32
+ project = options[:project_name]
33
+ platform_list = options[:platforms].split(',')
34
+ target_list = []
35
+ unless options[:targets].nil? || options[:targets].empty?
36
+ target_list = options[:targets].split(',')
37
+ end
38
+
39
+ platform_list.zip(target_list).each do |pair|
40
+ platform, target = pair
41
+ artifact = Vanagon::Driver.new(platform, project, options.merge({ 'target' => target }))
42
+ artifact.run
43
+ end
44
+ end
45
+
46
+ def options_translate(docopt_options)
47
+ translations = {
48
+ '--verbose' => :verbose,
49
+ '--workdir' => :workdir,
50
+ '--remote-workdir' => :"remote-workdir",
51
+ '--configdir' => :configdir,
52
+ '--engine' => :engine,
53
+ '--skipcheck' => :skipcheck,
54
+ '--preserve' => :preserve,
55
+ '--only-build' => :only_build,
56
+ '<project-name>' => :project_name,
57
+ '<platforms>' => :platforms,
58
+ '<targets>' => :targets
59
+ }
60
+ return docopt_options.map { |k, v| [translations[k], v] }.to_h
61
+ end
62
+
63
+ def options_validate(options)
64
+ # Handle --preserve option checking
65
+ valid_preserves = %w[always never on-failure]
66
+ unless valid_preserves.include? options[:preserve]
67
+ raise InvalidArgument, "--preserve option can only be one of: " +
68
+ valid_preserves.join(', ')
69
+ end
70
+ options[:preserve] = options[:preserve].to_sym
71
+ return options
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,49 @@
1
+ require 'docopt'
2
+
3
+ class Vanagon
4
+ class CLI
5
+ class BuildHostInfo < Vanagon::CLI
6
+ DOCUMENTATION = <<~DOCOPT.freeze
7
+ Usage:
8
+ build_host_info [options] <project-name> <platforms>
9
+
10
+ Options:
11
+ -h, --help Display help
12
+ -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
13
+ -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
14
+ -w, --workdir DIRECTORY Working directory on the local host
15
+ -v, --verbose Only here for backwards compatibility. Does nothing.
16
+ DOCOPT
17
+
18
+ def parse(argv)
19
+ Docopt.docopt(DOCUMENTATION, { argv: argv })
20
+ rescue Docopt::Exit => e
21
+ puts e.message
22
+ exit 1
23
+ end
24
+
25
+ def run(options)
26
+ platforms = options[:platforms].split(',')
27
+ project = options[:project_name]
28
+
29
+ platforms.each do |platform|
30
+ driver = Vanagon::Driver.new(platform, project, options)
31
+ $stdout.puts JSON.generate(driver.build_host_info)
32
+ end
33
+ end
34
+
35
+ def options_translate(docopt_options)
36
+ translations = {
37
+ '--verbose' => :verbose,
38
+ '--workdir' => :workdir,
39
+ '--configdir' => :configdir,
40
+ '--engine' => :engine,
41
+ '<project-name>' => :project_name,
42
+ '<platforms>' => :platforms,
43
+ '<targets>' => :targets
44
+ }
45
+ return docopt_options.map { |k, v| [translations[k], v] }.to_h
46
+ end
47
+ end
48
+ end
49
+ end