Пример #1
0
 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"])
Пример #2
0
  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)
Пример #3
0
 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.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