Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 6ccf035

Browse files
committed
readme..
1 parent a14f2be commit 6ccf035

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

README.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ You must have Packer installed prior to using this client (DUH!)
2020

2121
## Usage Example
2222

23-
### Executing a build
24-
2523
```python
2624
import packer
2725

@@ -34,8 +32,35 @@ vars_file = 'path/to/vars/file'
3432

3533
p = packer.Packer(packerfile, exc=exc, only=only, vars=vars,
3634
vars_file=vars_file, exec_path=packer_exec_path)
37-
# print(p.validate(syntax_only=True))
38-
print(p.build())
39-
result = p.inspect()
40-
print result.parsed_output
41-
```
35+
p.version() # `packer version`
36+
p.build() # `packer build`
37+
result = p.inspect() # `packer inspect`
38+
print(result.parsed_output)
39+
p.validate(syntax_only=False) # `packer validate`
40+
```
41+
42+
The `inspect` method will return a dictionary containing the components:
43+
44+
```python
45+
"variables": [
46+
{
47+
"name": "aws_access_key",
48+
"value": "{{env `AWS_ACCESS_KEY_ID`}}"
49+
},
50+
{
51+
"name": "aws_secret_key",
52+
"value": "{{env `AWS_ACCESS_KEY`}}"
53+
}
54+
],
55+
"provisioners": [
56+
{
57+
"type": "shell"
58+
}
59+
],
60+
"builders": [
61+
{
62+
"type": "amazon-ebs",
63+
"name": "amazon"
64+
}
65+
]
66+
```

packer/__init__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sh
22

3-
__author__ = 'Gigaspaces'
43
__version__ = '0.1.2'
54

65
DEFAULT_PACKER_PATH = 'packer'
@@ -56,18 +55,17 @@ def version(self):
5655

5756
def validate(self, syntax_only=False):
5857
"""Validates a Packer Template file (`packer validate`)
58+
59+
If the validation failed, an `sh` exception will be raised.
5960
"""
6061
validator = self.packer.validate
6162
if syntax_only:
6263
validator = validator.bake('-syntax-only')
6364
validator = self._append_base_arguments(validator)
6465
validator = validator.bake(self.packerfile)
65-
try:
66-
validated = validator()
67-
except:
68-
print 'HASDHASD'
69-
validated.succeeded = True if validated.exit_code == 0 else False
70-
validated.failed = not validated.succeeded
66+
validated = validator()
67+
# validated.succeeded = True if validated.exit_code == 0 else False
68+
# validated.failed = not validated.succeeded
7169
return validated
7270

7371
def build(self, parallel=True, debug=False, force=False):

0 commit comments

Comments
 (0)