ranch-hand 0.4.0 → 0.5.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
  SHA256:
3
- metadata.gz: 28e355a00dd066ac8d0b0270f59a2a97c25bd28e69066a289aec029db9661fa9
4
- data.tar.gz: 56a686da7e0be9a823b75fd7d349d75b7d7cd8c497106d153fe3018f6921ce87
3
+ metadata.gz: 48c84c3e4ddf11d37bb17c9bc444ccc0700f1f9ed384625e44a076bb87430cff
4
+ data.tar.gz: eececbaadd4d0f51df193d4bf347475a53e8c4adfd1597eaaeaa688b701d2475
5
5
  SHA512:
6
- metadata.gz: d7639b1029f2cfb0a415794dd22ca8af87f38a20be8efdb757373a0218ae2fbdbf50f13365985afdd55a0e44fdcce72e6cf40c260d33823f1dd8dafe0ece392b
7
- data.tar.gz: be9d54eed465ab6b3bb9b09f845ddb1d514f701076cf9d1f4b601b07fadfad36e2672c74d3b816380ab311ec4d619825ef4b966ebd657d7f4293f92900bd24f8
6
+ metadata.gz: 8dc1dfd8aacea8c3e94052f9b4e5d3bef1b6bfe9613a0c70a76ebbea48e3e8b85fd3dba10a1e8d9aa7b64d78dc02f36ed3f27f2fc3f08180dca8ab34865eb8cc
7
+ data.tar.gz: d728d0493913d69331764620855311288c49c98529f0b47fe5917f800e41b28aca5ddb11545fddbb5a60321c78a83e7152b24cc116304d53868298bc02e7198f
data/.gitignore CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ # https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
14
+ Gemfile.lock
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # RanchHand
2
2
 
3
- Provides an interface between the Rancher CLI and the Kubectl commands to make running commands in pods easier.
3
+ [![Gem Version](https://badge.fury.io/rb/ranch-hand.svg)](https://badge.fury.io/rb/ranch-hand)
4
+
5
+ Provides a simple interface on top the Rancher CLI and the Kubectl commands to make running commands in pods easier.
4
6
  This is particularily useful when using Kubernetes in a development environment.
5
7
 
8
+ ![ranch-hand demo](https://github.com/peregrinator/ranch-hand/raw/master/doc/ranch-hand-demo.gif "Ranch-hand Demo")
9
+
6
10
  ## Installation
7
11
 
8
12
  Add this line to your application's Gemfile:
@@ -19,6 +23,17 @@ Or install it yourself as:
19
23
 
20
24
  $ gem install ranch-hand
21
25
 
26
+ ## Setup
27
+
28
+ Once ranch-hand is installed, run `ranch-hand setup` from the command line. This will the necessary files in a `~/.ranch-hand`.
29
+
30
+ #### Project setup
31
+
32
+ Project setup is optional. You can create a set of default values for certain flags by running `ranch-hand init` in any directory. When ranch-hand is run from a directory it will use the values in a `.ranch-hand` file if it is present.
33
+
34
+ Normally you might run the following command: `ranch-hand -n my-namespace -g -p my-project -c /bin/bash`
35
+ Using `ranch-hand init` you can set the namespace, grouping flag and pod name as defaults, instead allowing you to just run: `ranch-hand -c /bin/bash`.
36
+
22
37
  ## Usage
23
38
 
24
39
  RanchHand makes use of the [GLI](https://github.com/davetron5000/gli) (Git Like Interface) gem to create a CLI with features similar to the Git CLI. Run `ranch-hand help` or `ranch-hand command help` for usage information.
@@ -23,16 +23,25 @@ module RanchHandCLI
23
23
  end
24
24
  end
25
25
 
26
+ desc 'Initializes ranch hand for project'
27
+ command :init do |c|
28
+ c.action do |global_options, command_options, args|
29
+ RanchHand::Base.init
30
+ end
31
+ end
32
+
26
33
  desc 'Execs into a running container'
27
34
  command :exec do |c|
28
- c.switch [:g, :group], negatable: false, desc: "Group pods returned so that there is only one from each deployment."
35
+ config = RanchHand::Config.load
36
+
37
+ c.switch [:g, :group], negatable: true, default_value: config[:group] || false, desc: "Group pods returned so that there is only one from each deployment, --no-group can be used to override project config as needed."
29
38
  c.switch [:rm, :remove], negatable: false, desc: "Used to indicated that you want to remove a previously saved command."
30
39
  c.switch [:r, :repeat], negatable: false, desc: "Repeat the last command ran (against the same pod)."
31
40
 
32
41
  c.flag [:c, :command], desc: "Command to run once (not permanently stored)"
33
42
  c.flag [:f, :filter], desc: "Filter pods returned to those that contain the string provided (negative matches supported). Examples: '-f nginx', '-f -apache'"
34
- c.flag [:n, :namespace], required: true, desc: "Namespace against which to retreive pods and run command"
35
- c.flag [:p, :pod], desc: "Run command in a specific pod. If used with -g only the pod name can be specified and the command will be run against the first in the group"
43
+ c.flag [:n, :namespace], required: true, default_value: config[:namespace], desc: "Namespace against which to retreive pods and run command"
44
+ c.flag [:p, :pod], default_value: config[:pod], desc: "Run command in a specific pod. If used with -g only the pod name can be specified and the command will be run against the first in the group"
36
45
 
37
46
  c.action do |global_options, command_options, args|
38
47
  RanchHand::KubeCtl.new.exec(command_options)
@@ -10,6 +10,7 @@ require 'tty-prompt'
10
10
  # our files
11
11
  require 'ranch_hand/base.rb'
12
12
  require 'ranch_hand/commands.rb'
13
+ require 'ranch_hand/config.rb'
13
14
  require 'ranch_hand/constants.rb'
14
15
  require 'ranch_hand/kube_ctl.rb'
15
16
  require 'ranch_hand/logger.rb'
@@ -6,5 +6,11 @@ module RanchHand
6
6
  File.new(RanchHand::STORE_FILE, 'w+', 0640)
7
7
  RanchHand::Logger.info("complete")
8
8
  end
9
+
10
+ def self.init
11
+ RanchHand::Logger.info("initializing ranch-hand for project")
12
+ RanchHand::Config.create
13
+ RanchHand::Logger.info("initialization complete")
14
+ end
9
15
  end
10
16
  end
@@ -0,0 +1,45 @@
1
+ module RanchHand
2
+ class Config
3
+ extend RanchHand::Commands
4
+
5
+ def self.create
6
+ save(generate_config)
7
+ RanchHand::Logger.info("Config file saved to #{project_config_path}")
8
+ end
9
+
10
+ def self.load
11
+ begin
12
+ YAML.load_file(project_config_path)
13
+ rescue Errno::ENOENT
14
+ {}
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def self.generate_config
21
+ namespace = prompt.ask('Namespace:')
22
+ group = prompt.ask('Use group command by default? (Y/n):')
23
+ group = %w(n N).include?(group) ? false : true
24
+ pod = prompt.ask('Pod name:')
25
+
26
+ {
27
+ group: group,
28
+ namespace: namespace,
29
+ pod: pod
30
+ }
31
+ end
32
+
33
+ def self.save(config)
34
+ # File.new(project_config_path, 'w+', 0640)
35
+
36
+ File.open(project_config_path, 'w', 0640) do |f|
37
+ f.write(config.to_yaml)
38
+ end
39
+ end
40
+
41
+ def self.project_config_path
42
+ File.join(Dir.pwd, ".ranch-hand")
43
+ end
44
+ end
45
+ end
@@ -3,6 +3,8 @@ module RanchHand
3
3
  include RanchHand::Commands
4
4
 
5
5
  def exec(options={})
6
+ # options = project_config.merge(options)
7
+
6
8
  namespace = options.delete(:namespace)
7
9
 
8
10
  if options[:remove]
@@ -179,5 +181,10 @@ module RanchHand
179
181
  def storage
180
182
  @storage ||= RanchHand::Storage.new
181
183
  end
184
+
185
+ # def project_config
186
+ # project_config_file = File.join(Dir.pwd, ".ranch-hand")
187
+ # YAML.load_file(project_config_file) || {}
188
+ # end
182
189
  end
183
190
  end
@@ -1,3 +1,3 @@
1
1
  module RanchHand
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }.reject { |f| f.match(%r{.gem$}) }
21
21
  end
22
22
  spec.bindir = "bin"
23
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.executables = spec.files.grep(%r{^bin/ranch-hand}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ranch-hand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peregrinator
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-03 00:00:00.000000000 Z
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,9 +112,7 @@ description: ''
112
112
  email:
113
113
  - bob.burbach@gmail.com
114
114
  executables:
115
- - console
116
115
  - ranch-hand
117
- - setup
118
116
  extensions: []
119
117
  extra_rdoc_files: []
120
118
  files:
@@ -123,16 +121,17 @@ files:
123
121
  - ".travis.yml"
124
122
  - CODE_OF_CONDUCT.md
125
123
  - Gemfile
126
- - Gemfile.lock
127
124
  - LICENSE.txt
128
125
  - README.md
129
126
  - Rakefile
130
127
  - bin/console
131
128
  - bin/ranch-hand
132
129
  - bin/setup
130
+ - doc/ranch-hand-demo.gif
133
131
  - lib/ranch_hand.rb
134
132
  - lib/ranch_hand/base.rb
135
133
  - lib/ranch_hand/commands.rb
134
+ - lib/ranch_hand/config.rb
136
135
  - lib/ranch_hand/constants.rb
137
136
  - lib/ranch_hand/kube_ctl.rb
138
137
  - lib/ranch_hand/logger.rb
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ranch-hand (0.3.0)
5
- gli (~> 2.18)
6
- pry (~> 0.12.2)
7
- tty-command (~> 0.8.2)
8
- tty-prompt (~> 0.18.1)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- coderay (1.1.2)
14
- diff-lcs (1.3)
15
- equatable (0.5.0)
16
- gli (2.18.0)
17
- method_source (0.9.2)
18
- necromancer (0.4.0)
19
- pastel (0.7.2)
20
- equatable (~> 0.5.0)
21
- tty-color (~> 0.4.0)
22
- pry (0.12.2)
23
- coderay (~> 1.1.0)
24
- method_source (~> 0.9.0)
25
- rake (10.5.0)
26
- rspec (3.8.0)
27
- rspec-core (~> 3.8.0)
28
- rspec-expectations (~> 3.8.0)
29
- rspec-mocks (~> 3.8.0)
30
- rspec-core (3.8.0)
31
- rspec-support (~> 3.8.0)
32
- rspec-expectations (3.8.2)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.8.0)
35
- rspec-mocks (3.8.0)
36
- diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.8.0)
38
- rspec-support (3.8.0)
39
- timers (4.3.0)
40
- tty-color (0.4.3)
41
- tty-command (0.8.2)
42
- pastel (~> 0.7.0)
43
- tty-cursor (0.6.1)
44
- tty-prompt (0.18.1)
45
- necromancer (~> 0.4.0)
46
- pastel (~> 0.7.0)
47
- timers (~> 4.0)
48
- tty-cursor (~> 0.6.0)
49
- tty-reader (~> 0.5.0)
50
- tty-reader (0.5.0)
51
- tty-cursor (~> 0.6.0)
52
- tty-screen (~> 0.6.4)
53
- wisper (~> 2.0.0)
54
- tty-screen (0.6.5)
55
- wisper (2.0.0)
56
-
57
- PLATFORMS
58
- ruby
59
-
60
- DEPENDENCIES
61
- bundler (~> 2.0)
62
- rake (~> 10.0)
63
- ranch-hand!
64
- rspec (~> 3.0)
65
-
66
- BUNDLED WITH
67
- 2.0.1