From d50f5ca2aaa790835a50d7b9b08c3e2c42edb8f5 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Fri, 30 Jul 2021 19:48:24 -0700 Subject: [PATCH] Added init command --- packer.py | 20 ++++++++++++-------- setup.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packer.py b/packer.py index 8b8fe8c..1714d0c 100644 --- a/packer.py +++ b/packer.py @@ -38,6 +38,18 @@ def __init__(self, template, exc=None, only=None, vars=None, self.packer = sh.Command(exec_path) self.packer = self.packer.bake(**kwargs) + def init(self, upgrade=False): + """Executes a `packer init` + + :param bool upgrade: Updates plugins to the latest version + """ + self.packer_cmd = self.packer.init + + self._add_opt('-upgrade' if upgrade else None) + self._add_opt(self.template) + + return self.packer_cmd() + def build(self, parallel=True, debug=False, force=False, machine_readable=False): """Executes a `packer build` @@ -243,11 +255,3 @@ def install(self): def _verify_packer_installed(self, packer_path): return os.path.isfile(packer_path) - - -class ValidationObject(): - pass - - -class PackerException(Exception): - pass diff --git a/setup.py b/setup.py index 04631ff..0185c2c 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(*parts): setup( name='python-packer', - version='0.1.3', + version='1.0.1', url='https://github.com/abhi1693/python-packer', author='abhi1693', author_email='desk.abhimanyu@gmail.com',