cody 0.9.7 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -9
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile +0 -2
  5. data/cody.gemspec +3 -3
  6. data/lib/cody.rb +4 -8
  7. data/lib/cody/aws_services.rb +1 -1
  8. data/lib/cody/aws_services/helpers.rb +20 -3
  9. data/lib/cody/cli.rb +3 -13
  10. data/lib/cody/{badge.rb → cli/badge.rb} +1 -1
  11. data/lib/cody/{base.rb → cli/base.rb} +9 -3
  12. data/lib/cody/{delete.rb → cli/delete.rb} +3 -3
  13. data/lib/cody/cli/deploy.rb +7 -0
  14. data/lib/cody/cli/help.rb +11 -0
  15. data/lib/cody/{help → cli/help}/deploy.md +0 -0
  16. data/lib/cody/{help → cli/help}/init.md +0 -0
  17. data/lib/cody/{help → cli/help}/logs.md +0 -0
  18. data/lib/cody/{help → cli/help}/start.md +0 -0
  19. data/lib/cody/{help → cli/help}/stop.md +0 -0
  20. data/lib/cody/{init.rb → cli/init.rb} +1 -2
  21. data/lib/cody/{list.rb → cli/list.rb} +18 -4
  22. data/lib/cody/{logs.rb → cli/logs.rb} +3 -2
  23. data/lib/cody/{sequence.rb → cli/sequence.rb} +3 -3
  24. data/lib/cody/{start.rb → cli/start.rb} +10 -5
  25. data/lib/cody/{status.rb → cli/status.rb} +2 -1
  26. data/lib/cody/{stop.rb → cli/stop.rb} +2 -1
  27. data/lib/cody/command.rb +11 -0
  28. data/lib/cody/core.rb +5 -5
  29. data/lib/cody/dsl/base.rb +9 -0
  30. data/lib/cody/dsl/project.rb +67 -49
  31. data/lib/cody/dsl/role.rb +11 -11
  32. data/lib/cody/dsl/schedule.rb +8 -8
  33. data/lib/cody/list/no_builds_project.rb +1 -1
  34. data/lib/cody/list/project.rb +1 -1
  35. data/lib/cody/project.rb +22 -23
  36. data/lib/cody/role.rb +20 -20
  37. data/lib/cody/schedule.rb +37 -37
  38. data/lib/cody/stack.rb +16 -71
  39. data/lib/cody/stack/base.rb +104 -0
  40. data/lib/cody/{create.rb → stack/create.rb} +2 -2
  41. data/lib/cody/{update.rb → stack/update.rb} +2 -2
  42. data/lib/cody/tailer.rb +9 -1
  43. data/lib/cody/version.rb +1 -1
  44. data/lib/template/project/buildspec.yml +1 -1
  45. data/lib/template/project/project.rb.tt +5 -19
  46. metadata +65 -71
  47. data/lib/cody/completer.rb +0 -159
  48. data/lib/cody/completer/script.rb +0 -6
  49. data/lib/cody/completer/script.sh +0 -10
  50. data/lib/cody/deploy.rb +0 -40
  51. data/lib/cody/help.rb +0 -9
  52. data/lib/cody/help/completion.md +0 -22
  53. data/lib/cody/help/completion_script.md +0 -3
  54. data/vendor/aws_data/CHANGELOG.md +0 -7
  55. data/vendor/aws_data/Gemfile +0 -4
  56. data/vendor/aws_data/LICENSE.txt +0 -21
  57. data/vendor/aws_data/README.md +0 -42
  58. data/vendor/aws_data/Rakefile +0 -6
  59. data/vendor/aws_data/aws_data.gemspec +0 -30
  60. data/vendor/aws_data/bin/console +0 -14
  61. data/vendor/aws_data/bin/setup +0 -8
  62. data/vendor/aws_data/lib/aws_data.rb +0 -91
  63. data/vendor/aws_data/lib/aws_data/version.rb +0 -3
  64. data/vendor/aws_data/spec/aws_data_spec.rb +0 -5
  65. data/vendor/aws_data/spec/spec_helper.rb +0 -14
  66. data/vendor/cfn-status/Gemfile +0 -4
  67. data/vendor/cfn-status/LICENSE.txt +0 -21
  68. data/vendor/cfn-status/README.md +0 -56
  69. data/vendor/cfn-status/Rakefile +0 -6
  70. data/vendor/cfn-status/bin/console +0 -14
  71. data/vendor/cfn-status/bin/setup +0 -8
  72. data/vendor/cfn-status/cfn-status.gemspec +0 -30
  73. data/vendor/cfn-status/lib/cfn/aws_service.rb +0 -56
  74. data/vendor/cfn-status/lib/cfn/status.rb +0 -220
  75. data/vendor/cfn-status/lib/cfn/status/version.rb +0 -5
  76. data/vendor/cfn-status/spec/cfn/status_spec.rb +0 -81
  77. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
  78. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
  79. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
  80. data/vendor/cfn-status/spec/spec_helper.rb +0 -14
  81. data/vendor/cfn_camelizer/CHANGELOG.md +0 -10
  82. data/vendor/cfn_camelizer/Gemfile +0 -4
  83. data/vendor/cfn_camelizer/LICENSE.txt +0 -21
  84. data/vendor/cfn_camelizer/README.md +0 -40
  85. data/vendor/cfn_camelizer/Rakefile +0 -6
  86. data/vendor/cfn_camelizer/bin/console +0 -14
  87. data/vendor/cfn_camelizer/bin/setup +0 -8
  88. data/vendor/cfn_camelizer/cfn_camelizer.gemspec +0 -32
  89. data/vendor/cfn_camelizer/lib/camelizer.yml +0 -33
  90. data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +0 -92
  91. data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +0 -3
  92. data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +0 -79
  93. data/vendor/cfn_camelizer/spec/spec_helper.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa39f80f5ce459188463bc201140ce7d85ced81312ae2ddeb0d14f8ec8144e22
4
- data.tar.gz: b85a6c790d4932ce0972f3b744273f6e58ddbc30032133c1cfc2cc7a41b16728
3
+ metadata.gz: 88a3ea8598603639f718e4f0abccdde3c1a1f822be72cb2f4394dffccc7cbd14
4
+ data.tar.gz: 0ca4437cbc6574b4b33f180808fc131ab2631ce73b49f387321936f3937390c7
5
5
  SHA512:
6
- metadata.gz: 49fddfb01decedd5d9abe75ca313135e1b2bf46f807fca161dce1d30e54354bb1bc4e19dcde57db9f4690f1c1b43de5a0cdd1c854d7cb941e42453b35991e118
7
- data.tar.gz: fe7f0374ca5fc899f40f907c73715c8f86fc1b58591e9ffbdd3e04323fd7ad1e00a3016007be3e60e40d49ee07231b030ca2a3a03b97648800f40504b7267318
6
+ metadata.gz: 492d26d995e252031c78b306e49ea494d823f657ea7c80e94fa053732cfe6ebd285ef098478a9bfc72c234504dac214621a9d49abcb119a377c94fa77e428846
7
+ data.tar.gz: '0299c29a77b4534be575aac58d38bd5c2da97f913ecc876eb8c1b4141b22005034c537581515f0825ac2f8e9d66e2f93c9fe659d71be608e532e8c86b6785f4a'
@@ -1,9 +0,0 @@
1
- [submodule "vendor/cfn-status"]
2
- path = vendor/cfn-status
3
- url = https://github.com/tongueroo/cfn-status
4
- [submodule "vendor/cfn_camelizer"]
5
- path = vendor/cfn_camelizer
6
- url = https://github.com/tongueroo/cfn_camelizer
7
- [submodule "vendor/aws_data"]
8
- path = vendor/aws_data
9
- url = https://github.com/tongueroo/aws_data
@@ -3,6 +3,30 @@
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
+ ## [1.0.3] - 2021-01-08
7
+ - [#31](https://github.com/tongueroo/cody/pull/31) surface context message with error message for during provisioning fa…
8
+ - docs: update ci jets v3
9
+ - raise error option
10
+
11
+ ## [1.0.2]
12
+ - #30 Allow multiple git providers
13
+
14
+ ## [1.0.1]
15
+ - fix EventsRuleRole Service camelcase
16
+
17
+ ## [1.0.0]
18
+ - Breaking changes: CamelCase for properties instead of underscore. Map straight to the CloudFormation resource to remove mental overhead.
19
+ - See: https://cody.run/docs/upgrading/
20
+ - Use unfrozen gems instead of vendors gems: aws_data, cfn-status, cfn_camelizer.
21
+ - Update templates to use the latest
22
+ - Restructure classes to use CLI namespace
23
+ - Change delete: `--sure` to `--yes` option. `-y` shorthand.
24
+ - Rename CODY_EXTRA env variable
25
+
26
+ ## [0.9.8]
27
+ - add minimal deploy iam policy docs
28
+ - list: add --status filter option
29
+
6
30
  ## [0.9.7]
7
31
  - #25 cody list: add sort-by option
8
32
 
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem dependencies in codebuild.gemspec
4
4
  gemspec
5
-
6
- gem "codeclimate-test-reporter", group: :test, require: nil
@@ -28,6 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "aws-sdk-cloudformation"
29
29
  spec.add_dependency "aws-sdk-codebuild"
30
30
  spec.add_dependency "aws-sdk-ssm"
31
+ spec.add_dependency "aws_data"
32
+ spec.add_dependency "cfn-status"
33
+ spec.add_dependency "cfn_camelizer"
31
34
  spec.add_dependency "cli-format"
32
35
  spec.add_dependency "memoist"
33
36
  spec.add_dependency "rainbow"
@@ -35,9 +38,6 @@ Gem::Specification.new do |spec|
35
38
  spec.add_dependency "thor"
36
39
  spec.add_dependency "zeitwerk"
37
40
 
38
- # spec.add_dependency "aws_data" # using vendor/cfn_camelizer for now
39
- # spec.add_dependency "cfn_camelizer" # using vendor/cfn_camelizer for now
40
-
41
41
  spec.add_development_dependency "bundler"
42
42
  spec.add_development_dependency "byebug"
43
43
  spec.add_development_dependency "cli_markdown"
@@ -1,19 +1,15 @@
1
1
  $:.unshift(File.expand_path("../", __FILE__))
2
+ require "aws_data"
3
+ require "cfn_camelizer"
4
+ require "cfn_status"
2
5
  require "cody/version"
6
+ require "memoist"
3
7
  require "rainbow/ext/string"
4
8
  require "yaml"
5
9
 
6
10
  require "cody/autoloader"
7
11
  Cody::Autoloader.setup
8
12
 
9
- gem_root = File.dirname(__dir__)
10
- $:.unshift("#{gem_root}/vendor/aws_data/lib")
11
- require "aws_data"
12
- $:.unshift("#{gem_root}/vendor/cfn_camelizer/lib")
13
- require "cfn_camelizer"
14
- $:.unshift("#{gem_root}/vendor/cfn-status/lib")
15
- require "cfn/status"
16
-
17
13
  module Cody
18
14
  class Error < StandardError; end
19
15
  extend Core
@@ -15,4 +15,4 @@ module Cody
15
15
  @cfn ||= Aws::CloudFormation::Client.new
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -1,5 +1,18 @@
1
1
  module Cody::AwsServices
2
2
  module Helpers
3
+ def find_stack(stack_name)
4
+ return if ENV['TEST']
5
+ resp = cfn.describe_stacks(stack_name: stack_name)
6
+ resp.stacks.first
7
+ rescue Aws::CloudFormation::Errors::ValidationError => e
8
+ # example: Stack with id demo-web does not exist
9
+ if e.message =~ /Stack with/ && e.message =~ /does not exist/
10
+ nil
11
+ else
12
+ raise
13
+ end
14
+ end
15
+
3
16
  def stack_exists?(stack_name)
4
17
  return false if ENV['TEST']
5
18
 
@@ -26,7 +39,7 @@ module Cody::AwsServices
26
39
  end
27
40
 
28
41
  def project_name_convention(name_base)
29
- items = [@project_name, @options[:type], Cody.env_extra]
42
+ items = [@project_name, @options[:type], Cody.extra]
30
43
  items.insert(2, Cody.env) if Cody.settings.dig(:stack_naming, :append_env)
31
44
  items.reject(&:blank?).compact.join("-")
32
45
  end
@@ -44,13 +57,13 @@ module Cody::AwsServices
44
57
  #
45
58
  def inferred_stack_name(project_name)
46
59
  append_stack_name = Cody.settings.dig(:stack_naming, :append_stack_name) || "cody"
47
- items = [project_name, @options[:type], Cody.env_extra, append_stack_name]
60
+ items = [project_name, @options[:type], Cody.extra, append_stack_name]
48
61
  items.insert(3, Cody.env) if Cody.settings.dig(:stack_naming, :append_env)
49
62
  items.reject(&:blank?).reject {|i| i == false}.compact.join("-")
50
63
  end
51
64
 
52
65
  def are_you_sure?(stack_name, action)
53
- if @options[:sure]
66
+ if @options[:yes]
54
67
  sure = 'y'
55
68
  else
56
69
  message = case action
@@ -68,5 +81,9 @@ module Cody::AwsServices
68
81
  exit 0
69
82
  end
70
83
  end
84
+
85
+ def normalize_stack_name(name)
86
+ name.gsub('_','-') # cloudformation stack names dont allow _
87
+ end
71
88
  end
72
89
  end
@@ -27,7 +27,7 @@ module Cody
27
27
 
28
28
  desc "delete", "Delete codebuild project."
29
29
  long_desc Help.text(:delete)
30
- option :sure, desc: "Bypass are you sure prompt"
30
+ option :yes, aliases: %w[y], desc: "Bypass are you sure prompt"
31
31
  common_options.call
32
32
  def delete(project_name=nil)
33
33
  Delete.new(options.merge(project_name: project_name)).run
@@ -63,6 +63,8 @@ module Cody
63
63
  long_desc Help.text(:list)
64
64
  option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
65
65
  option :sort_by, desc: "Sort by column: name, status, time"
66
+ option :status, desc: "status filter. IE: SUCCEEDED, FAILED, FAULT, TIMED_OUT, IN_PROGRESS, STOPPED. Both upper and lowercase works."
67
+ option :select, desc: "select filter on the project name. The select option gets converted to an Ruby regexp"
66
68
  def list
67
69
  List.new(options).run
68
70
  end
@@ -84,18 +86,6 @@ module Cody
84
86
  Badge.new(options.merge(project_name: project_name)).run
85
87
  end
86
88
 
87
- desc "completion *PARAMS", "Prints words for auto-completion."
88
- long_desc Help.text(:completion)
89
- def completion(*params)
90
- Completer.new(CLI, *params).run
91
- end
92
-
93
- desc "completion_script", "Generates a script that can be eval to setup auto-completion."
94
- long_desc Help.text(:completion_script)
95
- def completion_script
96
- Completer::Script.generate
97
- end
98
-
99
89
  desc "version", "prints version"
100
90
  def version
101
91
  puts VERSION
@@ -1,4 +1,4 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Badge < Base
3
3
  def run
4
4
  resp = codebuild.batch_get_projects(names: [@full_project_name])
@@ -1,7 +1,7 @@
1
1
  # Base only for Stop and Start currently.
2
- module Cody
2
+ class Cody::CLI
3
3
  class Base
4
- include AwsServices
4
+ include Cody::AwsServices
5
5
 
6
6
  def initialize(options)
7
7
  @options = options
@@ -24,5 +24,11 @@ module Cody
24
24
  resp = codebuild.list_builds_for_project(project_name: @full_project_name)
25
25
  resp.ids.first # most recent build_id
26
26
  end
27
+
28
+ def check_build_id!
29
+ return if build_id
30
+ puts "WARN: No builds found for #{@project_name.color(:green)} project"
31
+ exit
32
+ end
27
33
  end
28
- end
34
+ end
@@ -1,11 +1,11 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Delete
3
- include AwsServices
3
+ include Cody::AwsServices
4
4
 
5
5
  def initialize(options)
6
6
  @options = options
7
7
  @project_name = options[:project_name] || inferred_project_name
8
- @stack_name = options[:stack_name] || inferred_stack_name(@project_name)
8
+ @stack_name = normalize_stack_name(options[:stack_name] || inferred_stack_name(@project_name))
9
9
  end
10
10
 
11
11
  def run
@@ -0,0 +1,7 @@
1
+ class Cody::CLI
2
+ class Deploy < Base
3
+ def run
4
+ Cody::Stack.new(@options).run
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ class Cody::CLI
2
+ module Help
3
+ class << self
4
+ def text(namespaced_command)
5
+ path = namespaced_command.to_s.gsub(':','/')
6
+ path = File.expand_path("../help/#{path}.md", __FILE__)
7
+ IO.read(path) if File.exist?(path)
8
+ end
9
+ end
10
+ end
11
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Init < Sequence
3
3
  # Ugly, this is how I can get the options from to match with this Thor::Group
4
4
  def self.cli_options
@@ -28,7 +28,6 @@ module Cody
28
28
  override_source_paths(custom_template)
29
29
  else # additive: modify on top of default template
30
30
  default_template = File.expand_path("../../template", __FILE__)
31
- puts "default_template: #{default_template}"
32
31
  override_source_paths([custom_template, default_template])
33
32
  end
34
33
  end
@@ -1,8 +1,8 @@
1
1
  require 'cli-format'
2
2
 
3
- module Cody
3
+ class Cody::CLI
4
4
  class List
5
- include AwsServices
5
+ include Cody::AwsServices
6
6
  extend Memoist
7
7
 
8
8
  def initialize(options)
@@ -18,13 +18,23 @@ module Cody
18
18
  presenter = CliFormat::Presenter.new(@options)
19
19
  presenter.header = ["Name", "Status", "Time"]
20
20
  projects.each do |project|
21
- presenter.rows << [project.name, project.build_status, project.end_time]
21
+ row = [project.name, project.build_status, project.end_time]
22
+ presenter.rows << row if show?(project.build_status)
22
23
  end
23
24
  presenter.show
24
25
  end
25
26
 
27
+ def show?(build_status)
28
+ status = @options[:status].upcase if @options[:status]
29
+ if status
30
+ build_status == status
31
+ else
32
+ true
33
+ end
34
+ end
35
+
26
36
  def projects
27
- projects = list_projects.map { |p| Project.new(p) }
37
+ projects = list_projects.map { |p| Cody::List::Project.new(p) }
28
38
  if @options[:sort_by]
29
39
  projects.sort_by { |p| p.send(@options[:sort_by]) }
30
40
  else
@@ -45,6 +55,10 @@ module Cody
45
55
  next_token = resp.next_token
46
56
  projects += resp.projects
47
57
  end
58
+ if @options[:select]
59
+ regexp = Regexp.new(@options[:select])
60
+ projects.select! { |p| p =~ regexp }
61
+ end
48
62
  projects
49
63
  end
50
64
  memoize :list_projects
@@ -1,8 +1,9 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Logs < Base
3
3
  def run
4
+ check_build_id!
4
5
  run_with_exception_handling do
5
- Tailer.new(@options, build_id).run
6
+ Cody::Tailer.new(@options, build_id).run
6
7
  end
7
8
  end
8
9
  end
@@ -1,16 +1,16 @@
1
1
  require 'fileutils'
2
2
  require 'thor'
3
3
 
4
- module Cody
4
+ class Cody::CLI
5
5
  class Sequence < Thor::Group
6
- include AwsServices
6
+ include Cody::AwsServices
7
7
  include Thor::Actions
8
8
 
9
9
  add_runtime_options! # force, pretend, quiet, skip options
10
10
  # https://github.com/erikhuda/thor/blob/master/lib/thor/actions.rb#L49
11
11
 
12
12
  def self.source_paths
13
- [File.expand_path("../../template", __FILE__)]
13
+ [File.expand_path("../../../template", __FILE__)]
14
14
  end
15
15
 
16
16
  private
@@ -1,6 +1,6 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Start
3
- include AwsServices
3
+ include Cody::AwsServices
4
4
 
5
5
  def initialize(options)
6
6
  @options = options
@@ -24,7 +24,7 @@ module Cody
24
24
  end
25
25
 
26
26
  def tail_logs(build_id)
27
- Tailer.new(@options, build_id).run
27
+ Cody::Tailer.new(@options, build_id).run
28
28
  end
29
29
 
30
30
  def environment_variables_override
@@ -54,8 +54,13 @@ module Cody
54
54
  end
55
55
  resource.physical_resource_id # codebuild project name
56
56
  else
57
- puts "ERROR: Unable to find the codebuild project with either full_project_name: #{@full_project_name} or project_name: #{@project_name}".color(:red)
58
- exit 1
57
+ message = "ERROR: Unable to find the codebuild project with either full_project_name: #{@full_project_name} or project_name: #{@project_name}"
58
+ if @options[:raise_error]
59
+ raise(message)
60
+ else
61
+ puts message.color(:red)
62
+ exit 1
63
+ end
59
64
  end
60
65
  end
61
66
 
@@ -1,6 +1,7 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Status < Base
3
3
  def run
4
+ check_build_id!
4
5
  run_with_exception_handling do
5
6
  puts "Build id: #{build_id}"
6
7
  resp = codebuild.batch_get_builds(ids: [build_id])
@@ -1,6 +1,7 @@
1
- module Cody
1
+ class Cody::CLI
2
2
  class Stop < Base
3
3
  def run
4
+ check_build_id!
4
5
  run_with_exception_handling do
5
6
  codebuild.stop_build(id: build_id)
6
7
  puts "Build has been stopped: #{build_id}"
@@ -13,6 +13,17 @@ class Thor
13
13
  end
14
14
  end
15
15
 
16
+ # Gets rid of the c_l_i extra commands in the help menu. Seems like thor_classes_in is only used
17
+ # for this purpose. More details: https://gist.github.com/tongueroo/ee92ec28a4d3eed301d88e8ccdd2fe10
18
+ module ThorPrepend
19
+ module Util
20
+ def thor_classes_in(klass)
21
+ klass.name.include?("CLI") ? [] : super
22
+ end
23
+ end
24
+ end
25
+ Thor::Util.singleton_class.prepend(ThorPrepend::Util)
26
+
16
27
  module Cody
17
28
  class Command < Thor
18
29
  class << self