Module: Dapp::Kube::Dapp::Command::Render

Included in:
Dapp
Defined in:
lib/dapp/kube/dapp/command/render.rb

Instance Method Summary collapse

Instance Method Details

#kube_renderObject



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/render.rb', line 6

def kube_render
  command = "render"

  # 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_render_oldObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dapp/kube/dapp/command/render.rb', line 28

def kube_render_old
  helm_release do |release|
    templates = begin
      if options[:templates].any?
        release.templates.select do |template_path, _|
          options[:templates].map { |t| "#{t}*" }.any? do |template_path_pattern|
            template_path_without_chart_name = template_path[/.*?\/(.*)/, 1]
            template_relative_path_pattern = Pathname(File.expand_path(template_path_pattern)).subpath_of(path('.helm'))
            template_relative_path_pattern ||= template_path_pattern

            File.fnmatch?(template_relative_path_pattern, template_path_without_chart_name, File::FNM_PATHNAME|File::FNM_DOTMATCH) ||
              File.fnmatch?(template_relative_path_pattern, template_path, File::FNM_PATHNAME|File::FNM_DOTMATCH)
          end
        end
      else
        release.templates
      end
    end

    templates.values.each { |t| puts t }
  end
end