Esempio n. 1
0
 def store(self, name, value, default, save=True):
     if value:
         self.data[name] = value
     elif name not in self.data:
         self.data[name] = default
     if save:
         Config.save(settings.RUNTIME_PATH, self.data)
Esempio n. 2
0
    def save_env_vars(self, name = None):
        self.load_data()

        env_name = self.get_active_env() if name is None else name
        variables = {
            'ZIMAGI_ENVIRONMENT': env_name
        }
        with self.lock:
            if env_name not in self.data['environments']:
                raise EnvironmentError("Environment {} is not defined".format(env_name))

            for field_name, field_value in self.data['environments'][env_name].items():
                variables["ZIMAGI_{}".format(field_name.upper())] = field_value if field_value is not None else ''

            Config.save(self.get_env_path(), variables)
Esempio n. 3
0
 def set_env(self, name=None, repo=None, image=None):
     self.store_env(name, False)
     self.store_repo(repo, False)
     self.store_image(image, False)
     Config.save(settings.RUNTIME_PATH, self.data)