ecs-rails 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/bin/ecs +15 -0
- data/ecs-rails.gemspec +1 -0
- data/lib/ecs-rails/ecs_rails_configuration.rb +30 -8
- data/lib/ecs-rails/version.rb +1 -1
- data/lib/ecs-rails.rb +6 -8
- data/spec/ecs-rails/ecs_rails_configuration_spec.rb +29 -0
- data/spec/fixtures/ecs-rails.yml +2 -0
- metadata +18 -3
- data/spec/bin/ecs_spec.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c08e4e91434f407ea8df658c3493bffca339b819540d0c20a9cc6a46e62f8c2c
|
4
|
+
data.tar.gz: 982257395f3f3f4aff5eef242a1a8d3608ffa59c71bf9d87c4e6238ecd6843e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc00dadac2b0d17c2ab0c96312b2157f79b38f6c278e811080636d9d53e90986f8d731eccf2b1b78a994c7e8f5548b9735258aa1949b9352c6e2910d7de34e7
|
7
|
+
data.tar.gz: f18f580b67798d22634fd3e89e4d1fcd7cc96aac200653efb704aeb940ab4c4f8b504f221cd9574e4e8d612b05b5d6bf294d3bd713137a00e761e078d410a5bd
|
data/Gemfile
CHANGED
data/bin/ecs
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'byebug'
|
4
4
|
require 'optparse'
|
5
|
+
|
5
6
|
require_relative '../lib/ecs-rails'
|
6
7
|
|
7
8
|
options = {}
|
@@ -15,8 +16,22 @@ OptionParser.new do |opts|
|
|
15
16
|
opts.on("-s", "--service SERVICE_STRING", "Give a substring present in your service name. Ex: 'ecs console -c prod -s app' to connect to service webapp-app-prod-7c7cad7") do |c|
|
16
17
|
options[:service] = c
|
17
18
|
end
|
19
|
+
|
20
|
+
opts.on("-f", "--file-path FILE_PATH", "file path to yaml config file") do |c|
|
21
|
+
options[:config_file] = c
|
22
|
+
end
|
23
|
+
|
18
24
|
end.parse!
|
19
25
|
|
20
26
|
command_keyword = ARGV[0]
|
21
27
|
|
28
|
+
if !options[:config_file].nil?
|
29
|
+
EcsRails.load_settings(options[:config_file])
|
30
|
+
else
|
31
|
+
EcsRails.aws_region = ENV['AWS_REGION']
|
32
|
+
EcsRails.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
33
|
+
EcsRails.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
34
|
+
EcsRails.container_name = ENV['CONTAINER_NAME'] || 'webapp'
|
35
|
+
end
|
36
|
+
|
22
37
|
EcsRails::CommandExecutor.call(command_keyword, options)
|
data/ecs-rails.gemspec
CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency "aws-sdk-ecs", "~> 1.132", "> 1.132"
|
25
25
|
s.add_runtime_dependency "aws-sdk-ec2", "~> 1.425", "> 1.425"
|
26
26
|
s.add_runtime_dependency "tty-prompt", "~> 0.23", "> 0.23"
|
27
|
+
s.add_runtime_dependency "activesupport", "> 5.2"
|
27
28
|
end
|
@@ -1,21 +1,37 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'singleton'
|
3
|
+
|
1
4
|
module EcsRails
|
2
5
|
class EcsRailsConfiguration
|
6
|
+
include Singleton
|
7
|
+
|
3
8
|
attr_accessor :aws_region
|
4
9
|
attr_accessor :aws_access_key_id
|
5
10
|
attr_accessor :aws_secret_access_key
|
6
11
|
attr_accessor :container_name
|
7
12
|
|
8
|
-
def self.
|
9
|
-
|
10
|
-
yield config if block_given?
|
11
|
-
end
|
13
|
+
def self.delegated
|
14
|
+
public_instance_methods - Singleton.instance_methods
|
12
15
|
end
|
13
16
|
|
14
17
|
def initialize
|
15
|
-
@aws_region =
|
16
|
-
@aws_access_key_id =
|
17
|
-
@aws_secret_access_key =
|
18
|
-
@container_name =
|
18
|
+
@aws_region = 'us-east-1'
|
19
|
+
@aws_access_key_id = nil
|
20
|
+
@aws_secret_access_key = nil
|
21
|
+
@container_name = 'webapp'
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_settings(file_path=nil)
|
25
|
+
file_path ||= default_settings_file_path
|
26
|
+
yaml = YAML.load_file(file_path)
|
27
|
+
yaml_settings = yaml['settings']
|
28
|
+
yaml_settings.each do |key, value|
|
29
|
+
send("#{key}=", value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def aws_region
|
34
|
+
@aws_region
|
19
35
|
end
|
20
36
|
|
21
37
|
def aws_region=(region)
|
@@ -34,5 +50,11 @@ module EcsRails
|
|
34
50
|
@container_name = container_name
|
35
51
|
end
|
36
52
|
|
53
|
+
private
|
54
|
+
|
55
|
+
def default_settings_file_path
|
56
|
+
File.join(Dir.pwd, 'config', 'ecs-rails.yml')
|
57
|
+
end
|
58
|
+
|
37
59
|
end
|
38
60
|
end
|
data/lib/ecs-rails/version.rb
CHANGED
data/lib/ecs-rails.rb
CHANGED
@@ -24,21 +24,19 @@ require_relative 'ecs-rails/console'
|
|
24
24
|
require_relative 'ecs-rails/bash'
|
25
25
|
require_relative 'ecs-rails/null_command'
|
26
26
|
|
27
|
+
# delegate
|
28
|
+
require 'active_support/core_ext/module/delegation'
|
27
29
|
|
28
30
|
# prompt
|
29
31
|
require "tty-prompt"
|
30
32
|
|
31
33
|
module EcsRails
|
32
34
|
|
33
|
-
@configuration = EcsRails::EcsRailsConfiguration.setup
|
34
|
-
|
35
35
|
class << self
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
def_delegators :@configuration, :aws_secret_access_key, :aws_secret_access_key=
|
41
|
-
def_delegators :@configuration, :container_name, :container_name=
|
36
|
+
def config
|
37
|
+
EcsRails::EcsRailsConfiguration.instance
|
38
|
+
end
|
39
|
+
delegate(*EcsRails::EcsRailsConfiguration.delegated, to: :config)
|
42
40
|
end
|
43
41
|
|
44
42
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EcsRails::EcsRailsConfiguration do
|
4
|
+
|
5
|
+
|
6
|
+
describe '#default' do
|
7
|
+
|
8
|
+
it 'sets region to us-east-1' do
|
9
|
+
expect(EcsRails.aws_region).to eq('us-east-1')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'set aws region' do
|
14
|
+
describe 'directly' do
|
15
|
+
it 'sets region to us-west-2' do
|
16
|
+
EcsRails.aws_region = 'us-west-2'
|
17
|
+
expect(EcsRails.aws_region).to eq('us-west-2')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe 'via configuration file' do
|
21
|
+
it 'sets region to us-west-2' do
|
22
|
+
EcsRails.load_settings('spec/fixtures/ecs-rails.yml')
|
23
|
+
expect(EcsRails.aws_region).to eq('us-west-2')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franck D'agostini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -104,6 +104,20 @@ dependencies:
|
|
104
104
|
- - ">"
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0.23'
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: activesupport
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '5.2'
|
114
|
+
type: :runtime
|
115
|
+
prerelease: false
|
116
|
+
version_requirements: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '5.2'
|
107
121
|
description: Connect to your AWS ECS tasks
|
108
122
|
email: franck.dagostini@gmail.com
|
109
123
|
executables:
|
@@ -130,7 +144,8 @@ files:
|
|
130
144
|
- lib/ecs-rails/service_selector.rb
|
131
145
|
- lib/ecs-rails/task_selector.rb
|
132
146
|
- lib/ecs-rails/version.rb
|
133
|
-
- spec/
|
147
|
+
- spec/ecs-rails/ecs_rails_configuration_spec.rb
|
148
|
+
- spec/fixtures/ecs-rails.yml
|
134
149
|
- spec/spec_helper.rb
|
135
150
|
homepage: https://rubygems.org/gems/ecs-rails
|
136
151
|
licenses:
|
data/spec/bin/ecs_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Ecs binary' do
|
4
|
-
|
5
|
-
context 'without arguments' do
|
6
|
-
it 'should run ecs help' do
|
7
|
-
output = EcsRails::CommandExecutor.call('', {})
|
8
|
-
expect(output).to include('You must specify a command')
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'with console command argument' do
|
13
|
-
it 'calls the command factory with correct command keyword' do
|
14
|
-
command_factory_instance = double('command_factory_instance')
|
15
|
-
|
16
|
-
expect(EcsRails::CommandFactory).to receive(:new).with('console', {}).and_return(command_factory_instance)
|
17
|
-
|
18
|
-
command_instance = double('command_instance')
|
19
|
-
|
20
|
-
expect(command_factory_instance).to receive(:command).and_return(command_instance)
|
21
|
-
expect(command_instance).to receive(:call)
|
22
|
-
|
23
|
-
EcsRails::CommandExecutor.call('bash', {})
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|