piculet 0.0.2 → 0.1.0

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.
data/bin/piculet CHANGED
@@ -47,7 +47,7 @@ ARGV.options do |opt|
47
47
  exit 1
48
48
  end
49
49
  rescue => e
50
- $stderr.puts e
50
+ $stderr.puts("[ERROR] #{e.message}")
51
51
  exit 1
52
52
  end
53
53
  end
@@ -64,7 +64,7 @@ end
64
64
  begin
65
65
  logger = Piculet::Logger.instance
66
66
  logger.set_debug(options[:debug])
67
- client = Piculet::Client.new(options)
67
+ client = Piculet::Client.new(options)
68
68
 
69
69
  case mode
70
70
  when :export
@@ -122,7 +122,7 @@ rescue => e
122
122
  if options[:debug]
123
123
  raise e
124
124
  else
125
- $stderr.puts e
125
+ $stderr.puts("[ERROR] #{e.message}".red)
126
126
  exit 1
127
127
  end
128
128
  end
@@ -32,15 +32,26 @@ module Piculet
32
32
  end
33
33
 
34
34
  def ingress(&block)
35
+ if @ingress_is_defined
36
+ raise "SecurityGroup `#{@name}`: `ingress` is already defined"
37
+ end
38
+
35
39
  @result.ingress = Permissions.new(@name, :ingress, &block).result
40
+ @ingress_is_defined = true
36
41
  end
37
42
 
38
43
  def egress(&block)
44
+ if @egress_is_defined
45
+ raise "SecurityGroup `#{@name}`: `egress` is already defined"
46
+ end
47
+
39
48
  unless @vpc
40
49
  raise "SecurityGroup `#{@name}`: Cannot define `egress` in classic"
41
50
  end
42
51
 
43
52
  @result.egress = Permissions.new(@name, :egress, &block).result
53
+
54
+ @egress_is_defined = true
44
55
  end
45
56
  end # SecurityGroup
46
57
  end # EC2
@@ -1,5 +1,5 @@
1
1
  module Piculet
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
4
4
 
5
5
  Version = Piculet::VERSION
@@ -96,10 +96,14 @@ module Piculet
96
96
  when Array
97
97
  owner_id, group = src
98
98
 
99
- unless group =~ /\Asg-[0-9a-f]\Z/
99
+ unless group =~ /\Asg-[0-9a-f]+\Z/
100
100
  sg_coll = @options.ec2.security_groups.filter('group-name', group)
101
- sg_coll = sg_coll.filter('vpc-id', @security_group.vpc_id) if @security_group.vpc?
102
- sg_coll = sg_coll.filter('owner-id', owner_id) unless @options.ec2.own?(owner_id)
101
+
102
+ if @options.ec2.own?(owner_id)
103
+ sg_coll = sg_coll.filter('vpc-id', @security_group.vpc_id) if @security_group.vpc?
104
+ else
105
+ sg_coll = sg_coll.filter('owner-id', owner_id)
106
+ end
103
107
 
104
108
  unless (sg = sg_coll.first)
105
109
  raise "Can't find SecurityGroup: #{owner_id}/#{group} in #{@security_group.vpc_id || :classic}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piculet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: 535241775
139
+ hash: 998644499
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: 535241775
148
+ hash: 998644499
149
149
  requirements: []
150
150
  rubyforge_project:
151
151
  rubygems_version: 1.8.23