module Dapp::Kube::Dapp::Command::Lint

Public Instance Methods

kube_chart_name() click to toggle source
# File lib/dapp/kube/dapp/command/lint.rb, line 28
def kube_chart_name
  chart_spec = yaml_load_file(kube_chart_yaml_path)

  if chart_spec["name"].nil? || chart_spec["name"].empty?
    raise ::Dapp::Error::Command, code: :no_helm_chart_spec_name, data: { name: chart_spec["name"], path: kube_chart_yaml_path, raw_spec: kube_chart_yaml_path.read.strip }
  end

  chart_spec["name"]
end
kube_chart_yaml_path() click to toggle source
# File lib/dapp/kube/dapp/command/lint.rb, line 62
def kube_chart_yaml_path
  kube_chart_path.join("Chart.yaml")
end
kube_check_helm_chart_yaml!() click to toggle source
# File lib/dapp/kube/dapp/command/lint.rb, line 58
def kube_check_helm_chart_yaml!
  raise ::Dapp::Error::Command, code: :chart_yaml_not_found, data: { path: kube_chart_yaml_path } unless kube_chart_yaml_path.exist?
end
kube_lint() click to toggle source
# File lib/dapp/kube/dapp/command/lint.rb, line 6
def kube_lint
  command = "lint"

  # TODO: move project dir logic to golang
  project_dir = path.to_s

  dimgs = self.build_configs.map do |config|
    {"Name" => config._name, "ImageTag" => "DOCKER_TAG", "Repo" => "REPO"}
  end.uniq do |dimg|
    dimg["Name"]
  end

  res = ruby2go_deploy(
    "command" => command,
    "projectDir" => project_dir,
    "rubyCliOptions" => JSON.dump(self.options),
    "dimgs" => JSON.dump(dimgs),
  )

  raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
end
kube_lint_old() click to toggle source
# File lib/dapp/kube/dapp/command/lint.rb, line 51
def kube_lint_old
  kube_check_helm_chart_yaml!
  with_kube_tmp_lint_chart_dir do
    helm_release(&:lint!)
  end
end
with_kube_tmp_lint_chart_dir(&blk) click to toggle source
# File lib/dapp/kube/dapp/command/lint.rb, line 38
def with_kube_tmp_lint_chart_dir(&blk)
  old_kube_tmp_helm_chart_dir = @kube_tmp_helm_chart_dir
  unless ENV['DAPP_HELM_CHART_DIR']
    @kube_tmp_helm_chart_dir = File.join(Dir.mktmpdir('dapp-helm-lint-', tmp_base_dir), kube_chart_name)
  end

  begin
    with_kube_tmp_chart_dir(&blk)
  ensure
    @kube_tmp_helm_chart_dir = old_kube_tmp_helm_chart_dir
  end
end