Class: Dev::Aws::CodePipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/firespring_dev_commands/aws/codepipeline.rb

Overview

Class for performing codepipeline functions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCodePipeline

Returns a new instance of CodePipeline.



9
10
11
# File 'lib/firespring_dev_commands/aws/codepipeline.rb', line 9

def initialize
  @client = nil
end

Instance Attribute Details

#clientObject (readonly)

Create/set a new client if none is present Return the client



15
16
17
# File 'lib/firespring_dev_commands/aws/codepipeline.rb', line 15

def client
  @client
end

Instance Method Details

#pipelines(regex_match = nil) ⇒ Object

Get a list of all pipelines in the aws account Optionally filter by the regex_match



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/firespring_dev_commands/aws/codepipeline.rb', line 21

def pipelines(regex_match = nil)
  raise 'regex_match must be a regexp' if regex_match && !regex_match.is_a?(Regexp)

  pipelines = [].tap do |ary|
    Dev::Aws.each_page(client, :list_pipelines) do |response|
      ary.concat(response.pipelines)
    end
  end

  pipelines.select! { |it| it.name.match(regex_match) } if regex_match
  pipelines
end

#status(name) ⇒ Object

Find all pipelines matching the regex_match and find the status for each of them



35
36
37
38
39
40
# File 'lib/firespring_dev_commands/aws/codepipeline.rb', line 35

def status(name)
  pipeline = client.get_pipeline_state(name:)
  print_pipeline_information(pipeline)
rescue ::Aws::CodePipeline::Errors::PipelineNotFoundException
  LOG.error "No pipeline found with name #{name}".light_yellow
end