def config(self, config_options, options): """ Validate and view the compose file. Usage: config [options] Options: -q, --quiet Only validate the configuration, don't print anything. --services Print the service names, one per line. """ print "project dir:" + self.project_dir environment = Environment.from_env_file(self.project_dir) print environment config_path = get_config_path_from_options( self.project_dir, config_options, environment ) compose_config = config.load( config.find(self.project_dir, config_path, environment) ) if options['--quiet']: return if options['--services']: print('\n'.join(service['name'] for service in compose_config.services)) return print(serialize_config(compose_config))
def config(self, config_options, options): """ Validate and view the compose file. Usage: config [options] Options: -q, --quiet Only validate the configuration, don't print anything. --services Print the service names, one per line. """ print "project dir:" + self.project_dir environment = Environment.from_env_file(self.project_dir) print environment config_path = get_config_path_from_options(self.project_dir, config_options, environment) compose_config = config.load( config.find(self.project_dir, config_path, environment)) if options['--quiet']: return if options['--services']: print('\n'.join(service['name'] for service in compose_config.services)) return print(serialize_config(compose_config))
def get_auxiliary_project(self): config_details = config.find(self.auxiliary_project, [], Environment(self.environment())) project_name = self.auxiliary_project_name config_data = dork_config_load([], config_details) client = get_client(self.environment(), version=API_VERSIONS[config_data.version]) return Project.from_config(project_name, config_data, client)
def load_config(self, project_dir, options): try: environment = Environment.from_env_file(project_dir) config_path = get_config_path_from_options(project_dir, options, environment) config_details = config.find(project_dir, config_path, environment) self.config = config.load(config_details) except ComposeFileNotFound: self.config = False self._load_plugins()
def test_config_file_with_environment_variable(self): os.environ.update(IMAGE="busybox", HOST_PORT="80", LABEL_VALUE="myvalue") service_dicts = config.load(config.find("tests/fixtures/environment-interpolation", None)) self.assertEqual( service_dicts, [ { "name": "web", "image": "busybox", "ports": ["80:8000"], "labels": {"mylabel": "myvalue"}, "hostname": "host-", "command": "${ESCAPED}", } ], )
def test_config_file_with_environment_variable(self): os.environ.update( IMAGE="busybox", HOST_PORT="80", LABEL_VALUE="myvalue", ) service_dicts = config.load( config.find('tests/fixtures/environment-interpolation', None), ) self.assertEqual(service_dicts, [{ 'name': 'web', 'image': 'busybox', 'ports': ['80:8000'], 'labels': { 'mylabel': 'myvalue' }, 'hostname': 'host-', 'command': '${ESCAPED}', }])
def test_config_file_with_environment_variable(self): os.environ.update( IMAGE="busybox", HOST_PORT="80", LABEL_VALUE="myvalue", ) service_dicts = config.load( config.find('tests/fixtures/environment-interpolation', None), ) self.assertEqual(service_dicts, [ { 'name': 'web', 'image': 'busybox', 'ports': ['80:8000'], 'labels': {'mylabel': 'myvalue'}, 'hostname': 'host-', 'command': '${ESCAPED}', } ])
def load_from_filename(filename): return config.load(config.find('.', filename))
def load_from_filename(filename): return config.load(config.find('.', [filename]))
def load_from_filename(filename): return config.load(config.find(".", filename))
def _load(self, filename): working_dir = path.dirname(filename) loaded = config.load_yaml(filename) return config.load(config.find(working_dir, [path.basename(filename)]))