Class: ECSHelper::ClusterHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_helper/cluster_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(helper) ⇒ ClusterHelper

Returns a new instance of ClusterHelper.



5
6
7
# File 'lib/ecs_helper/cluster_helper.rb', line 5

def initialize(helper)
  @helper = helper
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def client
  @client
end

#clustersObject

Returns the value of attribute clusters.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def clusters
  @clusters
end

#current_clusterObject

Returns the value of attribute current_cluster.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def current_cluster
  @current_cluster
end

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def environment
  @environment
end

#helperObject

Returns the value of attribute helper.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def helper
  @helper
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def options
  @options
end

#projectObject

Returns the value of attribute project.



4
5
6
# File 'lib/ecs_helper/cluster_helper.rb', line 4

def project
  @project
end

Instance Method Details

#from_envObject



24
25
26
# File 'lib/ecs_helper/cluster_helper.rb', line 24

def from_env
  clusters.find {|c| c.include?(helper.project) && c.include?(helper.environment)}
end

#from_optionsObject

Raises:

  • (StandardError)


17
18
19
20
21
22
# File 'lib/ecs_helper/cluster_helper.rb', line 17

def from_options
  value = helper.options[:cluster]
  return nil unless value
  return value if clusters.include?(value)
  raise(StandardError.new("Cluster specified in cli not exists, clusters you have: #{clusters}")) unless clusters.find {|r| r == value}
end

#only_oneObject



28
29
30
# File 'lib/ecs_helper/cluster_helper.rb', line 28

def only_one
  return clusters[0] if clusters.length == 1
end