knuckle_cluster 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a45740ee1e2f621c56a0797856e5e35b8c1a4f0a
4
- data.tar.gz: 491c8b5a5cbea377eccd8398e50e06d437947fbe
3
+ metadata.gz: 2a3ddc54ca48b30d78d88c8e92e90232b52ac23a
4
+ data.tar.gz: 4d18251585f3cf240aa526e366bc69ed4f5f7133
5
5
  SHA512:
6
- metadata.gz: 4e4985e14bd91410df373307d0dea915e597946b8e5f5c6ecd94e194abf0cefda86d4431449323650563475a3a09cd6e9995345dab24f719414c8316981f35ca
7
- data.tar.gz: 83a2963607d32e6ec4694512bcef3e1618113226c23454446b3ee00fa1e6e131b914983370df040496e980b190e921623157f42130ca1c0384be2e883bd43c61
6
+ metadata.gz: af26f21868f728a336f9e8ffb4d031ff8506e2332ba741d1f9bfb3c34a19f5681fe50a6e701036597e30dfe6c5ce9b3895098883211cb95d265ac40863eb7d34
7
+ data.tar.gz: ae7c93d80043b3730507c4850f9184ed0ccc5ae9bf944e855d68969f2b23abfe3915371e1a815e90a95720af449ab22ada3d841f8ef17620663eda7df8fe938e
data/README.md CHANGED
@@ -107,6 +107,7 @@ See [Options for Knuckle Cluster](#options-for-knuckle-cluster) below for a list
107
107
  Command line options:
108
108
 
109
109
  ```
110
+ knuckle_cluster list - list all available clusters
110
111
  knuckle_cluster CLUSTER_PROFILE agents - list all agents and select one to start a shell
111
112
  knuckle_cluster CLUSTER_PROFILE containers - list all containers and select one to start a shell
112
113
  knuckle_cluster CLUSTER_PROFILE logs CONTAINER_NAME - tail the logs for a container
@@ -2,10 +2,16 @@
2
2
  require "knuckle_cluster"
3
3
  require "yaml"
4
4
 
5
+ if ARGV[0] == 'list'
6
+ KnuckleCluster::Configuration.list
7
+ exit
8
+ end
9
+
5
10
  profile = ARGV[0]
6
11
 
7
12
  if ARGV.count < 2
8
13
  puts <<~USAGE
14
+ knuckle_cluster list - list all available clusters
9
15
  knuckle_cluster CLUSTER_PROFILE agents - list all agents and select one to start a shell
10
16
  knuckle_cluster CLUSTER_PROFILE containers - list all containers and select one to start a shell
11
17
  knuckle_cluster CLUSTER_PROFILE logs CONTAINER_NAME - tail the logs for a container
@@ -3,10 +3,8 @@ class KnuckleCluster::Configuration
3
3
  DEFAULT_PROFILE_FILE = File.join(ENV['HOME'],'.ssh/knuckle_cluster').freeze
4
4
 
5
5
  def self.load_parameters(profile:, profile_file: nil)
6
- profile_file ||= DEFAULT_PROFILE_FILE
7
- raise "File #{profile_file} not found" unless File.exists?(profile_file)
8
6
 
9
- data = YAML.load_file(profile_file)
7
+ data = load_data(profile_file)
10
8
 
11
9
  unless data.keys.include?(profile)
12
10
  raise "Config file does not include profile for #{profile}"
@@ -33,6 +31,29 @@ class KnuckleCluster::Configuration
33
31
  keys_to_symbols(output)
34
32
  end
35
33
 
34
+ def self.load_data(profile_file = nil)
35
+ @data ||= (
36
+ profile_file ||= DEFAULT_PROFILE_FILE
37
+ raise "File #{profile_file} not found" unless File.exists?(profile_file)
38
+ YAML.load_file(profile_file)
39
+ )
40
+ end
41
+
42
+ def self.list
43
+ data = []
44
+
45
+ KnuckleCluster::Configuration.load_data.each do |k,v|
46
+ tmp = {'name': k}
47
+ tmp['tunnels'] = v['tunnels'] ? v['tunnels'].keys.join(', ') : ''
48
+ tmp['shortcuts'] = v['shortcuts'] ? v['shortcuts'].keys.join(', ') : ''
49
+
50
+ data << tmp
51
+ end
52
+ puts "\nVersion #{KnuckleCluster::VERSION}"
53
+ puts "\nAvailable connections"
54
+ tp data.sort{|x,y| x[:name] <=> y[:name]}
55
+ end
56
+
36
57
  private
37
58
 
38
59
  def self.keys_to_symbols(data)
@@ -49,4 +70,4 @@ class KnuckleCluster::Configuration
49
70
  end
50
71
  ret
51
72
  end
52
- end
73
+ end
@@ -1,3 +1,3 @@
1
1
  module KnuckleCluster
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.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.1.0
4
+ version: 2.2.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-07-17 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler