packer-client 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzljNzQ3MDI0YTI4ZDk0ZWYzNGQ3NWI4NTg0NzMwZTA0NjA3YzEwZQ==
5
- data.tar.gz: !binary |-
6
- NzBmZmRjZmJlNjVjYTkwZjY1ODQyY2JlNzI3OTNhZTY4OGE5YTg1Mw==
2
+ SHA1:
3
+ metadata.gz: 3855d6a8da914af08611f0d96f51b8af4d812a4e
4
+ data.tar.gz: 9e6b55b0850e7a6e116601d995ac545f968246bc
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZTk1MzQ5YmU1MDJmMTYwOGUwZTBjY2Q1NzVkZjRiOGY0NGFhNTE3YTM4YTIy
10
- ZDdjYjU4YjI5YjllMmMxODUzMDhmOTQ4YmQ2ZGQyOTk4MDI1N2EyMzMzNTg4
11
- OTQwNTRmZTYxYTIwYWM5MzZjYTZhZTFlZjdjYTc1MWMxYWFjZjI=
12
- data.tar.gz: !binary |-
13
- MDMzZWNlMjM3NDFkNTRiOTAwMjUwOGZmYTRhNTdhMmM5MjkxNjExNGFlMGZm
14
- ZmE5YjE0NWIxMWYxYTE3ZTUwZTZmMmUwN2NjZjhlOGJmZWJlYTE3MjFhZmQy
15
- ZDk3NDVhY2JjMzkwNmI5NTRkMmFiMzE4MDNmMTQwY2Q5MjA4ZWU=
6
+ metadata.gz: c456ad134ad226325cdf1f477e511d24621f4b8ba0e7e1eb3dd87bf26db989e29149fa83b78753948c4fad65c639152c8d16f25eab6c8d133d21999419dda201
7
+ data.tar.gz: 664c95bdd575ad72b007d3d7dd5d93c6d3e1a3e745d7e052eb519e27e858ba28ec3146d8e945a099c9bef76521cd1b1106aa47dfb98c70c3a477b3917725de5a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Packer Client
2
2
 
3
- [![Build Status](https://travis-ci.org/zl4bv/packer-ruby.svg?branch=master)](https://travis-ci.org/zl4bv/packer-ruby)
3
+ [![Build Status](https://travis-ci.org/zl4bv/packer-client.svg?branch=master)](https://travis-ci.org/zl4bv/packer-client)
4
4
 
5
5
  A ruby client for HashiCorp's [Packer](https://www.packer.io) tool.
6
6
 
@@ -40,6 +40,13 @@ client.build('template.json')
40
40
 
41
41
  # Get build artifacts
42
42
  client.build('template.json').artifacts
43
+
44
+ # Get packer output
45
+ result = client.build('template.json')
46
+ puts result.stdout
47
+
48
+ # Or have output streamed directly to stdout
49
+ result = client.build('template.json', live_stream: $STDOUT)
43
50
  ```
44
51
 
45
52
  ### Fix: Fix template
@@ -92,4 +99,4 @@ client.version.version_prerelease
92
99
 
93
100
  ## Contributing
94
101
 
95
- Bug reports and pull requests are welcome on GitHub at https://github.com/zl4bv/packer-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
102
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zl4bv/packer-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -26,6 +26,8 @@ module Packer
26
26
  # @option options [Hash] :vars variables for templates
27
27
  # @option options [String] :var_file path to JSON file containing user
28
28
  # variables
29
+ # @option options [IO] :live_stream an IO object to stream packer output to
30
+ # in addition to saving output in the output object.
29
31
  # @return [Packer::Output::Build]
30
32
  def build(template, options = {})
31
33
  args = ['build', '-machine-readable']
@@ -40,14 +42,20 @@ module Packer
40
42
 
41
43
  args << template
42
44
 
43
- Packer::Output::Build.new(command(args))
45
+ Packer::Output::Build.new(
46
+ command(args, options[:live_stream]))
44
47
  end
45
48
 
46
49
  # @api private
47
50
  # @param [Array<String>] args to pass to Packer
48
- def command(args)
51
+ # @param Boolean set to true to stream output to $stdout
52
+ def command(args, stream = nil)
49
53
  cmd = [executable_path, args].join(' ')
50
- so = Mixlib::ShellOut.new(cmd, timeout: execution_timeout)
54
+ options = {
55
+ timeout: execution_timeout,
56
+ live_stream: stream
57
+ }
58
+ so = Mixlib::ShellOut.new(cmd, options)
51
59
  so.run_command
52
60
  end
53
61
 
@@ -126,6 +134,8 @@ module Packer
126
134
  # @option options [Hash] :vars variables for templates
127
135
  # @option options [String] :var_file path to JSON file containing user
128
136
  # variables
137
+ # @option options [IO] :live_stream an IO object to stream packer output to
138
+ # in addition to saving output in the output object.
129
139
  # @return [Packer::Output::Push]
130
140
  def push(template, options = {})
131
141
  args = ['push']
@@ -139,7 +149,7 @@ module Packer
139
149
 
140
150
  args << template
141
151
 
142
- Packer::Output::Push.new(command(args))
152
+ Packer::Output::Push.new(command(args, options[:live_stream]))
143
153
  end
144
154
 
145
155
  # Executes +packer validate+
@@ -160,6 +170,8 @@ module Packer
160
170
  # @option options [Array<String>] :only validate only these builds
161
171
  # @option options [Hash] :vars variables for templates
162
172
  # @option options [String] :var_file path to JSON file containing user
173
+ # @option options [IO] :live_stream an IO object to stream packer output to
174
+ # in addition to saving output in the output object.
163
175
  # variables
164
176
  # @return [Packer::Output::Validate]
165
177
  def validate(template, options = {})
@@ -174,7 +186,7 @@ module Packer
174
186
 
175
187
  args << template
176
188
 
177
- Packer::Output::Validate.new(command(args))
189
+ Packer::Output::Validate.new(command(args, options[:live_stream]))
178
190
  end
179
191
 
180
192
  # Executes +packer version+
@@ -18,7 +18,7 @@ module Packer
18
18
  def select_messages(type)
19
19
  stdout
20
20
  .split("\n")
21
- .map { |line| CSV.parse(line).first }
21
+ .map { |line| CSV.parse(line, quote_char: "\x00").first }
22
22
  .select { |fields| fields[2] == type }
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Packer
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Vidulich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-15 00:00:00.000000000 Z
11
+ date: 2017-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-its
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mixlib-shellout
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: os
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.9'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.9'
97
97
  description: A Ruby client for HashiCorp's Packer tool.
@@ -101,10 +101,10 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
105
- - .rspec
106
- - .rubocop.yml
107
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
108
108
  - CODE_OF_CONDUCT.md
109
109
  - Gemfile
110
110
  - Guardfile
@@ -144,17 +144,17 @@ require_paths:
144
144
  - lib
145
145
  required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - ! '>='
147
+ - - ">="
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ! '>='
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.4.5
157
+ rubygems_version: 2.6.13
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: A Ruby client for HashiCorp's Packer tool.