cody 0.9.8 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -9
  3. data/CHANGELOG.md +23 -0
  4. data/Gemfile +0 -2
  5. data/cody.gemspec +4 -4
  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 +2 -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} +7 -3
  22. data/lib/cody/cli/logs.rb +10 -0
  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 +69 -75
  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/lib/cody/logs.rb +0 -14
  55. data/vendor/aws_data/CHANGELOG.md +0 -7
  56. data/vendor/aws_data/Gemfile +0 -4
  57. data/vendor/aws_data/LICENSE.txt +0 -21
  58. data/vendor/aws_data/README.md +0 -42
  59. data/vendor/aws_data/Rakefile +0 -6
  60. data/vendor/aws_data/aws_data.gemspec +0 -30
  61. data/vendor/aws_data/bin/console +0 -14
  62. data/vendor/aws_data/bin/setup +0 -8
  63. data/vendor/aws_data/lib/aws_data.rb +0 -91
  64. data/vendor/aws_data/lib/aws_data/version.rb +0 -3
  65. data/vendor/aws_data/spec/aws_data_spec.rb +0 -5
  66. data/vendor/aws_data/spec/spec_helper.rb +0 -14
  67. data/vendor/cfn-status/Gemfile +0 -4
  68. data/vendor/cfn-status/LICENSE.txt +0 -21
  69. data/vendor/cfn-status/README.md +0 -56
  70. data/vendor/cfn-status/Rakefile +0 -6
  71. data/vendor/cfn-status/bin/console +0 -14
  72. data/vendor/cfn-status/bin/setup +0 -8
  73. data/vendor/cfn-status/cfn-status.gemspec +0 -30
  74. data/vendor/cfn-status/lib/cfn/aws_service.rb +0 -56
  75. data/vendor/cfn-status/lib/cfn/status.rb +0 -220
  76. data/vendor/cfn-status/lib/cfn/status/version.rb +0 -5
  77. data/vendor/cfn-status/spec/cfn/status_spec.rb +0 -81
  78. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
  79. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
  80. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
  81. data/vendor/cfn-status/spec/spec_helper.rb +0 -14
  82. data/vendor/cfn_camelizer/CHANGELOG.md +0 -10
  83. data/vendor/cfn_camelizer/Gemfile +0 -4
  84. data/vendor/cfn_camelizer/LICENSE.txt +0 -21
  85. data/vendor/cfn_camelizer/README.md +0 -40
  86. data/vendor/cfn_camelizer/Rakefile +0 -6
  87. data/vendor/cfn_camelizer/bin/console +0 -14
  88. data/vendor/cfn_camelizer/bin/setup +0 -8
  89. data/vendor/cfn_camelizer/cfn_camelizer.gemspec +0 -32
  90. data/vendor/cfn_camelizer/lib/camelizer.yml +0 -33
  91. data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +0 -92
  92. data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +0 -3
  93. data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +0 -79
  94. 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: 5f84323d071291727d2b3bdf96dbcb4e2bc1e1059f67bcf55dc0a062fbd326e0
4
- data.tar.gz: e83e848a9b35fff1b555472c0fbcc5ec48f3068f5cae3c33b244b710928d1416
3
+ metadata.gz: a118fa82eafeb143c7566480627541b108c910a45147bb7d3211ea1bccae158e
4
+ data.tar.gz: e1505f9f0813a481eccdf1220b44b77879ff3720de6ee5ad8903056853d8568c
5
5
  SHA512:
6
- metadata.gz: d2ddb7689115463ee43717d0f647f73e320d17b3a468f9b6ba40d4c806bc8bd8f448e18c66d66d1674b28ca90d6898369523b4b16a3de02f11a2d68256c65768
7
- data.tar.gz: 4c21a9d3ab5019335dd2f11453efcc7e6726815d41d5a0dc68531c07ca2c3e11b7eff174d1c5d93808f9647ab257f137df3078abdc6ce49e5d301f387390c9fd
6
+ metadata.gz: 91a9d29d494a3b75f0f0752924baa5f06236c4d93017f1f02cf0f9059d167de10600fae3f62d5cf7db543c733a7fe4c53dc39ef522329ad0c2cc8df3f2e1606c
7
+ data.tar.gz: bad64d35ea10286323bd76d735f8b71e10d81b7b37e327a81137c3e1a2d17735fdc73f260277cf577cd1bb072f10aedd0d93410e3250d1a3f3da62460e250334
@@ -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,29 @@
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.4] - 2021-01-08
7
+ - loosen activesupport version pin
8
+
9
+ ## [1.0.3] - 2021-01-08
10
+ - [#31](https://github.com/tongueroo/cody/pull/31) surface context message with error message for during provisioning fa…
11
+ - docs: update ci jets v3
12
+ - raise error option
13
+
14
+ ## [1.0.2]
15
+ - #30 Allow multiple git providers
16
+
17
+ ## [1.0.1]
18
+ - fix EventsRuleRole Service camelcase
19
+
20
+ ## [1.0.0]
21
+ - Breaking changes: CamelCase for properties instead of underscore. Map straight to the CloudFormation resource to remove mental overhead.
22
+ - See: https://cody.run/docs/upgrading/
23
+ - Use unfrozen gems instead of vendors gems: aws_data, cfn-status, cfn_camelizer.
24
+ - Update templates to use the latest
25
+ - Restructure classes to use CLI namespace
26
+ - Change delete: `--sure` to `--yes` option. `-y` shorthand.
27
+ - Rename CODY_EXTRA env variable
28
+
6
29
  ## [0.9.8]
7
30
  - add minimal deploy iam policy docs
8
31
  - list: add --status filter option
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
@@ -22,12 +22,15 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "activesupport", "~> 6.0.0"
25
+ spec.add_dependency "activesupport"
26
26
  spec.add_dependency "aws-logs"
27
27
  spec.add_dependency "aws-mfa-secure"
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
@@ -64,6 +64,7 @@ module Cody
64
64
  option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
65
65
  option :sort_by, desc: "Sort by column: name, status, time"
66
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"
67
68
  def list
68
69
  List.new(options).run
69
70
  end
@@ -85,18 +86,6 @@ module Cody
85
86
  Badge.new(options.merge(project_name: project_name)).run
86
87
  end
87
88
 
88
- desc "completion *PARAMS", "Prints words for auto-completion."
89
- long_desc Help.text(:completion)
90
- def completion(*params)
91
- Completer.new(CLI, *params).run
92
- end
93
-
94
- desc "completion_script", "Generates a script that can be eval to setup auto-completion."
95
- long_desc Help.text(:completion_script)
96
- def completion_script
97
- Completer::Script.generate
98
- end
99
-
100
89
  desc "version", "prints version"
101
90
  def version
102
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)
@@ -34,7 +34,7 @@ module Cody
34
34
  end
35
35
 
36
36
  def projects
37
- projects = list_projects.map { |p| Project.new(p) }
37
+ projects = list_projects.map { |p| Cody::List::Project.new(p) }
38
38
  if @options[:sort_by]
39
39
  projects.sort_by { |p| p.send(@options[:sort_by]) }
40
40
  else
@@ -55,6 +55,10 @@ module Cody
55
55
  next_token = resp.next_token
56
56
  projects += resp.projects
57
57
  end
58
+ if @options[:select]
59
+ regexp = Regexp.new(@options[:select])
60
+ projects.select! { |p| p =~ regexp }
61
+ end
58
62
  projects
59
63
  end
60
64
  memoize :list_projects
@@ -0,0 +1,10 @@
1
+ class Cody::CLI
2
+ class Logs < Base
3
+ def run
4
+ check_build_id!
5
+ run_with_exception_handling do
6
+ Cody::Tailer.new(@options, build_id).run
7
+ end
8
+ end
9
+ end
10
+ 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
@@ -19,12 +19,12 @@ module Cody
19
19
  end
20
20
  memoize :env
21
21
 
22
- def env_extra
23
- env_extra = ENV['CODY_ENV_EXTRA'] if ENV['CODY_ENV_EXTRA'] # highest precedence
24
- return if env_extra&.empty?
25
- env_extra
22
+ def extra
23
+ extra = ENV['CODY_EXTRA'] if ENV['CODY_EXTRA'] # highest precedence
24
+ return if extra&.empty?
25
+ extra
26
26
  end
27
- memoize :env_extra
27
+ memoize :extra
28
28
 
29
29
  # Overrides AWS_PROFILE based on the Cody.env if set in configs/settings.yml
30
30
  # 2-way binding.