Class: KuberKit::ShellLauncher::Strategies::Kubernetes

Inherits:
Abstract show all
Defined in:
lib/kuber_kit/shell_launcher/strategies/kubernetes.rb

Instance Method Summary collapse

Instance Method Details

#call(shell) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kuber_kit/shell_launcher/strategies/kubernetes.rb', line 9

def call(shell)
  kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
  if kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
    kubeconfig_path = artifact_path_resolver.call(kubeconfig_path)
  end

  deployer_namespace = KuberKit.current_configuration.deployer_namespace
  if deployer_namespace
    kubectl_commands.set_namespace(shell, deployer_namespace, kubeconfig_path: kubeconfig_path)
  end

  env_vars = [
    "KUBECONFIG=#{kubeconfig_path}", 
    "KUBER_KIT_SHELL_CONFIGURATION=#{KuberKit.current_configuration.name}"
  ]

  if configs.shell_launcher_sets_configration
    env_vars << "KUBER_KIT_CONFIGURATION=#{KuberKit.current_configuration.name}"
  end

  shell.replace!(env: env_vars)
end