Module: Fog::Bouncer
- Defined in:
- lib/fog/bouncer.rb,
lib/fog/bouncer/cli.rb,
lib/fog/bouncer/group.rb,
lib/fog/bouncer/source.rb,
lib/fog/bouncer/sources.rb,
lib/fog/bouncer/version.rb,
lib/fog/bouncer/cli/diff.rb,
lib/fog/bouncer/security.rb,
lib/fog/bouncer/protocols.rb,
lib/fog/bouncer/group_manager.rb,
lib/fog/bouncer/ip_permissions.rb,
lib/fog/bouncer/source_manager.rb
Defined Under Namespace
Modules: CLI, IPPermissions, Logger, Protocols, Sources Classes: DefinitionNotFound, Group, GroupManager, Protocol, Security, Source, SourceBlockRequired, SourceManager
Constant Summary collapse
- VERSION =
"0.2.7"
Class Method Summary collapse
-
.aws_account_id ⇒ Object
Public: An AWS account ID.
-
.doorlists ⇒ Object
Public: The available doorlists.
-
.fog ⇒ Object
Public: An establised fog AWS compute connection.
-
.instrument_with(logger) ⇒ Object
Public: Allows the user to specify a logger for the log messages that Fog::Bouncer produces.
-
.load(file) ⇒ Object
Public: Load a file for evaluation.
-
.log(data, &blk) ⇒ Object
Internal: Top level log method for use by Fog::Bouncer.
-
.logger ⇒ Object
Public: The logging location.
-
.pretend ⇒ Object
Public: Check the pretend state.
-
.pretend! ⇒ Object
Public: Start pretending.
-
.pretend=(value) ⇒ Object
Public: Set the pretend state.
-
.pretending? ⇒ Boolean
Public: Evaluate the pretend state.
-
.reset ⇒ Object
Public: Empty the doorlists.
-
.security(name, &block) ⇒ Object
Public: Create a doorlist.
- .specific_groups ⇒ Object
- .specific_groups=(groups) ⇒ Object
-
.while_pretending(&block) ⇒ Object
Public: Pretend while evaluating the given block.
Class Method Details
.aws_account_id ⇒ Object
29 30 31 |
# File 'lib/fog/bouncer.rb', line 29 def self.aws_account_id ENV['AWS_ACCOUNT_ID'] end |
.doorlists ⇒ Object
41 42 43 |
# File 'lib/fog/bouncer.rb', line 41 def self.doorlists @doorlists ||= {} end |
.fog ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/fog/bouncer.rb', line 53 def self.fog @fog ||= Fog::Compute.new( :provider => "AWS", :region => (ENV['PROVIDER_REGION'] || 'us-east-1'), :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] ) end |
.instrument_with(logger) ⇒ Object
73 74 75 |
# File 'lib/fog/bouncer.rb', line 73 def self.instrument_with(logger) @logger = logger end |
.load(file) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/fog/bouncer.rb', line 102 def self.load(file) if file && File.exists?(file) Fog::Bouncer.log(load: true, file: file) do instance_eval(File.read(file)) end end end |
.log(data, &blk) ⇒ Object
Internal: Top level log method for use by Fog::Bouncer
data = Logging data (typically a hash) blk = block to execute
Returns the response from calling the logger with the arguments
83 84 85 |
# File 'lib/fog/bouncer.rb', line 83 def self.log(data, &blk) logger.call({ 'fog-bouncer' => true, 'pretending' => pretending? }.merge(data), &blk) end |
.logger ⇒ Object
Public: The logging location
Returns an Object
90 91 92 |
# File 'lib/fog/bouncer.rb', line 90 def self.logger @logger || Fog::Bouncer::Logger.method(:log) end |
.pretend ⇒ Object
Public: Check the pretend state
Returns false or true if pretending
113 114 115 |
# File 'lib/fog/bouncer.rb', line 113 def self.pretend @pretend ||= false end |
.pretend! ⇒ Object
Public: Start pretending
Returns true
142 143 144 |
# File 'lib/fog/bouncer.rb', line 142 def self.pretend! @pretend = true end |
.pretend=(value) ⇒ Object
Public: Set the pretend state
Returns the given state
135 136 137 |
# File 'lib/fog/bouncer.rb', line 135 def self.pretend=(value) @pretend = value end |
.pretending? ⇒ Boolean
Public: Evaluate the pretend state
Returns true if pretending or false if not
149 150 151 |
# File 'lib/fog/bouncer.rb', line 149 def self.pretending? !!pretend end |
.reset ⇒ Object
Public: Empty the doorlists
Returns an empty Hash
156 157 158 |
# File 'lib/fog/bouncer.rb', line 156 def self.reset @doorlists = {} end |
.security(name, &block) ⇒ Object
Public: Create a doorlist
Example
Fog::Bouncer.security :private do
group "name", "description" do
...
end
end
# => Fog::Bouncer::Security
Returns a Fog::Bouncer::Security object
172 173 174 175 176 |
# File 'lib/fog/bouncer.rb', line 172 def self.security(name, &block) Fog::Bouncer.log(security: true, name: name) do doorlists[name] = Fog::Bouncer::Security.new(name, specific_groups, &block) end end |
.specific_groups ⇒ Object
178 179 180 |
# File 'lib/fog/bouncer.rb', line 178 def self.specific_groups @specific_groups ||= [] end |
.specific_groups=(groups) ⇒ Object
182 183 184 |
# File 'lib/fog/bouncer.rb', line 182 def self.specific_groups=(groups) @specific_groups = Array(groups) end |
.while_pretending(&block) ⇒ Object
Public: Pretend while evaluating the given block
Example
Fog::Bouncer.while_pretending do
...
end
Returns nothing
126 127 128 129 130 |
# File 'lib/fog/bouncer.rb', line 126 def self.while_pretending(&block) @pretend = true yield @pretend = false end |