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

Commit 6248384

Browse files
committed
yeah
1 parent 48e9c22 commit 6248384

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

packer/interface.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ def _set_global_verbosity_level(is_verbose_output=False):
2626

2727
class Packer():
2828

29-
def __init__(self, exc=None, only=None, vars=None, vars_file=None,
30-
exec_path=DEFAULT_PACKER_PATH):
29+
def __init__(self, packerfile, exc=None, only=None, vars=None,
30+
vars_file=None, exec_path=DEFAULT_PACKER_PATH):
31+
self.packerfile = packerfile
3132
self.exc = exc if exc else []
3233
self.only = only if only else []
3334
self.vars = vars if vars else {}
@@ -59,20 +60,30 @@ def _join(self, lst):
5960
def version(self):
6061
return self.packer.version().split('v')[1].rstrip('\n')
6162

62-
def validate(self, packerfile, syntax_only=False):
63+
def validate(self, syntax_only=False):
6364
validator = self.packer.validate
6465
if syntax_only:
6566
lgr.info('syntax-only check active...')
6667
validator = validator.bake('-syntax-only')
6768
validator = self._append_base_arguments(validator)
68-
validator = validator.bake(packerfile)
69-
lgr.info('Validating packerfile: {0}'.format(packerfile))
70-
lgr.info('Executing: {0}'.format(self._join(validator().cmd)))
69+
validator = validator.bake(self.packerfile)
70+
lgr.info('Validating packerfile: {0}'.format(self.packerfile))
71+
# lgr.info('Executing: {0}'.format(self._join(validator().cmd)))
7172
return validator()
7273

73-
def build(self, packerfile, parallel=True, debug=False, force=False):
74+
def build(self, parallel=True, debug=False, force=False):
7475
builder = self.packer.build
7576
if parallel:
7677
lgr.info('parallel build active...')
77-
builder.
78+
builder = builder.bake('-parallel=true')
7879
if debug:
80+
lgr.info('debug mode active...')
81+
builder = builder.bake('-debug')
82+
if force:
83+
lgr.info('force mode active...')
84+
builder = builder.bake('-force')
85+
builder = self._append_base_arguments(builder)
86+
builder = builder.bake(self.packerfile)
87+
lgr.info('Running build: {0}'.format(self.packerfile))
88+
lgr.info('Executing: {0}'.format(self._join(builder().cmd)))
89+
return builder()

tester.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
vars = {}
1212
vars_file = '/x'
1313

14-
p = packer.Packer(exc=exc, only=only, vars=vars)
15-
print(p.version())
14+
p = packer.Packer(packerfile, exc=exc, only=only, vars=vars)
15+
# print(p.version())
1616

17-
print(p.validate(packerfile, syntax_only=False))
17+
print(p.validate(syntax_only=True))
18+
# print(p.build())

0 commit comments

Comments
 (0)