コード例 #1
0
  def testDebug(self):
    with mock.patch.object(subprocess, "Popen") as popen:
      with skaffold.Skaffold("./skaffold.yaml", debug=True):
        pass

    _, args, _ = popen.mock_calls[0]
    self.assertIn("-vdebug", args[0])
コード例 #2
0
  def testCommandWithNamespace(self):
    with mock.patch.object(subprocess, "Popen") as popen:
      with skaffold.Skaffold("./skaffold.yaml", namespace="fake-namespace"):
        pass

    _, args, _ = popen.mock_calls[0]
    self.assertIn("--namespace=fake-namespace", args[0])
コード例 #3
0
  def testCommandWithContext(self):
    with mock.patch.object(subprocess, "Popen") as popen:
      with skaffold.Skaffold("./skaffold.yaml", context_name="fake-context"):
        pass

    _, args, _ = popen.mock_calls[0]
    self.assertIn("--kube-context=fake-context", args[0])
コード例 #4
0
    def Run(self, args):
        _EnsureComponentsInstalled(args)

        settings = local.Settings.FromArgs(args)
        local_file_generator = local_files.LocalRuntimeFiles(settings)

        kubernetes_config = six.ensure_text(
            local_file_generator.KubernetesConfig())

        _EnsureDockerRunning()
        with cross_platform_temp_file.NamedTempFile(
                kubernetes_config) as kubernetes_file:
            skaffold_config = six.ensure_text(
                local_file_generator.SkaffoldConfig(kubernetes_file.name))
            skaffold_event_port = (args.skaffold_events_port
                                   or portpicker.pick_unused_port())
            with cross_platform_temp_file.NamedTempFile(skaffold_config) as skaffold_file, \
                 self._GetKubernetesEngine(args) as kube_context, \
                 self._WithKubeNamespace(args.namespace, kube_context.context_name), \
                 _SetImagePush(skaffold_file, kube_context.shared_docker) as patched_skaffold_file, \
                 skaffold.Skaffold(patched_skaffold_file.name, kube_context.context_name,
                                   args.namespace, kube_context.env_vars, _IsDebug(),
                                   skaffold_event_port) as running_process, \
                 skaffold.PrintUrlThreadContext(settings.service_name, skaffold_event_port):
                running_process.wait()
コード例 #5
0
  def testEnvVars(self):
    with mock.patch.object(subprocess, "Popen") as popen:
      with skaffold.Skaffold("./skaffold.yaml", env_vars={"A": "B", "C": "D"}):
        pass

    _, _, kwargs = popen.mock_calls[0]
    self.assertEqual(kwargs["env"]["A"], "B")
    self.assertEqual(kwargs["env"]["C"], "D")
コード例 #6
0
  def testCommand(self):
    with mock.patch.object(subprocess, "Popen") as popen:
      with skaffold.Skaffold("./skaffold.yaml"):
        pass

      popen.assert_called_with(
          [mock.ANY, "dev", "-f", "./skaffold.yaml", "--port-forward"],
          env=mock.ANY)
コード例 #7
0
  def testKeyboardInterrupted(self):
    with mock.patch.object(subprocess, "Popen"):
      with skaffold.Skaffold("./skaffold.yaml") as proc:
        raise KeyboardInterrupt()

      proc.terminate.assert_called()
コード例 #8
0
 def _SkaffoldProcess(self, patched_skaffold_file, kube_context, namespace,
                      skaffold_event_port):
     return skaffold.Skaffold(patched_skaffold_file.name,
                              kube_context.context_name, namespace,
                              kube_context.env_vars, _IsDebug(),
                              skaffold_event_port)