Method: KubernetesCLI#patch_object

Defined in:
lib/kubernetes-cli.rb

#patch_object(type, namespace, name, patch_data, patch_type = 'merge') ⇒ Object

T::Sig::WithoutRuntime.sig

params(
  type: String,
  namespace: String,
  name: String,
  patch_data: String,
  patch_type: String
).void


325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/kubernetes-cli.rb', line 325

def patch_object(type, namespace, name, patch_data, patch_type = 'merge')
  cmd = [executable, '--kubeconfig', kubeconfig_path]
  cmd += ['-n', namespace] if namespace
  cmd += ['patch', type, name]
  cmd += ['-p', Shellwords.shellescape(patch_data)]
  cmd += ['--type', patch_type]

  systemm(cmd)

  on_last_status_failure do |last_status|
    raise PatchResourceError, "couldn't patch resource of type '#{type}' named '#{name}' "\
      "in namespace #{namespace}: kubectl exited with status code #{last_status.exitstatus}"
  end
end