burdened-acrobat 0.3.4
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.org +93 -0
- data/burdened-acrobat.gemspec +17 -0
- data/lib/burdened-acrobat.rb +2 -0
- data/lib/burdened-acrobat/amazon.rb +3 -0
- data/lib/burdened-acrobat/amazon/contracts.rb +17 -0
- data/lib/burdened-acrobat/amazon/elb.rb +51 -0
- data/lib/burdened-acrobat/amazon/mixins.rb +31 -0
- data/lib/burdened-acrobat/contracts.rb +19 -0
- data/lib/burdened-acrobat/load_balancers.rb +101 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d2f6475fbd73830f64d12f22a332b99720c438b0
|
4
|
+
data.tar.gz: 925b341a98f9d00028314ea12d360d60f09832ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5614e4517497e25563c0849bfc27174e5684b3126d1d7fedf463fefe3e3e4380d79a4e3841791650e54bd1cd88b1321a0b505777ad5815bc42b910c91fba092
|
7
|
+
data.tar.gz: cf7ec3864f6f91c67179e6eda5a20cd8556be12d58cf497f4a700c61dedc53bde545ac3b519ad16e62fe2c7a43428b4bf0632943964408a1e967983d6f11fa50
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
The MIT License (MIT)
|
3
|
+
Copyright © 2016 Chris Olstrom <chris@olstrom.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the “Software”), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.org
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#+TITLE: Burdened Acrobat
|
2
|
+
#+LATEX: \pagebreak
|
3
|
+
|
4
|
+
* Overview
|
5
|
+
|
6
|
+
=burdened-acrobat= helps identity specific load balancers (or groups of load
|
7
|
+
balancers), when you have an unreasonable number of them. It does this by
|
8
|
+
treating the problem as one of set membership.
|
9
|
+
|
10
|
+
* Why does this exist?
|
11
|
+
|
12
|
+
Some orchestration systems create large numbers of load balancers. Eventually,
|
13
|
+
this becomes unwieldy to manage. =burdened-acrobat= makes it simple again.
|
14
|
+
|
15
|
+
* Installation
|
16
|
+
|
17
|
+
#+BEGIN_SRC shell
|
18
|
+
gem install burdened-acrobat
|
19
|
+
#+END_SRC
|
20
|
+
|
21
|
+
* Usage
|
22
|
+
|
23
|
+
#+BEGIN_SRC ruby
|
24
|
+
require 'burdened-acrobat'
|
25
|
+
|
26
|
+
load_balancers = BurdenedAcrobat::LoadBalancers.new
|
27
|
+
|
28
|
+
load_balancers.search do
|
29
|
+
tagged('KubernetesCluster') & with('subnet-abv123') & tagged('kubernetes.io/service-name', 'app/identity-service')
|
30
|
+
end
|
31
|
+
#+END_SRC
|
32
|
+
|
33
|
+
=burdened-acrobat= operates on two main sets of information: Load Balancers, and Tags.
|
34
|
+
|
35
|
+
** Tags
|
36
|
+
|
37
|
+
~LoadBalancers#tags~ returns tags.
|
38
|
+
|
39
|
+
| Given these Arguments | Expect to get a collection of... |
|
40
|
+
|--------------------------------+---------------------------------------|
|
41
|
+
| None | All tags |
|
42
|
+
| A tag name | All tags matching that name |
|
43
|
+
| A tag name, and a value | All tags matching that name and value |
|
44
|
+
| A collection of load balancers | The tags on those load balancers |
|
45
|
+
|
46
|
+
|
47
|
+
** Load Balanceers
|
48
|
+
|
49
|
+
~LoadBalancers#tagged~ returns load balancers.
|
50
|
+
|
51
|
+
| Given these arguments | Expect to get a collection of... |
|
52
|
+
|-------------------------+----------------------------------------------------------|
|
53
|
+
| None | All load balancers with tags |
|
54
|
+
| A tag name | All load balancers with the given tag |
|
55
|
+
| A tag name, and a value | All load balancers where the given tag matches the value |
|
56
|
+
| A collection of tags | All load balancers matching those tags |
|
57
|
+
|
58
|
+
** Everything!
|
59
|
+
|
60
|
+
~LoadBalancers#all~ returns all load balancers.
|
61
|
+
|
62
|
+
** Names
|
63
|
+
|
64
|
+
~LoadBalancers#names~ accepts tags or load balancers, and returns names.
|
65
|
+
|
66
|
+
** Using Names
|
67
|
+
|
68
|
+
~LoadBalancers#named~ accepts names, and returns load balancers.
|
69
|
+
|
70
|
+
** Complex Searches
|
71
|
+
|
72
|
+
Everything returned is in the form of =Sets=. This allows building complex
|
73
|
+
filters using ~#intersection~, ~#union~, ~#difference~, and so on.
|
74
|
+
|
75
|
+
** AWS-specific extras
|
76
|
+
|
77
|
+
When using Amazon ELBs, =burdened-acrobat= provides additional filters.
|
78
|
+
|
79
|
+
-LoadBalancers#with~ returns load balancers.
|
80
|
+
|
81
|
+
| Given these arguments | Expect to get a collection of |
|
82
|
+
|-----------------------+----------------------------------------------|
|
83
|
+
| A VPC | All load balancers in that VPC |
|
84
|
+
| A security group | All load balancers using that security group |
|
85
|
+
| A subnet | ALl load balancers using that subnet |
|
86
|
+
|
87
|
+
* License
|
88
|
+
|
89
|
+
~burdened-acrobat~ is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See ~LICENSE.txt~ for the full text.
|
90
|
+
|
91
|
+
* Contributors
|
92
|
+
|
93
|
+
- [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'burdened-acrobat'
|
3
|
+
gem.version = `git describe --tags --abbrev=0`.chomp
|
4
|
+
gem.licenses = 'MIT'
|
5
|
+
gem.authors = ['Chris Olstrom']
|
6
|
+
gem.email = 'chris@olstrom.com'
|
7
|
+
gem.homepage = 'https://github.com/colstrom/burdened-acrobat'
|
8
|
+
gem.summary = 'Library for finding load balancers, when you have too many'
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split("\n")
|
11
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
13
|
+
gem.require_paths = ['lib']
|
14
|
+
|
15
|
+
gem.add_runtime_dependency 'aws-sdk', '~> 2.6', '>= 2.6.3'
|
16
|
+
gem.add_runtime_dependency 'contracts', '~> 0.14', '>= 0.14.0'
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'contracts'
|
3
|
+
|
4
|
+
module BurdenedAcrobat
|
5
|
+
module Amazon
|
6
|
+
module Contracts
|
7
|
+
include ::Contracts::Core
|
8
|
+
include ::Contracts::Builtin
|
9
|
+
|
10
|
+
LoadBalancerDescription = ::Aws::ElasticLoadBalancing::Types::LoadBalancerDescription
|
11
|
+
LoadBalancerDescriptions = Or[SetOf[LoadBalancerDescription], ArrayOf[LoadBalancerDescription]]
|
12
|
+
|
13
|
+
TagDescription = ::Aws::ElasticLoadBalancing::Types::TagDescription
|
14
|
+
TagDescriptions = Or[SetOf[TagDescription], ArrayOf[TagDescription]]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require_relative 'contracts'
|
3
|
+
|
4
|
+
module BurdenedAcrobat
|
5
|
+
module Amazon
|
6
|
+
class ELB
|
7
|
+
include ::Contracts::Core
|
8
|
+
include ::Contracts::Builtin
|
9
|
+
include Contracts
|
10
|
+
|
11
|
+
Contract Maybe[HashOf[Symbol, Any]] => ELB
|
12
|
+
def initialize(**options)
|
13
|
+
@options = options
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
Contract None => ArrayOf[LoadBalancerDescription]
|
18
|
+
def load_balancers
|
19
|
+
@load_balancers ||= load_balancers!
|
20
|
+
end
|
21
|
+
|
22
|
+
Contract None => ArrayOf[LoadBalancerDescription]
|
23
|
+
def load_balancers!
|
24
|
+
@load_balancers = provider.describe_load_balancers.load_balancer_descriptions
|
25
|
+
end
|
26
|
+
|
27
|
+
Contract None => ArrayOf[String]
|
28
|
+
def names
|
29
|
+
load_balancers.map(&:load_balancer_name)
|
30
|
+
end
|
31
|
+
|
32
|
+
Contract None => ArrayOf[TagDescription]
|
33
|
+
def tags
|
34
|
+
@tags ||= tags!
|
35
|
+
end
|
36
|
+
|
37
|
+
Contract None => ArrayOf[TagDescription]
|
38
|
+
def tags!
|
39
|
+
@tags = names.each_slice(20).flat_map do |slice|
|
40
|
+
provider.describe_tags(load_balancer_names: slice).tag_descriptions
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def provider
|
47
|
+
@provider ||= ::Aws::ElasticLoadBalancing::Client.new @options
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
require_relative 'contracts'
|
3
|
+
|
4
|
+
module BurdenedAcrobat
|
5
|
+
module Amazon
|
6
|
+
module Mixins
|
7
|
+
include ::Contracts::Core
|
8
|
+
include ::Contracts::Builtin
|
9
|
+
include Contracts
|
10
|
+
|
11
|
+
VPCIdentifier = /vpc-[[:xdigit:]]+/
|
12
|
+
SubnetIdentifier = /subnet-[[:xdigit:]]+/
|
13
|
+
SecurityGroupIdentifier = /sg-[[:xdigit:]]+/
|
14
|
+
|
15
|
+
Contract VPCIdentifier => SetOf[LoadBalancerDescription]
|
16
|
+
def with(vpc)
|
17
|
+
Set.new all.select { |lb| lb.vpc_id == vpc }
|
18
|
+
end
|
19
|
+
|
20
|
+
Contract SubnetIdentifier => SetOf[LoadBalancerDescription]
|
21
|
+
def with(subnet)
|
22
|
+
Set.new all.select { |lb| lb.subnets.include? subnet }
|
23
|
+
end
|
24
|
+
|
25
|
+
Contract SecurityGroupIdentifier => SetOf[LoadBalancerDescription]
|
26
|
+
def with(security_group)
|
27
|
+
Set.new all.select { |lb| lb.security_groups.include? security_group }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
|
3
|
+
module BurdenedAcrobat
|
4
|
+
module Contracts
|
5
|
+
include ::Contracts::Core
|
6
|
+
include ::Contracts::Builtin
|
7
|
+
|
8
|
+
Key = Or[String, Symbol]
|
9
|
+
Value = Or[String, Symbol]
|
10
|
+
|
11
|
+
Name = Or[String, Symbol]
|
12
|
+
Names = Or[SetOf[Name], ArrayOf[Name]]
|
13
|
+
|
14
|
+
Named = RespondTo[:load_balancer_name]
|
15
|
+
NamedCollection = Or[SetOf[Named], ArrayOf[Named]]
|
16
|
+
|
17
|
+
Service = RespondTo[:load_balancers, :load_balancers!, :tags, :tags!]
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require_relative 'amazon/contracts'
|
2
|
+
require_relative 'amazon/elb'
|
3
|
+
require_relative 'contracts'
|
4
|
+
|
5
|
+
module BurdenedAcrobat
|
6
|
+
class LoadBalancers
|
7
|
+
include ::Contracts::Core
|
8
|
+
include ::Contracts::Builtin
|
9
|
+
include Contracts
|
10
|
+
include Amazon::Contracts
|
11
|
+
include Amazon::Mixins
|
12
|
+
|
13
|
+
Contract KeywordArgs[:service => Optional[Service]] => LoadBalancers
|
14
|
+
def initialize(**options)
|
15
|
+
@options = options
|
16
|
+
refresh!
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
Contract None => nil
|
21
|
+
def refresh!
|
22
|
+
nil.tap do
|
23
|
+
all!
|
24
|
+
tags!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def search(&block)
|
29
|
+
self.instance_eval(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
Contract None => SetOf[LoadBalancerDescription]
|
33
|
+
def all
|
34
|
+
@all ||= all!
|
35
|
+
end
|
36
|
+
|
37
|
+
Contract None => SetOf[TagDescription]
|
38
|
+
def tags
|
39
|
+
@tags ||= tags!
|
40
|
+
end
|
41
|
+
|
42
|
+
Contract Key => SetOf[TagDescription]
|
43
|
+
def tags(key)
|
44
|
+
Set.new tags.select { |lb| lb.tags.any? { |tag| tag.key == key.to_s } }
|
45
|
+
end
|
46
|
+
|
47
|
+
Contract Key, Value => SetOf[TagDescription]
|
48
|
+
def tags(key, value)
|
49
|
+
Set.new tags(key).select { |lb| lb.tags.any? { |tag| tag.value == value.to_s } }
|
50
|
+
end
|
51
|
+
|
52
|
+
Contract LoadBalancerDescriptions => SetOf[TagDescription]
|
53
|
+
def tags(load_balancers)
|
54
|
+
Set.new tags.select { |tag| names(load_balancers).include? tag.load_balancer_name }
|
55
|
+
end
|
56
|
+
|
57
|
+
Contract None => SetOf[LoadBalancerDescription]
|
58
|
+
def tagged
|
59
|
+
Set.new all.select { |lb| names(tags).include? lb.load_balancer_name }
|
60
|
+
end
|
61
|
+
|
62
|
+
Contract Key => SetOf[LoadBalancerDescription]
|
63
|
+
def tagged(key)
|
64
|
+
Set.new all.select { |lb| names(tags(key)).include? lb.load_balancer_name }
|
65
|
+
end
|
66
|
+
|
67
|
+
Contract Key, Value => SetOf[LoadBalancerDescription]
|
68
|
+
def tagged(key, value)
|
69
|
+
Set.new all.select { |lb| names(tags(key, value)).include? lb.load_balancer_name }
|
70
|
+
end
|
71
|
+
|
72
|
+
Contract TagDescriptions => SetOf[LoadBalancerDescription]
|
73
|
+
def tagged(tags)
|
74
|
+
Set.new all.select { |lb| names(tags).include? lb.load_balancer_name }
|
75
|
+
end
|
76
|
+
|
77
|
+
Contract NamedCollection => SetOf[String]
|
78
|
+
def names(load_balancers)
|
79
|
+
Set.new load_balancers.map(&:load_balancer_name)
|
80
|
+
end
|
81
|
+
|
82
|
+
Contract Names => SetOf[LoadBalancerDescription]
|
83
|
+
def named(names)
|
84
|
+
Set.new names.map { |name| all.find { |lb| lb.load_balancer_name == name } }
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def service
|
90
|
+
@service = @options.fetch(:service) { Amazon::ELB.new }
|
91
|
+
end
|
92
|
+
|
93
|
+
def all!
|
94
|
+
@all = Set.new service.load_balancers!
|
95
|
+
end
|
96
|
+
|
97
|
+
def tags!
|
98
|
+
@tags = Set.new service.tags!
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: burdened-acrobat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Olstrom
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.6'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.6.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.6'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.6.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: contracts
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.14'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.14.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.14'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.14.0
|
53
|
+
description:
|
54
|
+
email: chris@olstrom.com
|
55
|
+
executables: []
|
56
|
+
extensions: []
|
57
|
+
extra_rdoc_files: []
|
58
|
+
files:
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.org
|
61
|
+
- burdened-acrobat.gemspec
|
62
|
+
- lib/burdened-acrobat.rb
|
63
|
+
- lib/burdened-acrobat/amazon.rb
|
64
|
+
- lib/burdened-acrobat/amazon/contracts.rb
|
65
|
+
- lib/burdened-acrobat/amazon/elb.rb
|
66
|
+
- lib/burdened-acrobat/amazon/mixins.rb
|
67
|
+
- lib/burdened-acrobat/contracts.rb
|
68
|
+
- lib/burdened-acrobat/load_balancers.rb
|
69
|
+
homepage: https://github.com/colstrom/burdened-acrobat
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.5.1
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Library for finding load balancers, when you have too many
|
93
|
+
test_files: []
|