File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 2
2
# frozen_string_literal: true
3
3
4
4
require 'rubygems' unless defined? ( Gem )
5
+ require 'beaker'
5
6
require 'beaker-docker'
6
7
8
+ def dockerfile ( hostspec , filename )
9
+ ENV [ 'BEAKER_HYPERVISOR' ] = 'docker'
10
+ options = Beaker ::Options ::Parser . new . parse_args ( [ '--hosts' , hostspec || '' , '--no-provision' ] )
11
+ options [ :logger ] = Beaker ::Logger . new ( options )
12
+ network_manager = Beaker ::NetworkManager . new ( options , options [ :logger ] )
13
+ network_manager . provision
14
+ hosts = network_manager . hosts
15
+
16
+ if hosts . size != 1
17
+ options [ :logger ] . error "Found #{ hosts . size } hosts, expected 1"
18
+ exit ( 1 )
19
+ end
20
+
21
+ hypervisor = network_manager . hypervisors [ 'docker' ]
22
+ # TODO: private method
23
+ File . write ( filename , hypervisor . send ( :dockerfile_for , hosts . first ) )
24
+ end
25
+
7
26
VERSION_STRING = <<'VER'
8
27
_ .--.
9
28
( ` )
@@ -25,6 +44,13 @@ VERSION_STRING = <<'VER'
25
44
'=='
26
45
VER
27
46
28
- puts VERSION_STRING % BeakerDocker ::VERSION
47
+ case ARGV [ 0 ]
48
+ when 'containerfile'
49
+ dockerfile ( ARGV [ 1 ] , ARGV [ 2 ] || 'Containerfile' )
50
+ when 'dockerfile'
51
+ dockerfile ( ARGV [ 1 ] , ARGV [ 2 ] || 'Dockerfile' )
52
+ else
53
+ puts VERSION_STRING % BeakerDocker ::VERSION
54
+ end
29
55
30
56
exit 0
You can’t perform that action at this time.
0 commit comments