vanagon 0.17.0 → 0.18.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: e09a1563ed504da68687d85b7c7a70e62028b7d1ba24568476d5cae338ae1ebf
4
- data.tar.gz: 9da1804bfbf40c86ac845ccf60a76c133b217357117dcd22d43d97c35299aa1d
3
+ metadata.gz: b1c7459e4b7180a6b25de532c8ec598e9c3ea22449ad66c0c5a8c6088689bec6
4
+ data.tar.gz: 78c659f4a4b085aa4c6dd48a19f453ca12a32b6125c7f0b3967a0d94b0dece2e
5
5
  SHA512:
6
- metadata.gz: 19591339a372853aa653311214de761ead6dfd173218d68c0086691ede75da8d981079408afaf04e5fd362e2c9250c72ac9b1cb8cc3fdbeb16006a6510707176
7
- data.tar.gz: 74e995f55e05778820809bbed4c2dcd501896a8d4894e1a38921bb8057cee049d62c42e136e8929c84c9609790738d77be356ed55b499974b3399c6a032d724c
6
+ metadata.gz: bea66bbff87c1f57578705241d52cad28a577a5a5cc7746b5d1d2c783deff7a746b57bd63844ae09e337b2f835b65fc7db98d74dde82d13aac6592c17aa53d3d
7
+ data.tar.gz: de64bd63b30d501ebc3f7d411a9e6c2da3736abb0b0d1242bd080ee7b43b4381a21a004b8205aae32675aa2e6c0f1bb3b88fc2ba3dd2f0f7d2ba5889b6e052bb
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+
3
+ _vanagon()
4
+ {
5
+ local cur prev projects commands template_arg_commands
6
+
7
+ # COMREPLY is an array variable used to store completions
8
+ # the completion mechanism uses COMPRELY to display its contents as completions
9
+ # COMP_WORDS is an array of all the words typed after the name of the program
10
+ # COMP_CWORD is an index of the COMP_WORDS array pointing to the current word
11
+ COMPREPLY=()
12
+ cur="${COMP_WORDS[COMP_CWORD]}"
13
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
14
+ projects=($({ vanagon list -r | sed 1d; } 2>/dev/null))
15
+ commands="build build_host_info build_requirements completion inspect list render sign ship help"
16
+ template_arg_commands="build build_host_info build_requirements inspect render "
17
+
18
+ # completes with a project if the previous word was a command in template_arg_commands
19
+ if [[ $template_arg_commands =~ (^| )$prev($| ) ]] ; then
20
+ _vanagon_avail_templates_projects=$({ vanagon list -r | sed 1d; } 2>/dev/null)
21
+ # compgen generates completions filtered based on what has been typed by the user
22
+ COMPREPLY=( $(compgen -W "${_vanagon_avail_templates_projects}" -- "${cur}") )
23
+ fi
24
+
25
+ # allows multiple platforms to be tab completed
26
+ if [[ ${#COMP_WORDS[@]} -gt 3 ]] ; then
27
+ _vanagon_avail_templates_platforms=$({ vanagon list -l | sed 1d; } 2>/dev/null)
28
+ COMPREPLY=( $(compgen -W "${_vanagon_avail_templates_platforms}" -- "${cur}") )
29
+ fi
30
+
31
+ if [[ $1 == $prev ]] ; then
32
+ # only show top level commands we are at root
33
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
34
+ fi
35
+ }
36
+
37
+ # assign tab complete function `_vanagon ` to `vanagon` command
38
+ complete -F _vanagon vanagon
@@ -0,0 +1,41 @@
1
+ _vanagon()
2
+ {
3
+ local line commands template_arg_commands projects
4
+
5
+ commands="build build_host_info build_requirements completion inspect list render sign ship help"
6
+ template_arg_commands=("build" "build_host_info" "build_requirements" "inspect" "render")
7
+ projects=($({ vanagon list -r | sed 1d; } 2>/dev/null))
8
+
9
+ # '%p:globbed-files:' sets completion to only offer files matching a
10
+ # described pattern.
11
+ zstyle ':completion:*' file-patterns '%p:globbed-files:'
12
+
13
+ # arguments function provides potential completions to zsh
14
+ # specs are of the form n:message:action
15
+ _arguments -C \
16
+ ": :(${commands})" \
17
+ "*::arg:->args"
18
+
19
+ # (Ie)prevents "invalid subscript"
20
+ if ((template_arg_commands[(Ie)$line[1]])); then
21
+ _vanagon_template_sub_projects
22
+ fi
23
+ if [[ $projects =~ (^| )$line[2]($| ) ]]; then
24
+ _vanagon_template_sub_platforms
25
+ fi
26
+ }
27
+
28
+ _vanagon_template_sub_projects()
29
+ {
30
+ # -W look in certain path but don't append path to tab compelte
31
+ # -g enables file matching pattern
32
+ # (:r) removes the file extension `.rb` from the completion
33
+ _arguments "1: :_files -W $(PWD)/configs/projects/ -g '*.rb(:r)'"
34
+ }
35
+
36
+ _vanagon_template_sub_platforms()
37
+ {
38
+ _arguments "*: :_files -W $(PWD)/configs/platforms/ -g '*.rb(:r)'"
39
+ }
40
+ # compdef registeres the completion function: compdef <function-name> <program>
41
+ compdef _vanagon vanagon
@@ -8,7 +8,9 @@ require 'vanagon/extensions/hashable'
8
8
  require 'vanagon/cli/build'
9
9
  require 'vanagon/cli/build_host_info'
10
10
  require 'vanagon/cli/build_requirements'
11
+ require 'vanagon/cli/completion'
11
12
  require 'vanagon/cli/inspect'
13
+ require 'vanagon/cli/list'
12
14
  require 'vanagon/cli/render'
13
15
  require 'vanagon/cli/ship'
14
16
  require 'vanagon/cli/sign'
@@ -27,7 +29,9 @@ class Vanagon
27
29
  build build a package given a project and platform
28
30
  build_host_info print information about build hosts
29
31
  build_requirements print external packages required to build project
32
+ completion outputs path to tab completion script
30
33
  inspect a build dry-run, printing lots of information about the build
34
+ list shows a list of available projects and platforms
31
35
  render create local versions of packaging artifacts for project
32
36
  sign sign a package
33
37
  ship upload a package to a distribution server
@@ -46,10 +50,14 @@ class Vanagon
46
50
  @sub_parser = Vanagon::CLI::BuildHostInfo.new
47
51
  when 'build_requirements'
48
52
  @sub_parser = Vanagon::CLI::BuildRequirements.new
53
+ when 'completion'
54
+ @sub_parser = Vanagon::CLI::Completion.new
49
55
  when 'inspect'
50
56
  @sub_parser = Vanagon::CLI::Inspect.new
51
57
  when 'render'
52
58
  @sub_parser = Vanagon::CLI::Render.new
59
+ when 'list'
60
+ @sub_parser = Vanagon::CLI::List.new
53
61
  when 'sign'
54
62
  @sub_parser = Vanagon::CLI::Sign.new
55
63
  when 'ship'
@@ -10,7 +10,7 @@ class Vanagon
10
10
  Options:
11
11
  -h, --help Display help
12
12
  -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
13
- -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
13
+ -e, --engine ENGINE Custom engine to use [default: always_be_scheduling]
14
14
  -o, --only-build COMPONENT,COMPONENT,...
15
15
  Only build listed COMPONENTs
16
16
  -p, --preserve [RULE] Rule for VM preservation: never, on-failure, always
@@ -19,6 +19,14 @@ class Vanagon
19
19
  -s, --skipcheck Skip the "check" stage when building components
20
20
  -w, --workdir DIRECTORY Working directory on the local host
21
21
  -v, --verbose Only here for backwards compatibility. Does nothing.
22
+
23
+ Engines:
24
+ always_be_scheduling: default engine using Puppet's ABS infrastructure
25
+ docker: a docker container on the local host
26
+ ec2: an Amazon EC2 instance
27
+ hardware: a dedicated hardware device
28
+ local: the local machine, cannot be used with a target
29
+ pooler: [deprecated] Puppet's vmpooler
22
30
  DOCOPT
23
31
 
24
32
  def parse(argv)
@@ -38,7 +46,7 @@ class Vanagon
38
46
 
39
47
  platform_list.zip(target_list).each do |pair|
40
48
  platform, target = pair
41
- artifact = Vanagon::Driver.new(platform, project, options.merge({ 'target' => target }))
49
+ artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
42
50
  artifact.run
43
51
  end
44
52
  end
@@ -10,9 +10,17 @@ class Vanagon
10
10
  Options:
11
11
  -h, --help Display help
12
12
  -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
13
- -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
13
+ -e, --engine ENGINE Custom engine to use [default: always_be_scheduling]
14
14
  -w, --workdir DIRECTORY Working directory on the local host
15
15
  -v, --verbose Only here for backwards compatibility. Does nothing.
16
+
17
+ Engines:
18
+ always_be_scheduling: default engine using Puppet's ABS infrastructure
19
+ docker: a docker container on the local host
20
+ ec2: an Amazon EC2 instance
21
+ hardware: a dedicated hardware device
22
+ local: the local machine, cannot be used with a target
23
+ pooler: [deprecated] Puppet's vmpooler
16
24
  DOCOPT
17
25
 
18
26
  def parse(argv)
@@ -11,9 +11,17 @@ class Vanagon
11
11
  Options:
12
12
  -h, --help Display help
13
13
  -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
14
- -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
14
+ -e, --engine ENGINE Custom engine to use [default: always_be_scheduling]
15
15
  -w, --workdir DIRECTORY Working directory on the local host
16
16
  -v, --verbose Only here for backwards compatibility. Does nothing.
17
+
18
+ Engines:
19
+ always_be_scheduling: default engine using Puppet's ABS infrastructure
20
+ docker: a docker container on the local host
21
+ ec2: an Amazon EC2 instance
22
+ hardware: a dedicated hardware device
23
+ local: the local machine, cannot be used with a target
24
+ pooler: [deprecated] Puppet's vmpooler
17
25
  DOCOPT
18
26
 
19
27
  def parse(argv)
@@ -0,0 +1,43 @@
1
+ require 'docopt'
2
+
3
+ class Vanagon
4
+ class CLI
5
+ class Completion < Vanagon::CLI
6
+ DOCUMENTATION = <<~DOCOPT.freeze
7
+ Usage:
8
+ completion [options]
9
+
10
+ Options:
11
+ -h, --help Display help
12
+ -s, --shell SHELL Specify shell for completion script [default: bash]
13
+ DOCOPT
14
+
15
+ def parse(argv)
16
+ Docopt.docopt(DOCUMENTATION, { argv: argv })
17
+ rescue Docopt::Exit => e
18
+ puts e.message
19
+ exit 1
20
+ end
21
+
22
+ def run(options)
23
+ shell = options[:shell].downcase.strip
24
+ completion_file = File.expand_path(File.join('..', '..', '..', '..', 'extras', 'completions', "vanagon.#{shell}"), __FILE__)
25
+
26
+ if File.exist?(completion_file)
27
+ puts completion_file
28
+ exit 0
29
+ else
30
+ puts "Could not find completion file for '#{shell}': No such file #{completion_file}"
31
+ exit 1
32
+ end
33
+ end
34
+
35
+ def options_translate(docopt_options)
36
+ translations = {
37
+ '--shell' => :shell,
38
+ }
39
+ return docopt_options.map { |k, v| [translations[k], v] }.to_h
40
+ end
41
+ end
42
+ end
43
+ end
@@ -11,12 +11,20 @@ class Vanagon
11
11
  Options:
12
12
  -h, --help Display help
13
13
  -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
14
- -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
14
+ -e, --engine ENGINE Custom engine to use [default: always_be_scheduling]
15
15
 
16
16
  -p, --preserve [RULE] Rule for VM preservation: never, on-failure, always
17
17
  [Default: on-failure]
18
18
  -w, --workdir DIRECTORY Working directory on the local host
19
19
  -v, --verbose Only here for backwards compatibility. Does nothing.
20
+
21
+ Engines:
22
+ always_be_scheduling: default engine using Puppet's ABS infrastructure
23
+ docker: a docker container on the local host
24
+ ec2: an Amazon EC2 instance
25
+ hardware: a dedicated hardware device
26
+ local: the local machine, cannot be used with a target
27
+ pooler: [deprecated] Puppet's vmpooler
20
28
  DOCOPT
21
29
 
22
30
  def parse(argv)
@@ -0,0 +1,75 @@
1
+ require 'docopt'
2
+
3
+ class Vanagon
4
+ class CLI
5
+ class List < Vanagon::CLI
6
+ DOCUMENTATION = <<~DOCOPT.freeze
7
+ Usage:
8
+ list [options]
9
+
10
+ Options:
11
+ -h, --help Display help
12
+ -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
13
+ -l, --platforms Display a list of platforms
14
+ -r, --projects Display a list of projects
15
+ -s, --use-spaces Displays the list as space separated
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 output(list, use_spaces)
26
+ return list.join(' ') if use_spaces
27
+ return list
28
+ end
29
+
30
+ def run(options) # rubocop:disable Metrics/AbcSize
31
+ if Dir.exist?(File.join(options[:configdir], 'platforms')) == false ||
32
+ Dir.exist?(File.join(options[:configdir], 'projects')) == false
33
+
34
+ warn "Path to #{File.join(options[:configdir], 'platforms')} or #{File.join(options[:configdir], 'projects')} not found."
35
+ exit 1
36
+ end
37
+
38
+ platform_list = Dir.children(File.join(options[:configdir], 'platforms')).map do |platform|
39
+ File.basename(platform, File.extname(platform))
40
+ end
41
+
42
+ project_list = Dir.children(File.join(options[:configdir], 'projects')).map do |project|
43
+ File.basename(project, File.extname(project))
44
+ end
45
+
46
+ if options[:projects] == options[:platforms]
47
+ puts "- Projects", output(project_list, options[:use_spaces]), "\n", "- Platforms", output(platform_list, options[:use_spaces])
48
+ return
49
+ end
50
+
51
+ if options[:projects]
52
+ puts "- Projects"
53
+ puts output(project_list, options[:use_spaces])
54
+ return
55
+ end
56
+
57
+ if options[:platforms]
58
+ puts "- Platforms"
59
+ puts output(platform_list, options[:use_spaces])
60
+ return
61
+ end
62
+ end
63
+
64
+ def options_translate(docopt_options)
65
+ translations = {
66
+ '--configdir' => :configdir,
67
+ '--platforms' => :platforms,
68
+ '--projects' => :projects,
69
+ '--use-spaces' => :use_spaces,
70
+ }
71
+ return docopt_options.map { |k, v| [translations[k], v] }.to_h
72
+ end
73
+ end
74
+ end
75
+ end
@@ -11,9 +11,17 @@ class Vanagon
11
11
  Options:
12
12
  -h, --help Display help
13
13
  -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
14
- -e, --engine ENGINE Custom engine to use [base, local, docker, pooler] [default: pooler]
14
+ -e, --engine ENGINE Custom engine to use [default: always_be_scheduling]
15
15
  -w, --workdir DIRECTORY Working directory on the local host
16
16
  -v, --verbose Only here for backwards compatibility. Does nothing.
17
+
18
+ Engines:
19
+ always_be_scheduling: default engine using Puppet's ABS infrastructure
20
+ docker: a docker container on the local host
21
+ ec2: an Amazon EC2 instance
22
+ hardware: a dedicated hardware device
23
+ local: the local machine, cannot be used with a target
24
+ pooler: [deprecated] Puppet's vmpooler
17
25
  DOCOPT
18
26
 
19
27
  def parse(argv)
@@ -20,33 +20,29 @@ class Vanagon
20
20
  @retry_count ||= @project.retry_count || ENV["VANAGON_RETRY_COUNT"] || 1
21
21
  end
22
22
 
23
- def initialize(platform, project, options = { workdir: nil, configdir: nil, target: nil, engine: nil, components: nil, skipcheck: false, verbose: false, preserve: false, only_build: nil, remote_workdir: nil }) # rubocop:disable Metrics/AbcSize
24
- @verbose = options[:verbose]
25
- @preserve = options[:preserve]
23
+ def initialize(platform, project, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
24
+ @options = options
25
+ @verbose = options[:verbose] || false
26
+ @preserve = options[:preserve] || false
26
27
  @workdir = options[:workdir] || Dir.mktmpdir
27
28
 
28
29
  @@configdir = options[:configdir] || File.join(Dir.pwd, "configs")
29
30
  components = options[:components] || []
30
31
  only_build = options[:only_build]
31
- target = options[:target]
32
32
 
33
33
  @platform = Vanagon::Platform.load_platform(platform, File.join(@@configdir, "platforms"))
34
- @project = Vanagon::Project.load_project(project, File.join(@@configdir, "projects"), @platform, components)
34
+ @project = Vanagon::Project.load_project(
35
+ project, File.join(@@configdir, "projects"), @platform, components
36
+ )
35
37
  @project.settings[:verbose] = options[:verbose]
36
- @project.settings[:skipcheck] = options[:skipcheck]
38
+ @project.settings[:skipcheck] = options[:skipcheck] || false
37
39
  filter_out_components(only_build) if only_build
38
40
  loginit('vanagon_hosts.log')
39
41
 
40
42
  @remote_workdir = options[:"remote-workdir"]
41
43
 
42
- if options[:engine]
43
- # Use the explicitly configured engine.
44
- load_engine_object(options[:engine], @platform, target)
45
- else
46
- # Use 'pooler' as a default, but also apply selection logic that may
47
- # choose something different based on platform configuration.
48
- load_engine('pooler', @platform, target)
49
- end
44
+ engine = pick_engine(options)
45
+ load_engine_object(engine, @platform, options[:target])
50
46
  end
51
47
 
52
48
  def filter_out_components(only_build)
@@ -59,24 +55,28 @@ class Vanagon
59
55
  end
60
56
  end
61
57
 
62
- def load_engine(engine_type, platform, target)
63
- if engine_type != 'always_be_scheduling'
64
- if platform.build_hosts
65
- engine_type = 'hardware'
66
- elsif platform.aws_ami
67
- engine_type = 'ec2'
68
- elsif platform.docker_image
69
- engine_type = 'docker'
70
- elsif target
71
- engine_type = 'base'
72
- end
73
- end
74
- load_engine_object(engine_type, platform, target)
58
+ def pick_engine(options) # rubocop:disable Metrics/PerceivedComplexity
59
+ default_engine = 'always_be_scheduling'
60
+
61
+ # Use the explicitly configured engine if no target was provided.
62
+ return options[:engine] if options[:engine] && !options[:target]
63
+
64
+ # If the configured engine matches the default engine, use it
65
+ return options[:engine] if options[:engine] == default_engine
66
+
67
+ # Make some guesses about which engine to use
68
+ return 'hardware' if @platform.build_hosts
69
+ return 'ec2' if @platform.aws_ami
70
+ return 'docker' if @platform.docker_image
71
+ return 'base' if @options[:target]
72
+
73
+ return default_engine
75
74
  end
76
75
 
77
76
  def load_engine_object(engine_type, platform, target)
78
77
  require "vanagon/engine/#{engine_type}"
79
- @engine = Object::const_get("Vanagon::Engine::#{camelize(engine_type)}").new(platform, target, remote_workdir: remote_workdir)
78
+ @engine = Object::const_get("Vanagon::Engine::#{camelize(engine_type)}")
79
+ .new(platform, target, remote_workdir: remote_workdir)
80
80
  rescue StandardError, ScriptError => e
81
81
  raise Vanagon::Error.wrap(e, "Could not load the desired engine '#{engine_type}'")
82
82
  end
@@ -103,7 +103,9 @@ class Vanagon
103
103
  { "name" => @engine.build_host_name, "engine" => @engine.name }
104
104
  end
105
105
 
106
- # Returns the set difference between the build_requires and the components to get a list of external dependencies that need to be installed.
106
+ # Returns the set difference between the build_requires and the
107
+ # components to get a list of external dependencies that need to
108
+ # be installed.
107
109
  def list_build_dependencies
108
110
  @project.components.map(&:build_requires).flatten.uniq - @project.components.map(&:name)
109
111
  end
@@ -13,6 +13,8 @@ class Vanagon
13
13
  copy_extensions = '*.deb'
14
14
  end
15
15
  pkg_arch_opt = project.noarch ? "" : "-a#{@architecture}"
16
+ pkg_arch_opt = '-aarm64' if pkg_arch_opt == '-aaarch64'
17
+
16
18
  ["mkdir -p output/#{target_dir}",
17
19
  "mkdir -p $(tempdir)/#{project.name}-#{project.version}",
18
20
  "cp #{project.name}-#{project.version}.tar.gz $(tempdir)/#{project.name}_#{project.version}.orig.tar.gz",
@@ -5,7 +5,7 @@
5
5
  <%- get_configfiles.each do |config|
6
6
  dest_file = config.path.gsub(/\.pristine$/, '') -%>
7
7
 
8
- if [ -f "<%= dest_file %>" ]; then
8
+ if [ -f "<%= dest_file %>" ] && ! diff "<%= config.path %>" "<%= dest_file %>" > /dev/null; then
9
9
  echo "Detected file at '<%= dest_file %>'; updated file at '<%= config.path %>'."
10
10
  else
11
11
  mv '<%= config.path %>' '<%= dest_file %>'
@@ -9,7 +9,7 @@
9
9
  <%- get_configfiles.each do |config|
10
10
  dest_file = config.path.gsub(/\.pristine$/, '') -%>
11
11
 
12
- if [ -f "<%= dest_file %>" ]; then
12
+ if [ -f "<%= dest_file %>" ] && ! diff "<%= config.path %>" "<%= dest_file %>" > /dev/null; then
13
13
  echo "Detected file at '<%= dest_file %>'; updated file at '<%= config.path %>'."
14
14
  else
15
15
  cp -pr '<%= config.path %>' '<%= dest_file %>'
@@ -78,3 +78,149 @@ describe Vanagon::CLI do
78
78
  end
79
79
  end
80
80
  end
81
+
82
+ describe Vanagon::CLI::List do
83
+ let(:cli) { Vanagon::CLI::List.new }
84
+
85
+ describe "#output" do
86
+ let(:list) { ['a', 'b', 'c']}
87
+ it "returns an array if space is false" do
88
+ expect(cli.output(list, false)).to eq(list)
89
+ end
90
+ it "returns space separated if space is true" do
91
+ expect(cli.output(list, true)).to eq('a b c')
92
+ end
93
+ end
94
+
95
+ describe "#run" do
96
+ let(:projects){ ['foo', 'bar', 'baz'] }
97
+ let(:platforms){ ['1', '2', '3'] }
98
+ let(:output_both){
99
+ "- Projects
100
+ foo
101
+ bar
102
+ baz
103
+
104
+ - Platforms
105
+ 1
106
+ 2
107
+ 3
108
+ "
109
+ }
110
+ context "specs with standard config path" do
111
+ before(:each) do
112
+ expect(Dir).to receive(:exist?)
113
+ .with("#{File.join(Dir.pwd, 'configs', 'platforms')}")
114
+ .and_return(true)
115
+ expect(Dir).to receive(:exist?)
116
+ .with("#{File.join(Dir.pwd, 'configs', 'projects')}")
117
+ .and_return(true)
118
+ expect(Dir).to receive(:children)
119
+ .with("#{File.join(Dir.pwd, 'configs', 'projects')}")
120
+ .and_return(projects)
121
+ expect(Dir).to receive(:children)
122
+ .with("#{File.join(Dir.pwd, 'configs', 'platforms')}")
123
+ .and_return(platforms)
124
+ end
125
+ let(:options_empty) { {
126
+ nil=>false,
127
+ :configdir=>"#{Dir.pwd}/configs",
128
+ :platforms=>false,
129
+ :projects=>false,
130
+ :use_spaces=>false
131
+ } }
132
+ let(:options_platforms_only) { {
133
+ nil=>false,
134
+ :configdir=>"#{Dir.pwd}/configs",
135
+ :platforms=>true,
136
+ :projects=>false,
137
+ :use_spaces=>false
138
+ } }
139
+ let(:options_projects_only) { {
140
+ nil=>false,
141
+ :configdir=>"#{Dir.pwd}/configs",
142
+ :platforms=>false,
143
+ :projects=>true,
144
+ :use_spaces=>false
145
+ } }
146
+ let(:options_space_only) { {
147
+ nil=>false,
148
+ :configdir=>"#{Dir.pwd}/configs",
149
+ :platforms=>false,
150
+ :projects=>false,
151
+ :use_spaces=>true
152
+ } }
153
+
154
+ it "outputs projects and platforms with no options passed" do
155
+ expect do
156
+ cli.run(options_empty)
157
+ end.to output(output_both).to_stdout
158
+ end
159
+
160
+ let(:output_both_space){
161
+ "- Projects
162
+ foo bar baz
163
+
164
+ - Platforms
165
+ 1 2 3
166
+ "
167
+ }
168
+ it "outputs projects and platforms space separated" do
169
+ expect do
170
+ cli.run(options_space_only)
171
+ end.to output(output_both_space).to_stdout
172
+ end
173
+
174
+ let(:output_platforms){
175
+ "- Platforms
176
+ 1
177
+ 2
178
+ 3
179
+ "
180
+ }
181
+ it "outputs only platforms when platforms is passed" do
182
+ expect do
183
+ cli.run(options_platforms_only)
184
+ end.to output(output_platforms).to_stdout
185
+ end
186
+
187
+ let(:output_projects){
188
+ "- Projects
189
+ foo
190
+ bar
191
+ baz
192
+ "
193
+ }
194
+ it "outputs only projects when projects is passed" do
195
+ expect do
196
+ cli.run(options_projects_only)
197
+ end.to output(output_projects).to_stdout
198
+ end
199
+ end
200
+
201
+ context "spec with a configdir specified" do
202
+ let(:options_configdir) { {
203
+ nil=>false,
204
+ :configdir=> '/configs',
205
+ :platforms=>false,
206
+ :projects=>false,
207
+ :use_spaces=>false} }
208
+ it "it successfully takes the configs directory" do
209
+ expect(Dir).to receive(:exist?).with('/configs' + '/platforms')
210
+ .and_return(true)
211
+ expect(Dir).to receive(:exist?).with('/configs' + '/projects')
212
+ .and_return(true)
213
+ expect(Dir).to receive(:children).with('/configs' + '/projects')
214
+ .and_return(projects)
215
+ expect(Dir).to receive(:children).with('/configs' + '/platforms')
216
+ .and_return(platforms)
217
+ expect do
218
+ cli.run(options_configdir)
219
+ end.to output(output_both).to_stdout
220
+ end
221
+ end
222
+ end
223
+ end
224
+
225
+
226
+
@@ -50,7 +50,7 @@ describe 'Vanagon::Driver' do
50
50
  info = create_driver(redhat).build_host_info
51
51
 
52
52
  expect(info).to match({ 'name' => 'centos-7-x86_64',
53
- 'engine' => 'pooler' })
53
+ 'engine' => 'always_be_scheduling' })
54
54
  end
55
55
 
56
56
  it 'returns the vmpooler template with an explicit engine' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-02 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -107,6 +107,8 @@ files:
107
107
  - bin/ship
108
108
  - bin/sign
109
109
  - bin/vanagon
110
+ - extras/completions/vanagon.bash
111
+ - extras/completions/vanagon.zsh
110
112
  - lib/git/basic_submodules.rb
111
113
  - lib/git/rev_list.rb
112
114
  - lib/makefile.rb
@@ -115,7 +117,9 @@ files:
115
117
  - lib/vanagon/cli/build.rb
116
118
  - lib/vanagon/cli/build_host_info.rb
117
119
  - lib/vanagon/cli/build_requirements.rb
120
+ - lib/vanagon/cli/completion.rb
118
121
  - lib/vanagon/cli/inspect.rb
122
+ - lib/vanagon/cli/list.rb
119
123
  - lib/vanagon/cli/render.rb
120
124
  - lib/vanagon/cli/ship.rb
121
125
  - lib/vanagon/cli/sign.rb
@@ -288,41 +292,41 @@ signing_key:
288
292
  specification_version: 3
289
293
  summary: All of your packages will fit into this van with this one simple trick.
290
294
  test_files:
291
- - spec/lib/vanagon/project/dsl_spec.rb
295
+ - spec/lib/git/rev_list_spec.rb
296
+ - spec/lib/makefile_spec.rb
297
+ - spec/lib/vanagon/environment_spec.rb
298
+ - spec/lib/vanagon/engine/pooler_spec.rb
299
+ - spec/lib/vanagon/engine/docker_spec.rb
300
+ - spec/lib/vanagon/engine/hardware_spec.rb
301
+ - spec/lib/vanagon/engine/always_be_scheduling_spec.rb
302
+ - spec/lib/vanagon/engine/base_spec.rb
303
+ - spec/lib/vanagon/engine/local_spec.rb
304
+ - spec/lib/vanagon/engine/ec2_spec.rb
292
305
  - spec/lib/vanagon/extensions/string_spec.rb
293
- - spec/lib/vanagon/extensions/ostruct/json_spec.rb
294
306
  - spec/lib/vanagon/extensions/set/json_spec.rb
295
- - spec/lib/vanagon/platform/solaris_11_spec.rb
296
- - spec/lib/vanagon/platform/dsl_spec.rb
297
- - spec/lib/vanagon/platform/rpm/aix_spec.rb
298
- - spec/lib/vanagon/platform/windows_spec.rb
299
- - spec/lib/vanagon/platform/osx_spec.rb
300
- - spec/lib/vanagon/platform/solaris_10_spec.rb
301
- - spec/lib/vanagon/platform/rpm_spec.rb
302
- - spec/lib/vanagon/platform/deb_spec.rb
307
+ - spec/lib/vanagon/extensions/ostruct/json_spec.rb
303
308
  - spec/lib/vanagon/project_spec.rb
304
- - spec/lib/vanagon/component/source/rewrite_spec.rb
309
+ - spec/lib/vanagon/common/pathname_spec.rb
310
+ - spec/lib/vanagon/common/user_spec.rb
305
311
  - spec/lib/vanagon/component/source/git_spec.rb
306
- - spec/lib/vanagon/component/source/local_spec.rb
307
312
  - spec/lib/vanagon/component/source/http_spec.rb
313
+ - spec/lib/vanagon/component/source/local_spec.rb
314
+ - spec/lib/vanagon/component/source/rewrite_spec.rb
315
+ - spec/lib/vanagon/component/source_spec.rb
308
316
  - spec/lib/vanagon/component/rules_spec.rb
309
317
  - spec/lib/vanagon/component/dsl_spec.rb
310
- - spec/lib/vanagon/component/source_spec.rb
311
- - spec/lib/vanagon/common/user_spec.rb
312
- - spec/lib/vanagon/common/pathname_spec.rb
313
318
  - spec/lib/vanagon/component_spec.rb
314
- - spec/lib/vanagon/engine/hardware_spec.rb
315
- - spec/lib/vanagon/engine/ec2_spec.rb
316
- - spec/lib/vanagon/engine/local_spec.rb
317
- - spec/lib/vanagon/engine/docker_spec.rb
318
- - spec/lib/vanagon/engine/pooler_spec.rb
319
- - spec/lib/vanagon/engine/base_spec.rb
320
- - spec/lib/vanagon/engine/always_be_scheduling_spec.rb
321
- - spec/lib/vanagon/environment_spec.rb
319
+ - spec/lib/vanagon/project/dsl_spec.rb
320
+ - spec/lib/vanagon/platform/rpm/aix_spec.rb
321
+ - spec/lib/vanagon/platform/deb_spec.rb
322
+ - spec/lib/vanagon/platform/rpm_spec.rb
323
+ - spec/lib/vanagon/platform/solaris_10_spec.rb
324
+ - spec/lib/vanagon/platform/osx_spec.rb
325
+ - spec/lib/vanagon/platform/windows_spec.rb
326
+ - spec/lib/vanagon/platform/solaris_11_spec.rb
327
+ - spec/lib/vanagon/platform/dsl_spec.rb
322
328
  - spec/lib/vanagon/cli_spec.rb
323
- - spec/lib/vanagon/driver_spec.rb
324
- - spec/lib/vanagon/utilities_spec.rb
325
329
  - spec/lib/vanagon/platform_spec.rb
326
330
  - spec/lib/vanagon/utilities/shell_utilities_spec.rb
327
- - spec/lib/makefile_spec.rb
328
- - spec/lib/git/rev_list_spec.rb
331
+ - spec/lib/vanagon/utilities_spec.rb
332
+ - spec/lib/vanagon/driver_spec.rb