Class: HelmWrapper::Shared::Chart
- Inherits:
-
Object
- Object
- HelmWrapper::Shared::Chart
- Includes:
- Logging
- Defined in:
- lib/helm-wrapper/shared/chart.rb
Constant Summary collapse
- @@chart_metadata_file =
"Chart.yaml"
Instance Attribute Summary collapse
-
#artefact ⇒ Object
readonly
Returns the value of attribute artefact.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#oci ⇒ Object
readonly
Returns the value of attribute oci.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #artefact_active(active:, index:) ⇒ Object
-
#initialize(options:) ⇒ Chart
constructor
A new instance of Chart.
- #oci_active(active:, index:) ⇒ Object
Methods included from Logging
configure_logger_for, logger_for
Constructor Details
#initialize(options:) ⇒ Chart
Returns a new instance of Chart.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/helm-wrapper/shared/chart.rb', line 31 def initialize(options:) if ["path"].nil? then @path = ["path"] logger.fatal("Chart name must be a string!") unless ["name"].kind_of?(String) logger.fatal("Chart name must not be blank!") if ["name"].strip.empty? @name = ["name"] logger.fatal("Chart version must be a string!") unless ["version"].kind_of?(String) @version = ["version"] else logger.fatal("Chart path must be a string!") unless ["path"].kind_of?(String) logger.fatal("Chart path must not be blank!") if ["path"].strip.empty? logger.fatal("Chart path must exist!") unless File.directory?(["path"]) @path = ["path"] end logger.fatal("Chart repos must be a list of hashes!") unless ["repos"].kind_of?(Array) repos = ["repos"] @oci = Array.new @artefact = Array.new repos.each do |repo| logger.fatal("All elements of chart repos must be hashes!") unless repo.kind_of?(Hash) logger.fatal("Chart repo: #{hash["name"]} must have a type attribute!") unless repo.key?("type") logger.fatal("Chart repo: #{hash["name"]} type must be a string!") unless repo["type"].kind_of?(String) logger.fatal("Chart repo: #{hash["name"]} type must either be 'artefact' or 'oci'.") unless [ "artefact", "oci" ].include?(repo["type"]) is_artefact = repo["type"] == "artefact" ? true : false is_oci = repo["type"] == "oci" ? true : false hash = Hash.new logger.fatal("Chart repos must have a name attribute!") unless repo.key?("name") logger.fatal("Chart repo name must be a string!") unless repo["name"].kind_of?(String) logger.fatal("Chart repo name must not be blank!") if repo["name"].strip.empty? hash["name"] = repo["name"].strip logger.fatal("Chart repo: #{hash["name"]} must have a url attribute!") unless repo.key?("url") logger.fatal("Chart repo: #{hash["name"]} url must be a string!") unless repo["url"].kind_of?(String) logger.fatal("Chart repo: #{hash["name"]} url must not be blank!") if repo["url"].strip.empty? hash["url"] = repo["url"].strip if repo.key?("username") then logger.fatal("Chart repo: #{hash["name"]} username must be a string!") unless repo["username"].kind_of?(String) logger.fatal("Chart repo: #{hash["name"]} username must not be blank!") if repo["username"].strip.empty? hash["username"] = repo["username"].strip logger.fatal("Chart repo: #{hash["name"]} must have a password attribute if 'username' is set!") unless repo.key?("password") logger.fatal("Chart repo: #{hash["name"]} password must be a string!") unless repo["password"].kind_of?(String) logger.fatal("Chart repo: #{hash["name"]} password must not be blank!") if repo["password"].strip.empty? hash["password"] = repo["password"].strip else fatal("Chart repo: #{hash["name"]} is an OCI repository therefore must have a username attribute! Public OCI repositories do not need to be declared.") if is_oci hash["username"] = nil hash["password"] = nil end hash["active"] = false artefact.append(hash) if is_artefact oci.append(hash) if is_oci end end |
Instance Attribute Details
#artefact ⇒ Object (readonly)
Returns the value of attribute artefact.
23 24 25 |
# File 'lib/helm-wrapper/shared/chart.rb', line 23 def artefact @artefact end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/helm-wrapper/shared/chart.rb', line 24 def name @name end |
#oci ⇒ Object (readonly)
Returns the value of attribute oci.
26 27 28 |
# File 'lib/helm-wrapper/shared/chart.rb', line 26 def oci @oci end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
25 26 27 |
# File 'lib/helm-wrapper/shared/chart.rb', line 25 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
27 28 29 |
# File 'lib/helm-wrapper/shared/chart.rb', line 27 def version @version end |
Instance Method Details
#artefact_active(active:, index:) ⇒ Object
108 109 110 |
# File 'lib/helm-wrapper/shared/chart.rb', line 108 def artefact_active(active:, index:) artefact[index]["active"] = active end |
#oci_active(active:, index:) ⇒ Object
114 115 116 |
# File 'lib/helm-wrapper/shared/chart.rb', line 114 def oci_active(active:, index:) oci[index]["active"] = active end |