cody 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba9f8bf325cf0dc7b02a62295ef48e8897beffd0ff258216ef0089cebbc6be83
4
- data.tar.gz: 0afd2fdea1f74ba15b69148bd5543e48ede3b11e7d553728501a79e0444bb911
3
+ metadata.gz: b9a5cb295e57e6087f876ac035db13c45135a56f169aa672f019721a0c26414e
4
+ data.tar.gz: 1abe3d62dd99f1d98f01cbaf5762f2e4271035011fa13098bacf961e48e2c747
5
5
  SHA512:
6
- metadata.gz: 33c187131adaf7a27dbadf4aa10f908b7f2bbee9fd5f0fb40ebea752742a8a1d346fffbd64674905cb7d7b341ba951beba65d7d450349f0d9853cc38b08ef0d6
7
- data.tar.gz: 16cdcd2e6c9f61e0f1fa002950d49179691029067f0d33006baf892f6cbfc16af9ff74d9fbaaafbaafefd119d8a5ce9e2293c31a90b97b0f5968c5dad59d85ff
6
+ metadata.gz: 4eb291322cee25dcbdd4d5b939d4432e00b1c4cb5b820aca4f4a2c682b443a04f12ced61b969dea2582d278ae946585bf73232301c9a4ff69afee47ea23d7b50
7
+ data.tar.gz: 1cf485143b33635c22c2655687fc3ebeb6a507cb84074d15c24a893cedafb3e9a7174de11902ce22058aa0710e428211e1d0279ed8007c1feb42e1df97605629
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.9.0]
7
+ - #13,#14 setting a default region in the event that the AWS region is not set.
8
+ - #17 allow empty IAM Managed Policies
9
+ - #18 add status and list commands
10
+ - fix display failed phases
11
+
6
12
  ## [0.8.6]
7
13
  - only print Failed Phases when there are failed phases
8
14
 
data/README.md CHANGED
@@ -20,7 +20,7 @@ Cody is an AWS CodeBuild Management Tool. Cody lets you create AWS CodeBuild pro
20
20
 
21
21
  ## Private Repo
22
22
 
23
- IMPORTANT: Before deploying, if you are using a private repo, use [aws codebuild import-source-credentials](https://docs.aws.amazon.com/cli/latest/reference/codebuild/import-source-credentials.html) to add credentials so that codebuild can clone down the repo. Refer to the [CodeBuilld Github Oauth/](https://cody.run/docs/github_oauth/) for more info.
23
+ IMPORTANT: Before deploying, if you are using a private repo, use [aws codebuild import-source-credentials](https://docs.aws.amazon.com/cli/latest/reference/codebuild/import-source-credentials.html) to add credentials so that codebuild can clone down the repo. Refer to the [CodeBuilld Github Oauth](https://cody.run/docs/github_oauth/) for more info.
24
24
 
25
25
  ## Usage
26
26
 
@@ -17,5 +17,12 @@ module Cody
17
17
  rescue Aws::CodeBuild::Errors::InvalidInputException => e
18
18
  puts "ERROR: #{e.class}: #{e.message}".color(:red)
19
19
  end
20
+
21
+ def build_id
22
+ return @options[:build_id] if @options[:build_id]
23
+
24
+ resp = codebuild.list_builds_for_project(project_name: @full_project_name)
25
+ resp.ids.first # most recent build_id
26
+ end
20
27
  end
21
28
  end
@@ -41,6 +41,14 @@ module Cody
41
41
  Start.new(options.merge(project_name: project_name)).run
42
42
  end
43
43
 
44
+ desc "status", "status of codebuild project."
45
+ long_desc Help.text(:status)
46
+ option :build_id, desc: "Project build id. Defaults to most recent."
47
+ common_options.call
48
+ def status(project_name=nil)
49
+ Status.new(options.merge(project_name: project_name)).run
50
+ end
51
+
44
52
  desc "stop", "stop codebuild project."
45
53
  long_desc Help.text(:stop)
46
54
  option :build_id, desc: "Project build id. Defaults to most recent."
@@ -49,6 +57,12 @@ module Cody
49
57
  Stop.new(options.merge(project_name: project_name)).run
50
58
  end
51
59
 
60
+ desc "list", "list codebuild project."
61
+ long_desc Help.text(:list)
62
+ def list
63
+ List.new(options).run
64
+ end
65
+
52
66
  desc "logs", "Prints out logs for codebuild project."
53
67
  long_desc Help.text(:logs)
54
68
  option :build_id, desc: "Project build id. Defaults to most recent."
@@ -77,6 +77,13 @@ module Cody
77
77
  def website
78
78
  ""
79
79
  end
80
+
81
+ # https://github.com/erikhuda/thor/issues/244
82
+ # Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `Lono::CLI`
83
+ # You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
84
+ def exit_on_failure?
85
+ true
86
+ end
80
87
  end
81
88
  end
82
89
  end
@@ -0,0 +1,32 @@
1
+ module Cody
2
+ class List
3
+ include AwsServices
4
+ extend Memoist
5
+
6
+ def initialize(options)
7
+ @options = options
8
+ end
9
+
10
+ def run
11
+ projects.each do |project|
12
+ puts project
13
+ end
14
+ end
15
+
16
+ def projects
17
+ projects = []
18
+ next_token = :start
19
+ while next_token
20
+ options = {sort_by: "NAME"}
21
+ if next_token && next_token != :start
22
+ options[:next_token] = next_token
23
+ end
24
+ resp = codebuild.list_projects(options)
25
+ next_token = resp.next_token
26
+ projects += resp.projects
27
+ end
28
+ projects
29
+ end
30
+ memoize :projects
31
+ end
32
+ end
@@ -5,12 +5,5 @@ module Cody
5
5
  Tailer.new(@options, build_id).run
6
6
  end
7
7
  end
8
-
9
- def build_id
10
- return @options[:build_id] if @options[:build_id]
11
-
12
- resp = codebuild.list_builds_for_project(project_name: @full_project_name)
13
- resp.ids.first # most recent build_id
14
- end
15
8
  end
16
9
  end
@@ -24,11 +24,7 @@ module Cody
24
24
  }
25
25
  }]
26
26
 
27
- if @managed_policy_arns && !@managed_policy_arns.empty?
28
- @properties[:managed_policy_arns] = @managed_policy_arns
29
- else
30
- @properties[:managed_policy_arns] = default_managed_policy_arns
31
- end
27
+ @properties[:managed_policy_arns] ||= @managed_policy_arns || default_managed_policy_arns
32
28
 
33
29
  resource = {
34
30
  IamRole: {
@@ -63,6 +63,7 @@ module Cody
63
63
  def codebuild_log_url(build_id)
64
64
  build_id = build_id.split(':').last
65
65
  region = `aws configure get region`.strip rescue "us-east-1"
66
+ region ||= "us-east-1"
66
67
  "https://#{region}.console.aws.amazon.com/codesuite/codebuild/projects/#{project_name}/build/#{project_name}%3A#{build_id}/log"
67
68
  end
68
69
 
@@ -0,0 +1,26 @@
1
+ module Cody
2
+ class Status < Base
3
+ def run
4
+ run_with_exception_handling do
5
+ puts "Build id: #{build_id}"
6
+ resp = codebuild.batch_get_builds(ids: [build_id])
7
+ build = resp.builds.first
8
+ puts "Build status: #{colored(build.build_status)}"
9
+ end
10
+ end
11
+
12
+ def colored(status)
13
+ # one of SUCCEEDED FAILED FAULT TIMED_OUT IN_PROGRESS STOPPED
14
+ case status
15
+ when "SUCCEEDED"
16
+ status.color(:green)
17
+ when "FAILED", "FAULT", "TIMED_OUT"
18
+ status.color(:red)
19
+ when "IN_PROGRESS"
20
+ status.color(:yellow)
21
+ else
22
+ status
23
+ end
24
+ end
25
+ end
26
+ end
@@ -6,12 +6,5 @@ module Cody
6
6
  puts "Build has been stopped: #{build_id}"
7
7
  end
8
8
  end
9
-
10
- def build_id
11
- return @options[:build_id] if @options[:build_id]
12
-
13
- resp = codebuild.list_builds_for_project(project_name: @full_project_name)
14
- resp.ids.first # most recent build_id
15
- end
16
9
  end
17
10
  end
@@ -47,7 +47,7 @@ module Cody
47
47
 
48
48
  def display_failed_phases(build)
49
49
  failed_phases = build.phases.select do |phase|
50
- phase.phase_status != "SUCCEEDED" && !phase.phase_status.to_s == ""
50
+ phase.phase_status != "SUCCEEDED" && phase.phase_status.to_s != ""
51
51
  end
52
52
  return if failed_phases.empty?
53
53
 
@@ -1,3 +1,3 @@
1
1
  module Cody
2
- VERSION = "0.8.6"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cody
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-30 00:00:00.000000000 Z
11
+ date: 2020-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -249,7 +249,6 @@ files:
249
249
  - ".gitignore"
250
250
  - ".gitmodules"
251
251
  - ".rspec"
252
- - ".ruby-version"
253
252
  - CHANGELOG.md
254
253
  - Gemfile
255
254
  - Guardfile
@@ -289,6 +288,7 @@ files:
289
288
  - lib/cody/help/start.md
290
289
  - lib/cody/help/stop.md
291
290
  - lib/cody/init.rb
291
+ - lib/cody/list.rb
292
292
  - lib/cody/logs.rb
293
293
  - lib/cody/project.rb
294
294
  - lib/cody/role.rb
@@ -297,6 +297,7 @@ files:
297
297
  - lib/cody/setting.rb
298
298
  - lib/cody/stack.rb
299
299
  - lib/cody/start.rb
300
+ - lib/cody/status.rb
300
301
  - lib/cody/stop.rb
301
302
  - lib/cody/tailer.rb
302
303
  - lib/cody/update.rb
@@ -374,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
374
375
  - !ruby/object:Gem::Version
375
376
  version: '0'
376
377
  requirements: []
377
- rubygems_version: 3.0.6
378
+ rubygems_version: 3.1.2
378
379
  signing_key:
379
380
  specification_version: 4
380
381
  summary: Cody provides a beautiful DSL to create and manage AWS CodeBuild projects
@@ -1 +0,0 @@
1
- 2.5.6