Module: Dapp::Kube::Dapp::Command::Lint
- Included in:
- Dapp
- Defined in:
- lib/dapp/kube/dapp/command/lint.rb
Instance Method Summary collapse
- #kube_chart_name ⇒ Object
- #kube_chart_yaml_path ⇒ Object
- #kube_check_helm_chart_yaml! ⇒ Object
- #kube_lint ⇒ Object
- #kube_lint_old ⇒ Object
- #with_kube_tmp_lint_chart_dir(&blk) ⇒ Object
Instance Method Details
#kube_chart_name ⇒ Object
28 29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
62 63 64 |
# 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! ⇒ Object
58 59 60 |
# 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 ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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.), "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 ⇒ Object
51 52 53 54 55 56 |
# 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) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# 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 |