knuckle_cluster 2.2.0 → 2.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a3ddc54ca48b30d78d88c8e92e90232b52ac23a
4
- data.tar.gz: 4d18251585f3cf240aa526e366bc69ed4f5f7133
3
+ metadata.gz: e6f39b842c827055e0c0966f03fff7a4e201b023
4
+ data.tar.gz: 299b8fc8dcf5e90f111686faf98adadd4b078535
5
5
  SHA512:
6
- metadata.gz: af26f21868f728a336f9e8ffb4d031ff8506e2332ba741d1f9bfb3c34a19f5681fe50a6e701036597e30dfe6c5ce9b3895098883211cb95d265ac40863eb7d34
7
- data.tar.gz: ae7c93d80043b3730507c4850f9184ed0ccc5ae9bf944e855d68969f2b23abfe3915371e1a815e90a95720af449ab22ada3d841f8ef17620663eda7df8fe938e
6
+ metadata.gz: 9a238237ac947360cd94e17600dd0904dab91a298d850cdd63d8156c817015351786d67147319561671d8a8454c19b75289e551b6666d34a1571f087b889e1a5
7
+ data.tar.gz: 4a93477e310c70decc1e510d0b899731599a621f38d493bc5da45b0e358951780de9bcd3920deaf999cceeecb568122604748ede1f6dcacaf13d5f0c8a73952e
data/README.md CHANGED
@@ -69,6 +69,9 @@ platform:
69
69
  local_port: 54321
70
70
  remote_host: postgres-db.yourcompany.com
71
71
  remote_port: 5432
72
+ hide:
73
+ container: some_container_regex_i_dont_care_about
74
+ task: some_task_regex_i_dont_care_about
72
75
  ```
73
76
 
74
77
  You can also use inheritance to simplify the inclusion of multiple similar targets:
@@ -209,6 +212,7 @@ ssh_username | The username to conncet. Will default to `ec2-user`
209
212
  sudo | true or false - will sudo the `docker` command on the target machine. Usually not needed unless the user is not a part of the `docker` group.
210
213
  aws_vault_profile | If you use the `aws-vault` tool to manage your AWS credentials, you can specify a profile here that will be automatically used to connect to this cluster.
211
214
  profile | Another profile to inherit settings from. Settings from lower profiles can be overridden in higher ones.
215
+ hide | allows you to specify a regex for either `task` or `container` to omit these from being shown
212
216
 
213
217
  ## Spot Fleets
214
218
  If you wish to see what instances are running within a spot fleet, KnuckleCluster can do that too!. In your config, use `spot_request_id` instead of `cluster_name`. Note that the `containers` command will not work when invoking (use `agents` instead).
@@ -30,7 +30,8 @@ module KnuckleCluster
30
30
  sudo: false,
31
31
  aws_vault_profile: nil,
32
32
  shortcuts: {},
33
- tunnels: {})
33
+ tunnels: {},
34
+ hide: {})
34
35
  @cluster_name = cluster_name
35
36
  @spot_request_id = spot_request_id
36
37
  @asg_name = asg_name
@@ -42,6 +43,7 @@ module KnuckleCluster
42
43
  @aws_vault_profile = aws_vault_profile
43
44
  @shortcuts = shortcuts
44
45
  @tunnels = tunnels
46
+ @hide = hide
45
47
 
46
48
  if @cluster_name.nil? && @spot_request_id.nil? && @asg_name.nil?
47
49
  raise "Must specify either cluster_name, spot_request_id or asg name"
@@ -205,6 +207,7 @@ module KnuckleCluster
205
207
  EcsAgentRegistry.new(
206
208
  aws_client_config: aws_client_config,
207
209
  cluster_name: cluster_name,
210
+ hide: @hide,
208
211
  )
209
212
  elsif @spot_request_id
210
213
  SpotRequestInstanceRegistry.new(
@@ -7,9 +7,10 @@ module KnuckleCluster
7
7
  class EcsAgentRegistry
8
8
  extend Forwardable
9
9
 
10
- def initialize(aws_client_config:, cluster_name:)
10
+ def initialize(aws_client_config:, cluster_name:, hide: {})
11
11
  @aws_client_config = aws_client_config
12
- @cluster_name = cluster_name
12
+ @cluster_name = cluster_name
13
+ @hide = hide
13
14
  end
14
15
 
15
16
  def agents
@@ -72,6 +73,7 @@ module KnuckleCluster
72
73
  ecs_client: ecs_client,
73
74
  cluster_name: cluster_name,
74
75
  agent_registry: self,
76
+ hide: @hide,
75
77
  )
76
78
  end
77
79
 
@@ -3,14 +3,15 @@ require 'knuckle_cluster/container'
3
3
 
4
4
  module KnuckleCluster
5
5
  class TaskRegistry
6
- def initialize(ecs_client:, cluster_name:, agent_registry:)
7
- @ecs_client = ecs_client
8
- @cluster_name = cluster_name
6
+ def initialize(ecs_client:, cluster_name:, agent_registry:, hide: {})
7
+ @ecs_client = ecs_client
8
+ @cluster_name = cluster_name
9
9
  @agent_registry = agent_registry
10
+ @hide = hide
10
11
  end
11
12
 
12
13
  def tasks
13
- @tasks ||= load_tasks
14
+ @tasks ||= load_tasks.compact
14
15
  end
15
16
 
16
17
  def containers
@@ -41,15 +42,28 @@ module KnuckleCluster
41
42
  ecs_client.describe_tasks(tasks: task_ids, cluster: cluster_name).tasks.flat_map do |task|
42
43
  agent = agent_registry.find_by(container_instance_arn: task.container_instance_arn)
43
44
 
45
+ task_name = task.task_definition_arn[/.*\/(.*):\d/,1]
46
+
47
+ if @hide[:task]
48
+ regex = Regexp.new(@hide[:task])
49
+ next if regex.match(task_name)
50
+ end
51
+
52
+ # next if task_name.include? 'datadog'
44
53
  Task.new(
45
54
  arn: task.task_arn,
46
55
  container_instance_arn: task.container_instance_arn,
47
56
  agent: agent,
48
57
  definition: task.task_definition_arn[/.*\/(.*):.*/,1],
49
- name: task.task_definition_arn[/.*\/(.*):\d/,1],
58
+ name: task_name,
50
59
  task_registry: self,
51
60
  ).tap do |new_task|
52
61
  task.containers.each do |container|
62
+ if @hide[:container]
63
+ regex = Regexp.new(@hide[:container])
64
+ next if regex.match(container.name)
65
+ end
66
+
53
67
  index += 1
54
68
 
55
69
  all_containers << Container.new(
@@ -1,3 +1,3 @@
1
1
  module KnuckleCluster
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knuckle_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler