Class: Minfra::Cli::StackM::AppTemplate
- Inherits:
-
Object
- Object
- Minfra::Cli::StackM::AppTemplate
- Includes:
- Logging
- Defined in:
- lib/minfra/cli/commands/stack/app_template.rb
Instance Attribute Summary collapse
-
#app_path ⇒ Object
readonly
Returns the value of attribute app_path.
-
#deployment ⇒ Object
readonly
Returns the value of attribute deployment.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #app ⇒ Object
- #client ⇒ Object
- #cluster_name ⇒ Object
-
#initialize(name, config) ⇒ AppTemplate
constructor
A new instance of AppTemplate.
- #read ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Methods included from Logging
#debug, #deprecated, #error, #exit_error, #info, #warn
Constructor Details
#initialize(name, config) ⇒ AppTemplate
Returns a new instance of AppTemplate.
13 14 15 16 17 18 19 20 21 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 13 def initialize(name, config) @name = name @path = config.stacks_path.join(name) @app_path = @path.join('fxnet-app.json') @errors = [] @config = config @env = config.orch_env @content = {} end |
Instance Attribute Details
#app_path ⇒ Object (readonly)
Returns the value of attribute app_path.
11 12 13 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 11 def app_path @app_path end |
#deployment ⇒ Object (readonly)
Returns the value of attribute deployment.
11 12 13 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 11 def deployment @deployment end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
11 12 13 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 11 def env @env end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 11 def name @name end |
Instance Method Details
#app ⇒ Object
48 49 50 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 48 def app @content.app end |
#client ⇒ Object
52 53 54 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 52 def client @content.client end |
#cluster_name ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 23 def cluster_name return @cluster_name if defined?(@cluster_name) @cluster_name = @cluster @cluster_name ||= "kind-#{@config.name}" if @config.dev? @cluster_name = YAML.safe_load(File.read(cluster_path))[env.to_s] if cluster_path.exist? && (@cluster_name.nil? || @cluster_name.empty?) unless @cluster_name error "Cluster name unknown (not given explicitly and '#{cluster_path}' missing)" exit 1 end @cluster_name end |
#read ⇒ Object
43 44 45 46 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 43 def read t = Minfra::Cli::Templater.new(File.read(@app_path)) @content = Hashie::Mash.new(JSON.parse(t.render({}))) end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 56 def to_s JSON.generate(@content, { indent: ' ', object_nl: "\n" }) end |
#valid? ⇒ Boolean
36 37 38 39 40 41 |
# File 'lib/minfra/cli/commands/stack/app_template.rb', line 36 def valid? @errors << "stack path #{@path} doesn't exist" unless @path.exist? @errors << "stack.rb file #{@app_path} doesn't exist" unless @app_path.exist? @errors.empty? end |