Method: KubernetesCLI#apply_uri

Defined in:
lib/kubernetes-cli.rb

#apply_uri(uri, dry_run: false) ⇒ Object

T::Sig::WithoutRuntime.sig { params(uri: String, dry_run: T::Boolean).void }


183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/kubernetes-cli.rb', line 183

def apply_uri(uri, dry_run: false)
  cmd = [executable, '--kubeconfig', kubeconfig_path, 'apply', '--validate']
  cmd << '--dry-run=client' if dry_run
  cmd += ['-f', uri]
  systemm(cmd)

  on_last_status_failure do |last_status|
    err = InvalidResourceUriError.new("Could not apply #{uri}: "\
      "kubectl exited with status code #{last_status.exitstatus}"
    )

    err.resource_uri = uri
    raise err
  end
end