tacoma 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8310f820be44f0ffc85fbbd01ce2efb9028474d8
4
- data.tar.gz: fe8857502b48b144263b084421670df5c1ad0307
3
+ metadata.gz: 7671a33039dd0abccfbbcc88c7efed13253439b8
4
+ data.tar.gz: f4c1d1a2b23c01dd82a2d103b1ec95130b848d14
5
5
  SHA512:
6
- metadata.gz: 9f83ea8a3d456d8faf5f3ad1f1f9d1d51633a197a22a520f831fc8236eca3877ed44a9592f542a4c6df39bc8ebc927dd8cd21b44b3d467abeb90b16472174f20
7
- data.tar.gz: 0afe0672977d5094ac2a460dc332ee33f04f951765a4e0bacf439771dfd426e636309abb235eebab9e3ad52d9e23b15d4fbba8fac9eb05300871634c2bc80a17
6
+ metadata.gz: dad5d74aee8aef2678289fa14cbef7a61b0df78d231cf0b90e3a022d6cff9c08b5bdc2085d24a7fcad70783c63bfb56e50f37001280026513c7307ff95fe6368
7
+ data.tar.gz: d09385047512791d49be9aa98db74c0deca50a4a934d04ac8e0955c93966d89b181237b81747d0c20e381c6d7df5b5e70dfcbe7466160c6839619bd2fdde0183
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 1.0.11
2
+ - Current tacoma environment gets cached in $HOME/.tacoma_current_environment
1
3
  1.0.10
2
4
  - Added 'tacoma current' command, which will display the current tacoma environment
3
5
  1.0.9
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'thor'
1
+ source 'https://rubygems.org'
4
2
 
3
+ gemspec
data/README.md CHANGED
@@ -33,7 +33,7 @@ And it will list all the configured entries. Running
33
33
 
34
34
  tacoma switch project
35
35
 
36
- Will display the export commands for the AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID credential environment variables, will add the specified identity file into the SSH agent, and will generate configuration files for the supported tools, which at this time are
36
+ Will add the specified identity file into the SSH agent, and will generate configuration files for the supported tools, which at this time are
37
37
 
38
38
  - [Fog](https://github.com/fog/fog), which should work with Capistrano's capify-ec2.
39
39
  - [Boto](https://github.com/boto/boto)
@@ -41,12 +41,15 @@ Will display the export commands for the AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_I
41
41
  - [route53](https://github.com/pcorliss/ruby_route_53)
42
42
  - [aws cli](https://github.com/aws/aws-cli)
43
43
 
44
- Running tacoma switch with the --with-exports option will also echo shell export sentences for the most common incarnations of the AWS env vars.
44
+ Running `tacoma switch` with the `--with-exports` option will also echo shell export sentences for the most common incarnations of the AWS env vars.
45
45
 
46
46
  tacoma version
47
47
 
48
48
  Will display the current tacoma version and list all available configuration templates (providers).
49
49
 
50
+ tacoma current
51
+
52
+ Will display the currently active tacoma environment.
50
53
 
51
54
  ## Bash Completion
52
55
 
@@ -5,7 +5,7 @@ _tacoma()
5
5
  cur="${COMP_WORDS[COMP_CWORD]}"
6
6
  prev="${COMP_WORDS[COMP_CWORD-1]}"
7
7
 
8
- commands="cd help install list switch"
8
+ commands="cd current help install list switch version"
9
9
 
10
10
  case "${prev}" in
11
11
  cd)
data/lib/tacoma.rb CHANGED
@@ -1,2 +1,3 @@
1
+ require_relative './tacoma/cache_environment'
1
2
  require_relative './tacoma/command'
2
3
  require_relative './tacoma/version'
@@ -0,0 +1,24 @@
1
+ module CacheEnvironment
2
+
3
+ def environment_cache_path
4
+ "#{Dir.home}/.tacoma_current_environment"
5
+ end
6
+
7
+ def update_environment_to_cache(environment)
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
14
+
15
+ def read_environment_from_cache
16
+ str = begin
17
+ File.open(environment_cache_path, &:readline)
18
+ rescue
19
+ nil
20
+ end
21
+ str
22
+ end
23
+
24
+ end
@@ -5,13 +5,19 @@ require 'pathname'
5
5
 
6
6
  module Tacoma
7
7
 
8
+
9
+
8
10
  module Tool
11
+
12
+
9
13
  class << self
10
14
  attr_accessor :aws_identity_file
11
15
  attr_accessor :aws_secret_access_key
12
16
  attr_accessor :aws_access_key_id
13
17
  attr_accessor :repo
14
18
 
19
+ include CacheEnvironment
20
+
15
21
  def config
16
22
  filename = File.join(Dir.home, ".tacoma.yml")
17
23
  return YAML::load_file(filename)
@@ -34,19 +40,7 @@ module Tacoma
34
40
 
35
41
  # Assume there is a ~/.aws/credentials file with a valid format
36
42
  def current_environment
37
- current_filename = File.join(Dir.home, ".aws/credentials")
38
- File.open(current_filename).each do |line|
39
- if /aws_access_key_id/ =~ line
40
- current_access_key_id = line[20..-2] # beware the CRLF
41
- config = Tool.config
42
- for key in config.keys
43
- if config[key]['aws_access_key_id'] == current_access_key_id
44
- return "#{key}"
45
- end
46
- end
47
- end
48
- end
49
- nil
43
+ read_environment_from_cache
50
44
  end
51
45
  end
52
46
  end
@@ -55,6 +49,8 @@ module Tacoma
55
49
 
56
50
  include Thor::Actions
57
51
 
52
+ include CacheEnvironment
53
+
58
54
  desc "list", "Lists all known AWS environments"
59
55
  def list
60
56
  Tool.config.keys.each do |key|
@@ -94,6 +90,8 @@ module Tacoma
94
90
  @aws_access_key_id = Tool.aws_access_key_id
95
91
  @repo = Tool.repo
96
92
 
93
+
94
+
97
95
  # set configurations for tools
98
96
  TOOLS.each do |tool, config_path|
99
97
  template_path = Pathname.new("#{self.class.source_root}/../template/#{tool}").realpath.to_s
@@ -108,6 +106,9 @@ module Tacoma
108
106
  puts "export AWS_ACCESS_KEY=#{@aws_access_key_id}"
109
107
  puts "export AWS_ACCESS_KEY_ID=#{@aws_access_key_id}"
110
108
  end
109
+
110
+ update_environment_to_cache(environment)
111
+
111
112
  return true
112
113
  else
113
114
  return false
@@ -143,9 +144,9 @@ module Tacoma
143
144
  end
144
145
  end
145
146
 
146
- def self.source_root
147
- File.dirname(__FILE__)
148
- end
147
+ def self.source_root
148
+ File.dirname(__FILE__)
149
+ end
149
150
 
150
151
  end
151
152
 
@@ -1,3 +1,3 @@
1
1
  module Tacoma
2
- VERSION='1.0.10'
2
+ VERSION='1.0.11'
3
3
  end
data/tacoma.gemspec CHANGED
@@ -1,5 +1,3 @@
1
- require "bundler/setup"
2
-
3
1
  lib = File.expand_path('../lib', __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'tacoma/version'
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tacoma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
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: 2015-02-23 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Easy command line tool for AWS credentials management
@@ -74,13 +74,14 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - CHANGELOG
79
79
  - Gemfile
80
80
  - README.md
81
81
  - bin/tacoma
82
82
  - contrib/tacoma.completion.sh
83
83
  - lib/tacoma.rb
84
+ - lib/tacoma/cache_environment.rb
84
85
  - lib/tacoma/command.rb
85
86
  - lib/tacoma/version.rb
86
87
  - lib/template/aws_credentials
@@ -100,20 +101,19 @@ require_paths:
100
101
  - lib
101
102
  required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
- - - '>='
104
+ - - ">="
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
- - - '>='
109
+ - - ">="
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  requirements: []
112
113
  rubyforge_project:
113
- rubygems_version: 2.0.0
114
+ rubygems_version: 2.4.6
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: This tool reads a YAML file with the credentials for your AWS accounts and
117
118
  loads them into your environment.
118
119
  test_files: []
119
- has_rdoc: