Class: Putpaws::InfraTargetConfig

Inherits:
Struct
  • Object
show all
Defined in:
lib/putpaws/infra_target_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster

Returns:

  • (Object)

    the current value of cluster



4
5
6
# File 'lib/putpaws/infra_target_config.rb', line 4

def cluster
  @cluster
end

#container_nameObject

Returns the value of attribute container_name

Returns:

  • (Object)

    the current value of container_name



4
5
6
# File 'lib/putpaws/infra_target_config.rb', line 4

def container_name
  @container_name
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/putpaws/infra_target_config.rb', line 4

def name
  @name
end

#scheduler_roleObject

Returns the value of attribute scheduler_role

Returns:

  • (Object)

    the current value of scheduler_role



4
5
6
# File 'lib/putpaws/infra_target_config.rb', line 4

def scheduler_role
  @scheduler_role
end

#task_definitionObject

Returns the value of attribute task_definition

Returns:

  • (Object)

    the current value of task_definition



4
5
6
# File 'lib/putpaws/infra_target_config.rb', line 4

def task_definition
  @task_definition
end

Class Method Details

.allObject



21
22
23
24
25
26
# File 'lib/putpaws/infra_target_config.rb', line 21

def self.all
  load.map{|k,v|
    data = v.slice(*self.members)
    new(data.merge(name: k.to_s))
  }
end

.find(name) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/putpaws/infra_target_config.rb', line 28

def self.find(name)
  infra_target_data = load
  data = infra_target_data[name.to_sym]
  return nil unless data
  data = data.slice(*self.members)
  new(data.merge({name: name.to_s}))
end

.load(path_prefix: '.putpaws') ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/putpaws/infra_target_config.rb', line 11

def self.load(path_prefix: '.putpaws')
  @infra_target_data ||= begin
    path = Pathname.new(path_prefix).join("infra.json").to_s
    data = File.exist?(path) ?
      JSON.parse(File.read(path), symbolize_names: true).to_h :
      {}
    data[:target] || {}
  end
end