def testGenClientConfig_ignoreBuilderContext(self): with test_lib.PreserveConfig(): # Define a secondary config with special values for the ClientBuilder # context. str_override = """ Test Context: Client.labels: [label0, label1] ClientBuilder Context: Client.labels: [build-label0, build-label1] """ override = config_lib.YamlParser(data=str_override).RawData() config.CONFIG.MergeData(override) # Sanity-check that the secondary config was merged into the global # config. self.assertEqual(config.CONFIG["Client.labels"], ["label0", "label1"]) repacker = build.ClientRepacker() context = [ "Test Context", "ClientBuilder Context", "Client Context" ] str_client_config = repacker.GetClientConfig(context) client_config = config_lib.YamlParser( data=str_client_config).RawData() # Settings particular to the ClientBuilder context should not carry over # into the generated client config. self.assertEqual(client_config["Client.labels"], ["label0", "label1"])
def testGenClientConfig(self): with test_lib.ConfigOverrider({"Client.build_environment": "test_env"}): deployer = build.ClientRepacker() data = deployer.GetClientConfig(["Client Context"], validate=True) parser = config_lib.YamlParser(data=data) raw_data = parser.RawData() self.assertIn("Client.deploy_time", raw_data)
def testGenClientConfig(self): plugins = ["plugin1", "plugin2"] config_lib.CONFIG.Set("Client.plugins", plugins) deployer = build.ClientDeployer() data = deployer.GetClientConfig(["Client Context"], validate=True) parser = config_lib.YamlParser(data=data) raw_data = parser.RawData() self.assertIn("Client.build_time", raw_data) self.assertIn("Client.plugins", raw_data) self.assertEqual(raw_data["Client.plugins"], plugins)
def testGenClientConfig(self): plugins = ["plugin1", "plugin2"] with test_lib.ConfigOverrider({"Client.plugins": plugins, "Client.build_environment": "test_env"}): deployer = build.ClientDeployer() data = deployer.GetClientConfig(["Client Context"], validate=True) parser = config_lib.YamlParser(data=data) raw_data = parser.RawData() self.assertIn("Client.deploy_time", raw_data) self.assertIn("Client.plugins", raw_data) self.assertEqual(raw_data["Client.plugins"], plugins)
def GetConfigFromTemplate(self, template_path): """Apply build.yaml settings from the template.""" with zipfile.ZipFile(template_path) as template_zip: build_yaml = None for name in template_zip.namelist(): if name.endswith("build.yaml"): build_yaml = name break if not build_yaml: raise RuntimeError("Couldn't find build.yaml in %s" % template_path) with template_zip.open(build_yaml) as buildfile: repack_config = config_lib.CONFIG.CopyConfig() parser = config_lib.YamlParser(fd=buildfile) config_data = parser.RawData() self.Validate(config_data, template_path) repack_config.MergeData(config_data) return repack_config
def MergeBuildConfig(self, fd=None, data=None): data = config_lib.YamlParser(fd=fd, data=data).RawData() config_lib.CONFIG.MergeData(data)