Skip to content

Commit

Permalink
Merge pull request #4 from barmull/main
Browse files Browse the repository at this point in the history
Feature: Add method generate_manifest
  • Loading branch information
martin-mat authored Sep 25, 2024
2 parents ae6c3a3 + 5eead9e commit 3d76d49
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions helm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ module Helm
[resp[:status].success?, output_file]
end

def self.generate_manifest(release_name : String, namespace : String)
Log.info { "Generating manifest from installed CNF: #{release_name}" }

helm = BinarySingleton.helm
cmd = "#{helm} get manifest #{release_name} --namespace #{namespace}"
Log.info { "helm command: #{cmd}" }

status = Process.run(cmd, shell: true, output: output = IO::Memory.new, error: stderr = IO::Memory.new)

if status.success? && !output.empty?
Log.debug { "Helm.manifest output:\n #{output.to_s}" }
Log.info { "Manifest was generated successfully" }
if !stderr.empty?
Log.info { "Helm.manifest stderr: #{stderr.to_s}" }
end
else
raise ManifestGenerationError.new(stderr.to_s)
end
output.to_s
end

def self.workload_resource_by_kind(ymls : Array(YAML::Any), kind : String)
Log.info { "workload_resource_by_kind kind: #{kind}" }
Log.debug { "workload_resource_by_kind ymls: #{ymls}" }
Expand Down Expand Up @@ -362,4 +383,11 @@ module Helm
return nil
end
end

class ManifestGenerationError < Exception
def initialize(stderr : String)
super("✖ ERROR: generating manifest was not successfull.\nHelm stderr --> #{stderr}")
end
end

end

0 comments on commit 3d76d49

Please sign in to comment.