ec2-host 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef29cecf0c6f274808f15f1abcc4998c420ec289
4
- data.tar.gz: e06379b2c29923349d6326e295e42896753e8365
3
+ metadata.gz: c1eb20245f5a476fec6d84ce21697235b24ad6d2
4
+ data.tar.gz: 5de04a845db6fe32b690f31fe0c82ab70d8f1d68
5
5
  SHA512:
6
- metadata.gz: 8dbde2c0e7ffd9f7140e1ceff13986a8f5ac605fefcae7f5b83312354b0b2b9b70f3a28ece4329f8e4216c532d02077bf4bc021099f3d83fa190e325de3df3c7
7
- data.tar.gz: b946a0386ee1865dd768f48feb398b15a41529a527e954c7002b9ebf0754570a659c2f1ef23f7cf84df393fbd9ec0259b634879c05e27e976dbf09740ebfd030
6
+ metadata.gz: 745211b9aff4c00cd9c561f788b8eaa0c1764010ab161854750ef21aa1e822e8445c08bf47921bcd9ee198a6a60919ddfd371828b553960a78ca5432ffda5f2e
7
+ data.tar.gz: 2b8e7c3a2fb51bf199da07c710b9ccb1bf4ef43cf29ac7a0010723c6566e9cdb081f91d4330e188eb4ba8361fb08023ca9c4d2834cd8896abef207989e263ffe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.3 (2015/08/10)
2
+
3
+ Enhancement:
4
+
5
+ * Add ROLE_TAG_DELIMITER and ARRAY_TAG_DELIMITER config
6
+
1
7
  # 0.0.2 (2015/08/10)
2
8
 
3
9
  Fixes:
data/README.md CHANGED
@@ -24,11 +24,13 @@ ec2-host parameters:
24
24
 
25
25
  * **HOSTNAME_TAG**: EC2 tag key used to express a hostname. The default is `Name`.
26
26
  * **ROLES_TAG**: EC2 tag keys used to express roles. The default is `Roles`
27
- * You can assign multiple roles seperated by `,` comma
28
- * Also, you can express levels of roles delimited by `:`.
27
+ * You can assign multiple roles seperated by `ARRAY_TAG_DELIMITER` (default: `,`)
28
+ * Also, you can express levels of roles delimited by `ROLE_TAG_DELIMITER` (default `:`)
29
29
  * Example: admin:ami, then `EC2::Host.new(role: 'admin:ami')` and also `EC2::Host.new(role1: 'admin')` returns this host
30
+ * **ROLE_TAG_DELIMITER**: A delimiter to express levels of roles. Default is `:`
30
31
  * **OPTIONAL_STRING_TAGS**: You may add optional non-array tags. You can specify multiple tags like `Service,Status`.
31
- * **OPTIONAL_ARRAY_TAGS**: You may add optional array tags. Array tags allows multiple values delimited by `,` (comma) as `Roles` tag.
32
+ * **OPTIONAL_ARRAY_TAGS**: You may add optional array tags. Array tags allows multiple values delimited by `ARRAY_TAG_DELIMITER` (default: `,`)
33
+ * **ARRAY_TAG_DELIMITER**: A delimiter to express array. Default is `,`
32
34
  * **LOG_LEVEL**: Log level such as `info`, `debug`, `error`. The default is `info`.
33
35
 
34
36
  See [sampel.conf](./sample.conf)
data/ec2-host.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "ec2-host"
3
- gem.version = '0.0.2'
3
+ gem.version = '0.0.3'
4
4
  gem.author = ['Naotoshi Seo']
5
5
  gem.email = ['sonots@gmail.com']
6
6
  gem.homepage = 'https://github.com/sonots/ec2-host'
data/lib/ec2/host.rb CHANGED
@@ -53,9 +53,6 @@ class EC2
53
53
  Config.configure(params)
54
54
  end
55
55
 
56
- ARRAY_TAG_DELIMITER = ','
57
- ROLE_TAG_DELIMITER = ':'
58
-
59
56
  attr_reader :conditions, :options
60
57
 
61
58
  # @param [Array of Hash, or Hash] conditions (and options)
data/lib/ec2/host/cli.rb CHANGED
@@ -18,15 +18,15 @@ class EC2
18
18
  option :role1,
19
19
  :aliases => %w[--r1 --usage1 --u1], # hmm, -r1 is not suppored by thor
20
20
  :type => :array,
21
- :desc => "role1, the 1st part of role delimited by #{ROLE_TAG_DELIMITER}"
21
+ :desc => "role1, the 1st part of role delimited by #{Config.role_tag_delimiter}"
22
22
  option :role2,
23
23
  :aliases => %w[--r2 --usage2 --u2],
24
24
  :type => :array,
25
- :desc => "role2, the 2nd part of role delimited by #{ROLE_TAG_DELIMITER}"
25
+ :desc => "role2, the 2nd part of role delimited by #{Config.role_tag_delimiter}"
26
26
  option :role3,
27
27
  :aliases => %w[--r3 --usage3 --u3],
28
28
  :type => :array,
29
- :desc => "role3, the 3rd part of role delimited by #{ROLE_TAG_DELIMITER}"
29
+ :desc => "role3, the 3rd part of role delimited by #{Config.role_tag_delimiter}"
30
30
  Config.optional_options.each do |opt, tag|
31
31
  option opt, :type => :array, :desc => opt
32
32
  end
@@ -69,6 +69,14 @@ class EC2
69
69
  @optional_string_tags ||= (ENV['OPTIONAL_STRING_TAGS'] || config.fetch('OPTIONAL_STRING_TAGS', '')).split(',')
70
70
  end
71
71
 
72
+ def self.role_tag_delimiter
73
+ @role_tag_delimiter ||= ENV['ROLE_TAG_DELIMITER'] || config.fetch('ROLE_TAG_DELIMITER', ':')
74
+ end
75
+
76
+ def self.array_tag_delimiter
77
+ @array_tag_delimiter ||= ENV['ARRAY_TAG_DELIMITER'] || config.fetch('ARRAY_TAG_DELIMITER', ',')
78
+ end
79
+
72
80
  # private
73
81
 
74
82
  def self.aws_credentials
@@ -121,7 +121,7 @@ class EC2
121
121
 
122
122
  def find_array_tag(key)
123
123
  v = instance.tags.find {|tag| tag.key == key }
124
- v ? v.value.split(ARRAY_TAG_DELIMITER) : []
124
+ v ? v.value.split(Config.array_tag_delimiter) : []
125
125
  end
126
126
  end
127
127
  end
@@ -7,13 +7,13 @@ class EC2
7
7
  # Represents each role
8
8
  class RoleData
9
9
  def self.initialize(role)
10
- role1, role2, role3 = role.split(ROLE_TAG_DELIMITER)
10
+ role1, role2, role3 = role.split(Config.role_tag_delimiter)
11
11
  self.new(role1, role2, role3)
12
12
  end
13
13
 
14
14
  # @return [String] something like "admin:jenkins:slave"
15
15
  def role
16
- @role ||= [role1, role2, role3].compact.reject(&:empty?).join(ROLE_TAG_DELIMITER)
16
+ @role ||= [role1, role2, role3].compact.reject(&:empty?).join(Config.role_tag_delimiter)
17
17
  end
18
18
  alias :to_s :role
19
19
 
data/sample.conf CHANGED
@@ -3,6 +3,8 @@ AWS_SECRET_ACCESS_KEY=xxxxxx
3
3
  AWS_REGION=ap-northeast-1
4
4
  HOSTNAME_TAG=Name
5
5
  ROLES_TAG=Roles
6
- OPTIONAL_ARRAY_TAGS=Tags
6
+ ROLE_TAG_DELIMITER=:
7
7
  OPTIONAL_STRING_TAGS=Service,Status
8
+ OPTIONAL_ARRAY_TAGS=Tags
9
+ ARRAY_TAG_DELIMITER=,
8
10
  LOG_LEVEL=info
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo