Method: KubernetesCLI#annotate

Defined in:
lib/kubernetes-cli.rb

#annotate(type, namespace, name, annotations, overwrite: true) ⇒ Object

T::Sig::WithoutRuntime.sig

params(
  type: String,
  namespace: String,
  name: String,
  annotations: T::Hash[String, String],
  overwrite: T::Boolean
).void


349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/kubernetes-cli.rb', line 349

def annotate(type, namespace, name, annotations, overwrite: true)
  cmd = [
    executable,
    '--kubeconfig', kubeconfig_path,
    '-n', namespace,
    'annotate'
  ]

  cmd << '--overwrite' if overwrite
  cmd += [type, name]

  annotations.each do |key, value|
    cmd << "'#{key}'='#{value}'"
  end

  systemm(cmd)

  on_last_status_failure do |last_status|
    raise AnnotateResourceError, "could not annotate resource '#{name}': kubectl "\
      "exited with status code #{last_status.exitstatus}"
  end
end