cody 0.9.7 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -9
- data/CHANGELOG.md +24 -0
- data/Gemfile +0 -2
- data/cody.gemspec +3 -3
- data/lib/cody.rb +4 -8
- data/lib/cody/aws_services.rb +1 -1
- data/lib/cody/aws_services/helpers.rb +20 -3
- data/lib/cody/cli.rb +3 -13
- data/lib/cody/{badge.rb → cli/badge.rb} +1 -1
- data/lib/cody/{base.rb → cli/base.rb} +9 -3
- data/lib/cody/{delete.rb → cli/delete.rb} +3 -3
- data/lib/cody/cli/deploy.rb +7 -0
- data/lib/cody/cli/help.rb +11 -0
- data/lib/cody/{help → cli/help}/deploy.md +0 -0
- data/lib/cody/{help → cli/help}/init.md +0 -0
- data/lib/cody/{help → cli/help}/logs.md +0 -0
- data/lib/cody/{help → cli/help}/start.md +0 -0
- data/lib/cody/{help → cli/help}/stop.md +0 -0
- data/lib/cody/{init.rb → cli/init.rb} +1 -2
- data/lib/cody/{list.rb → cli/list.rb} +18 -4
- data/lib/cody/{logs.rb → cli/logs.rb} +3 -2
- data/lib/cody/{sequence.rb → cli/sequence.rb} +3 -3
- data/lib/cody/{start.rb → cli/start.rb} +10 -5
- data/lib/cody/{status.rb → cli/status.rb} +2 -1
- data/lib/cody/{stop.rb → cli/stop.rb} +2 -1
- data/lib/cody/command.rb +11 -0
- data/lib/cody/core.rb +5 -5
- data/lib/cody/dsl/base.rb +9 -0
- data/lib/cody/dsl/project.rb +67 -49
- data/lib/cody/dsl/role.rb +11 -11
- data/lib/cody/dsl/schedule.rb +8 -8
- data/lib/cody/list/no_builds_project.rb +1 -1
- data/lib/cody/list/project.rb +1 -1
- data/lib/cody/project.rb +22 -23
- data/lib/cody/role.rb +20 -20
- data/lib/cody/schedule.rb +37 -37
- data/lib/cody/stack.rb +16 -71
- data/lib/cody/stack/base.rb +104 -0
- data/lib/cody/{create.rb → stack/create.rb} +2 -2
- data/lib/cody/{update.rb → stack/update.rb} +2 -2
- data/lib/cody/tailer.rb +9 -1
- data/lib/cody/version.rb +1 -1
- data/lib/template/project/buildspec.yml +1 -1
- data/lib/template/project/project.rb.tt +5 -19
- metadata +65 -71
- data/lib/cody/completer.rb +0 -159
- data/lib/cody/completer/script.rb +0 -6
- data/lib/cody/completer/script.sh +0 -10
- data/lib/cody/deploy.rb +0 -40
- data/lib/cody/help.rb +0 -9
- data/lib/cody/help/completion.md +0 -22
- data/lib/cody/help/completion_script.md +0 -3
- data/vendor/aws_data/CHANGELOG.md +0 -7
- data/vendor/aws_data/Gemfile +0 -4
- data/vendor/aws_data/LICENSE.txt +0 -21
- data/vendor/aws_data/README.md +0 -42
- data/vendor/aws_data/Rakefile +0 -6
- data/vendor/aws_data/aws_data.gemspec +0 -30
- data/vendor/aws_data/bin/console +0 -14
- data/vendor/aws_data/bin/setup +0 -8
- data/vendor/aws_data/lib/aws_data.rb +0 -91
- data/vendor/aws_data/lib/aws_data/version.rb +0 -3
- data/vendor/aws_data/spec/aws_data_spec.rb +0 -5
- data/vendor/aws_data/spec/spec_helper.rb +0 -14
- data/vendor/cfn-status/Gemfile +0 -4
- data/vendor/cfn-status/LICENSE.txt +0 -21
- data/vendor/cfn-status/README.md +0 -56
- data/vendor/cfn-status/Rakefile +0 -6
- data/vendor/cfn-status/bin/console +0 -14
- data/vendor/cfn-status/bin/setup +0 -8
- data/vendor/cfn-status/cfn-status.gemspec +0 -30
- data/vendor/cfn-status/lib/cfn/aws_service.rb +0 -56
- data/vendor/cfn-status/lib/cfn/status.rb +0 -220
- data/vendor/cfn-status/lib/cfn/status/version.rb +0 -5
- data/vendor/cfn-status/spec/cfn/status_spec.rb +0 -81
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
- data/vendor/cfn-status/spec/spec_helper.rb +0 -14
- data/vendor/cfn_camelizer/CHANGELOG.md +0 -10
- data/vendor/cfn_camelizer/Gemfile +0 -4
- data/vendor/cfn_camelizer/LICENSE.txt +0 -21
- data/vendor/cfn_camelizer/README.md +0 -40
- data/vendor/cfn_camelizer/Rakefile +0 -6
- data/vendor/cfn_camelizer/bin/console +0 -14
- data/vendor/cfn_camelizer/bin/setup +0 -8
- data/vendor/cfn_camelizer/cfn_camelizer.gemspec +0 -32
- data/vendor/cfn_camelizer/lib/camelizer.yml +0 -33
- data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +0 -92
- data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +0 -3
- data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +0 -79
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88a3ea8598603639f718e4f0abccdde3c1a1f822be72cb2f4394dffccc7cbd14
|
4
|
+
data.tar.gz: 0ca4437cbc6574b4b33f180808fc131ab2631ce73b49f387321936f3937390c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492d26d995e252031c78b306e49ea494d823f657ea7c80e94fa053732cfe6ebd285ef098478a9bfc72c234504dac214621a9d49abcb119a377c94fa77e428846
|
7
|
+
data.tar.gz: '0299c29a77b4534be575aac58d38bd5c2da97f913ecc876eb8c1b4141b22005034c537581515f0825ac2f8e9d66e2f93c9fe659d71be608e532e8c86b6785f4a'
|
data/.gitmodules
CHANGED
@@ -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
|
data/CHANGELOG.md
CHANGED
@@ -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
data/cody.gemspec
CHANGED
@@ -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"
|
data/lib/cody.rb
CHANGED
@@ -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
|
data/lib/cody/aws_services.rb
CHANGED
@@ -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.
|
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.
|
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[:
|
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
|
data/lib/cody/cli.rb
CHANGED
@@ -27,7 +27,7 @@ module Cody
|
|
27
27
|
|
28
28
|
desc "delete", "Delete codebuild project."
|
29
29
|
long_desc Help.text(:delete)
|
30
|
-
option :
|
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,7 +1,7 @@
|
|
1
1
|
# Base only for Stop and Start currently.
|
2
|
-
|
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
|
-
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
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
|
-
|
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
|
-
|
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,16 +1,16 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'thor'
|
3
3
|
|
4
|
-
|
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("
|
13
|
+
[File.expand_path("../../../template", __FILE__)]
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
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
|
-
|
58
|
-
|
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
|
|
data/lib/cody/command.rb
CHANGED
@@ -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
|