tacoma 1.0.13 → 1.0.14
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.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/README.md +17 -15
- data/bin/tacoma +1 -2
- data/lib/tacoma/cache_environment.rb +15 -19
- data/lib/tacoma/command.rb +59 -66
- data/lib/tacoma/version.rb +1 -1
- data/lib/template/s3cfg +35 -35
- data/tacoma.gemspec +12 -13
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2cc55778f5dd0d7e576f56f0483072d248a209c
|
4
|
+
data.tar.gz: ea54584fe182d4cfa754d721892d52d968035964
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0393a9b07ac4a55666859553037e39fddc37cea4521cac1d78ce95d087663e8eca4f9eb2a107934930c9f182bc82eb0121c8849c4a3de2dbd68ef281ba37f22f
|
7
|
+
data.tar.gz: a0f8319b113b50a59f13ea5b5c1ff5ef5c974f806e83be3dcb19d7f0ec31b42b6a8d3e88bc7af2031c4b4875c029002184728b6d0534323a52a3bb17e82ee372
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -13,20 +13,22 @@ Tacoma needs a special file `.tacoma.yml` in your home directory. It can create
|
|
13
13
|
tacoma install
|
14
14
|
|
15
15
|
The format of the `.tacoma.yml` file is pretty straighforward
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
```yml
|
17
|
+
project:
|
18
|
+
aws_identity_file: "/path/to/pem/file/my_project.pem"
|
19
|
+
aws_secret_access_key: "YOURSECRETACCESSKEY"
|
20
|
+
aws_access_key_id: "YOURACCESSKEYID"
|
21
|
+
region: "REGION"
|
22
|
+
repo: "$HOME/projects/my_project"
|
23
|
+
another_project:
|
24
|
+
aws_identity_file: "/path/to/another_pem.pem"
|
25
|
+
aws_secret_access_key: "ANOTHERECRETACCESSKEY"
|
26
|
+
aws_access_key_id: "ANOTHERACCESSKEYID"
|
27
|
+
region: "REGION"
|
28
|
+
repo: "$HOME/projects/another_project"
|
29
|
+
s3cfg:
|
30
|
+
gpg_passphrase: my_gpg_passphrase
|
31
|
+
```
|
30
32
|
Once setup with a file like this, you can run
|
31
33
|
|
32
34
|
tacoma list
|
@@ -50,7 +52,7 @@ Running `tacoma switch` with the `--with-exports` option will also echo shell ex
|
|
50
52
|
Will display the current tacoma version and list all available configuration templates (providers).
|
51
53
|
|
52
54
|
tacoma current
|
53
|
-
|
55
|
+
|
54
56
|
Will display the currently active tacoma environment.
|
55
57
|
|
56
58
|
If you don't indicate a specific region, tacoma will use the "eu-west-1" region by default.
|
data/bin/tacoma
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
module CacheEnvironment
|
2
|
+
def environment_cache_path
|
3
|
+
"#{Dir.home}/.tacoma_current_environment"
|
4
|
+
end
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
begin
|
9
|
-
File.open(environment_cache_path, 'w') { |file| file.write(environment) }
|
10
|
-
rescue
|
11
|
-
puts "Cannot write at #{environment_cache_path}"
|
12
|
-
end
|
13
|
-
end
|
6
|
+
def update_environment_to_cache(environment)
|
7
|
+
File.open(environment_cache_path, 'w') { |file| file.write(environment) }
|
8
|
+
rescue StandardError
|
9
|
+
puts "Cannot write at #{environment_cache_path}"
|
10
|
+
end
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
str
|
12
|
+
def read_environment_from_cache
|
13
|
+
str = begin
|
14
|
+
File.open(environment_cache_path, &:readline)
|
15
|
+
rescue StandardError
|
16
|
+
nil
|
22
17
|
end
|
23
|
-
|
18
|
+
str
|
19
|
+
end
|
24
20
|
end
|
data/lib/tacoma/command.rb
CHANGED
@@ -2,13 +2,9 @@ require 'yaml'
|
|
2
2
|
require 'thor'
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
-
|
6
5
|
module Tacoma
|
7
|
-
|
8
|
-
|
9
|
-
|
10
6
|
module Tool
|
11
|
-
DEFAULT_AWS_REGION = 'eu-west-1'
|
7
|
+
DEFAULT_AWS_REGION = 'eu-west-1'.freeze
|
12
8
|
|
13
9
|
class << self
|
14
10
|
attr_accessor :aws_identity_file
|
@@ -16,29 +12,31 @@ module Tacoma
|
|
16
12
|
attr_accessor :aws_access_key_id
|
17
13
|
attr_accessor :region
|
18
14
|
attr_accessor :repo
|
15
|
+
attr_accessor :s3cfg
|
19
16
|
|
20
|
-
include CacheEnvironment
|
17
|
+
include CacheEnvironment
|
21
18
|
|
22
19
|
def config
|
23
|
-
filename = File.join(Dir.home,
|
24
|
-
|
20
|
+
filename = File.join(Dir.home, '.tacoma.yml')
|
21
|
+
YAML.load_file(filename)
|
25
22
|
end
|
26
23
|
|
27
24
|
def load_vars(environment)
|
28
25
|
return false unless exists?(environment)
|
29
26
|
|
30
|
-
config = Tool.config
|
27
|
+
config = Tool.config
|
31
28
|
@aws_identity_file = config[environment]['aws_identity_file']
|
32
29
|
@aws_secret_access_key = config[environment]['aws_secret_access_key']
|
33
30
|
@aws_access_key_id = config[environment]['aws_access_key_id']
|
34
31
|
@region = config[environment]['region'] || DEFAULT_AWS_REGION
|
35
32
|
@repo = config[environment]['repo']
|
33
|
+
@s3cfg = config[environment]['s3cfg'] || {}
|
36
34
|
validate_vars
|
37
35
|
end
|
38
|
-
|
36
|
+
|
39
37
|
# Assume there is a ~/.aws/credentials file with a valid format
|
40
38
|
def current_environment
|
41
|
-
|
39
|
+
read_environment_from_cache
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
@@ -46,7 +44,7 @@ module Tacoma
|
|
46
44
|
# shows error message if any attr is missing
|
47
45
|
# return false if any attr is missing to exit the program
|
48
46
|
def validate_vars
|
49
|
-
errors =
|
47
|
+
errors = instance_variables.map do |var|
|
50
48
|
next unless instance_variable_get(var).to_s.empty?
|
51
49
|
"Cannot find #{var} key, check your YAML config file."
|
52
50
|
end.compact
|
@@ -56,71 +54,64 @@ module Tacoma
|
|
56
54
|
|
57
55
|
def exists?(environment)
|
58
56
|
config = Tool.config
|
59
|
-
if config.keys.include?(environment)
|
60
|
-
|
61
|
-
return false
|
62
|
-
else
|
63
|
-
return true
|
64
|
-
end
|
57
|
+
return true if config.keys.include?(environment)
|
58
|
+
puts "Cannot find #{environment} key, check your YAML config file"
|
65
59
|
end
|
66
60
|
end
|
67
61
|
end
|
68
62
|
|
69
63
|
class Command < Thor
|
70
|
-
|
71
64
|
include Thor::Actions
|
72
65
|
|
73
|
-
include CacheEnvironment
|
66
|
+
include CacheEnvironment
|
74
67
|
|
75
|
-
desc
|
68
|
+
desc 'list', 'Lists all known AWS environments'
|
76
69
|
def list
|
77
|
-
Tool.config.
|
70
|
+
Tool.config.each_key do |key|
|
78
71
|
puts key
|
79
72
|
end
|
80
73
|
end
|
81
74
|
|
82
|
-
TOOLS = {fog: '.fog',
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
75
|
+
TOOLS = { fog: '.fog',
|
76
|
+
boto: '.boto',
|
77
|
+
s3cfg: '.s3cfg',
|
78
|
+
route53: '.route53',
|
79
|
+
aws_credentials: '.aws/credentials' }.freeze
|
87
80
|
|
88
|
-
desc
|
81
|
+
desc 'version', 'Displays current tacoma version'
|
89
82
|
def version
|
90
83
|
puts "tacoma, version #{Tacoma::VERSION}"
|
91
|
-
puts
|
84
|
+
puts 'Configuration templates available for:'
|
92
85
|
TOOLS.each do |tool, config_path|
|
93
|
-
puts " #{tool
|
86
|
+
puts " #{tool} => '~/#{config_path}'"
|
94
87
|
end
|
95
88
|
end
|
96
89
|
|
97
|
-
desc
|
90
|
+
desc 'current', 'Displays current loaded tacoma environment'
|
98
91
|
def current
|
99
92
|
puts Tool.current_environment
|
100
|
-
|
93
|
+
true
|
101
94
|
end
|
102
|
-
|
103
|
-
desc
|
95
|
+
|
96
|
+
desc 'switch ENVIRONMENT', 'Prepares AWS config files for the providers. --with-exports will output environment variables'
|
104
97
|
option :'with-exports'
|
105
|
-
|
106
|
-
def switch(environment)
|
107
98
|
|
99
|
+
def switch(environment)
|
108
100
|
if Tool.load_vars(environment)
|
109
101
|
@aws_identity_file = Tool.aws_identity_file
|
110
102
|
@aws_secret_access_key = Tool.aws_secret_access_key
|
111
103
|
@aws_access_key_id = Tool.aws_access_key_id
|
112
104
|
@region = Tool.region
|
113
105
|
@repo = Tool.repo
|
114
|
-
|
115
|
-
|
106
|
+
@s3cfg = Tool.s3cfg
|
116
107
|
|
117
108
|
# set configurations for tools
|
118
109
|
TOOLS.each do |tool, config_path|
|
119
|
-
template_path =
|
110
|
+
template_path = build_template_path(tool)
|
120
111
|
file_path = File.join(Dir.home, config_path)
|
121
|
-
template template_path, file_path, :
|
112
|
+
template template_path, file_path, force: true
|
122
113
|
end
|
123
|
-
|
114
|
+
|
124
115
|
system("ssh-add #{@aws_identity_file}")
|
125
116
|
if options[:'with-exports']
|
126
117
|
puts "export AWS_SECRET_ACCESS_KEY=#{@aws_secret_access_key}"
|
@@ -129,48 +120,50 @@ module Tacoma
|
|
129
120
|
puts "export AWS_ACCESS_KEY_ID=#{@aws_access_key_id}"
|
130
121
|
puts "export AWS_DEFAULT_REGION=#{@region}"
|
131
122
|
end
|
132
|
-
|
123
|
+
|
133
124
|
update_environment_to_cache(environment)
|
134
|
-
|
135
|
-
|
125
|
+
|
126
|
+
true
|
136
127
|
else
|
137
|
-
|
128
|
+
false
|
138
129
|
end
|
139
130
|
end
|
140
131
|
|
141
|
-
desc
|
132
|
+
desc 'cd ENVIRONMENT', 'Change directory to the project path'
|
142
133
|
def cd(environment)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
134
|
+
return unless switch(environment)
|
135
|
+
|
136
|
+
Dir.chdir `echo #{@repo}`.strip
|
137
|
+
puts 'Welcome to the tacoma shell'
|
138
|
+
shell = ENV['SHELL'].split('/').last
|
139
|
+
options =
|
140
|
+
case shell
|
141
|
+
when 'zsh'
|
142
|
+
''
|
143
|
+
else
|
144
|
+
'--login'
|
145
|
+
end
|
146
|
+
system("#{shell} #{options}")
|
147
|
+
Process.kill(:SIGQUIT, Process.getpgid(Process.ppid))
|
157
148
|
end
|
158
149
|
|
159
|
-
desc
|
150
|
+
desc 'install', 'Create a sample ~/.tacoma.yml file'
|
160
151
|
def install
|
161
|
-
if
|
152
|
+
if File.exist?(File.join(Dir.home, '.tacoma.yml'))
|
162
153
|
puts "File ~/.tacoma.yml already present, won't overwrite"
|
163
154
|
else
|
164
|
-
template_path=
|
165
|
-
new_path = File.join(Dir.home,
|
155
|
+
template_path = build_template_path('tacoma.yml')
|
156
|
+
new_path = File.join(Dir.home, '.tacoma.yml')
|
166
157
|
template template_path, new_path
|
167
158
|
end
|
168
159
|
end
|
169
160
|
|
161
|
+
def build_template_path(template_name)
|
162
|
+
"#{self.class.source_root}/../template/#{template_name}".realpath.to_s
|
163
|
+
end
|
164
|
+
|
170
165
|
def self.source_root
|
171
166
|
File.dirname(__FILE__)
|
172
167
|
end
|
173
|
-
|
174
168
|
end
|
175
|
-
|
176
169
|
end
|
data/lib/tacoma/version.rb
CHANGED
data/lib/template/s3cfg
CHANGED
@@ -1,38 +1,38 @@
|
|
1
1
|
[default]
|
2
2
|
access_key = <%= @aws_access_key_id %>
|
3
|
-
bucket_location = US
|
4
|
-
cloudfront_host = cloudfront.amazonaws.com
|
5
|
-
cloudfront_resource = /2010-07-15/distribution
|
6
|
-
default_mime_type = binary/octet-stream
|
7
|
-
delete_removed = False
|
8
|
-
dry_run = False
|
9
|
-
encoding = UTF-8
|
10
|
-
encrypt = False
|
11
|
-
follow_symlinks = False
|
12
|
-
force = False
|
13
|
-
get_continue = False
|
14
|
-
gpg_command = None
|
15
|
-
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
|
16
|
-
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
|
17
|
-
gpg_passphrase =
|
18
|
-
guess_mime_type = True
|
19
|
-
host_base = s3.amazonaws.com
|
20
|
-
host_bucket = %(bucket)s.s3.amazonaws.com
|
21
|
-
human_readable_sizes = False
|
22
|
-
list_md5 = False
|
23
|
-
log_target_prefix =
|
24
|
-
preserve_attrs = True
|
25
|
-
progress_meter = True
|
26
|
-
proxy_host =
|
27
|
-
proxy_port = 0
|
28
|
-
recursive = False
|
29
|
-
recv_chunk = 4096
|
30
|
-
reduced_redundancy = False
|
3
|
+
bucket_location = <%= @s3cfg['bucket_location'] || 'US' %>
|
4
|
+
cloudfront_host = <%= @s3cfg['cloudfront_host'] || 'cloudfront.amazonaws.com' %>
|
5
|
+
cloudfront_resource = <%= @s3cfg['cloudfront_resource'] || '/2010-07-15/distribution' %>
|
6
|
+
default_mime_type = <%= @s3cfg['default_mime_type'] || 'binary/octet-stream' %>
|
7
|
+
delete_removed = <%= @s3cfg['delete_removed'] || 'False' %>
|
8
|
+
dry_run = <%= @s3cfg['dry_run'] || 'False' %>
|
9
|
+
encoding = <%= @s3cfg['encoding'] || 'UTF-8' %>
|
10
|
+
encrypt = <%= @s3cfg['encrypt'] || 'False' %>
|
11
|
+
follow_symlinks = <%= @s3cfg['follow_symlinks'] || 'False' %>
|
12
|
+
force = <%= @s3cfg['force'] || 'False' %>
|
13
|
+
get_continue = <%= @s3cfg['get_continue'] || 'False' %>
|
14
|
+
gpg_command = <%= @s3cfg['gpg_command'] || 'None' %>
|
15
|
+
gpg_decrypt = <%= @s3cfg['gpg_decrypt'] || '%(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s' %>
|
16
|
+
gpg_encrypt = <%= @s3cfg['gpg_encrypt'] || '%(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s' %>
|
17
|
+
gpg_passphrase = <%= @s3cfg['gpg_passphrase'] || '' %>
|
18
|
+
guess_mime_type = <%= @s3cfg['guess_mime_type'] || 'True' %>
|
19
|
+
host_base = <%= @s3cfg['host_base'] || 's3.amazonaws.com' %>
|
20
|
+
host_bucket = <%= @s3cfg['host_bucket'] || '%(bucket)s.s3.amazonaws.com' %>
|
21
|
+
human_readable_sizes = <%= @s3cfg['human_readable_sizes'] || 'False' %>
|
22
|
+
list_md5 = <%= @s3cfg['list_md5'] || 'False' %>
|
23
|
+
log_target_prefix = <%= @s3cfg['log_target_prefix'] || '' %>
|
24
|
+
preserve_attrs = <%= @s3cfg['preserve_attrs'] || 'True' %>
|
25
|
+
progress_meter = <%= @s3cfg['progress_meter'] || 'True' %>
|
26
|
+
proxy_host = <%= @s3cfg['proxy_host'] || '' %>
|
27
|
+
proxy_port = <%= @s3cfg['proxy_port'] || '0' %>
|
28
|
+
recursive = <%= @s3cfg['recursive'] || 'False' %>
|
29
|
+
recv_chunk = <%= @s3cfg['recv_chunk'] || '4096' %>
|
30
|
+
reduced_redundancy = <%= @s3cfg['reduced_redundancy'] || 'False' %>
|
31
31
|
secret_key = <%= @aws_secret_access_key %>
|
32
|
-
send_chunk = 4096
|
33
|
-
simpledb_host = sdb.amazonaws.com
|
34
|
-
skip_existing = False
|
35
|
-
socket_timeout = 300
|
36
|
-
urlencoding_mode = normal
|
37
|
-
use_https = False
|
38
|
-
verbosity = WARNING
|
32
|
+
send_chunk = <%= @s3cfg['send_chunk'] || '4096' %>
|
33
|
+
simpledb_host = <%= @s3cfg['simpledb_host'] || 'sdb.amazonaws.com' %>
|
34
|
+
skip_existing = <%= @s3cfg['skip_existing'] || 'False' %>
|
35
|
+
socket_timeout = <%= @s3cfg['socket_timeout'] || '300' %>
|
36
|
+
urlencoding_mode = <%= @s3cfg['urlencoding_mode'] || 'normal' %>
|
37
|
+
use_https = <%= @s3cfg['use_https'] || 'False' %>
|
38
|
+
verbosity = <%= @s3cfg['verbosity'] || 'WARNING' %>
|
data/tacoma.gemspec
CHANGED
@@ -3,23 +3,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'tacoma/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'tacoma'
|
7
7
|
spec.version = Tacoma::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
-
spec.description =
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
8
|
+
spec.authors = ['Juan Lupión']
|
9
|
+
spec.email = ['pantulis@gmail.com']
|
10
|
+
spec.description = 'Easy command line tool for AWS credentials management'
|
11
|
+
spec.summary = 'This tool reads a YAML file with the credentials for your AWS accounts and loads them into your environment.'
|
12
|
+
spec.homepage = 'https://github.com/pantulis/tacoma'
|
13
|
+
spec.license = 'MIT'
|
14
14
|
|
15
|
-
spec.files = `git ls-files`.split(
|
15
|
+
spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
|
21
20
|
spec.add_runtime_dependency 'thor', '~> 0'
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 0'
|
22
|
+
spec.add_development_dependency 'minitest', '~> 0'
|
23
|
+
spec.add_development_dependency 'rake', '~> 0'
|
25
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tacoma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Lupión
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|