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

Commit e2dd316

Browse files
committed
added fix and push functions. untested
1 parent a938b3e commit e2dd316

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

packer/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@ def validate(self, syntax_only=False):
7979
# validated.failed = not validated.succeeded
8080
return validated
8181

82+
def push(self, create=True, token=False):
83+
"""Implmenets the `packer push` function
84+
"""
85+
pusher = self.packer.push
86+
if create:
87+
pusher = pusher.bake('-create=true')
88+
if token:
89+
pusher = pusher.bake('-token={0}'.format(token))
90+
pusher = pusher.bake(self.packerfile)
91+
return pusher()
92+
93+
def fix(self, to_file=None):
94+
"""Implements the `packer fix` function
95+
"""
96+
fixer = self.packer.fix
97+
fixer = fixer.bake(self.packerfile)
98+
if to_file:
99+
fixer = fixer.bake(' > {0}'.format(to_file))
100+
return fixer()
101+
82102
def build(self, parallel=True, debug=False, force=False):
83103
"""Executes a Packer build (`packer build`)
84104

0 commit comments

Comments
 (0)