ranch-hand 0.5.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +13 -0
- data/README.md +4 -4
- data/bin/ranch-hand +10 -3
- data/files/ranch-hand.plugin.zsh +4 -0
- data/lib/ranch_hand/base.rb +23 -1
- data/lib/ranch_hand/commands.rb +1 -1
- data/lib/ranch_hand/kube_ctl.rb +14 -12
- data/lib/ranch_hand/version.rb +1 -1
- data/ranch-hand.gemspec +6 -4
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fcf2dcd9fa4d7109d4e40ee519904acde93eab7d6861444900e045d8f9e85fd
|
4
|
+
data.tar.gz: 579f8858997fc6d180e400d97463cf49f64a6f29084d4224108b7256a61b1708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee5fa837162469e9076186dd625bd4d8f2491836494a91d72861bc5571fba58a37719be2d8d190a948bc571e9542fb8098dd6888a5bba01073db15b25bfea78f
|
7
|
+
data.tar.gz: 11d3035683053d219e80d1da994b3a0ef634e07c4908344fb924c88ffe728724bd35651aa014d074e31904cdec85856c30334e475311bc803ed4f3de152f104f
|
data/Changelog.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
### 0.7.0
|
2
|
+
#### Features
|
3
|
+
Add support for command arguments. Commands that use arguments no longer need to be wrapped in a string in order to be passed properly. This provides a better interface for editor plugins that automatically append arguments to the end of a custom command.
|
4
|
+
- https://github.com/peregrinator/ranch-hand/commit/a70d44042507d407c0088a2a8ffa4d4514a800af
|
5
|
+
- ex: before: `ranch-hand exec -c 'rspec spec/foo.rb:21'`, now: `ranch-hand exec -c rspec spec/foo.rb:21`
|
6
|
+
|
7
|
+
#### Bugfixes:
|
8
|
+
- d76855: correctly handle scenario in which the namespace queried has no pods
|
9
|
+
|
10
|
+
### 0.6.0
|
11
|
+
|
12
|
+
Updates for Ruby 3.0 compat
|
13
|
+
- https://rubyreferences.github.io/rubychanges/3.0.html#keyword-arguments-are-now-fully-separated-from-positional-arguments
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Provides a simple interface on top the Rancher CLI and the Kubectl commands to make running commands in pods easier.
|
6
6
|
This is particularily useful when using Kubernetes in a development environment.
|
7
7
|
|
8
|
-
![ranch-hand demo](https://github.com/peregrinator/ranch-hand/raw/
|
8
|
+
![ranch-hand demo](https://github.com/peregrinator/ranch-hand/raw/main/doc/ranch-hand-demo.gif "Ranch-hand Demo")
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -25,14 +25,14 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
## Setup
|
27
27
|
|
28
|
-
Once ranch-hand is installed, run `ranch-hand setup` from the command line. This will the necessary files in
|
28
|
+
Once ranch-hand is installed, run `ranch-hand setup` from the command line. This will create the necessary files in `~/.ranch-hand`.
|
29
29
|
|
30
30
|
#### Project setup
|
31
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
|
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 the `.ranch-hand` file if it is present.
|
33
33
|
|
34
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
|
35
|
+
Using `ranch-hand init` you can set the namespace, grouping flag and pod name as defaults, and instead just run: `ranch-hand -c /bin/bash`.
|
36
36
|
|
37
37
|
## Usage
|
38
38
|
|
data/bin/ranch-hand
CHANGED
@@ -14,7 +14,7 @@ module RanchHandCLI
|
|
14
14
|
version RanchHand::VERSION
|
15
15
|
|
16
16
|
subcommand_option_handling :normal
|
17
|
-
arguments :
|
17
|
+
arguments :loose
|
18
18
|
|
19
19
|
desc 'Sets up ranch hand'
|
20
20
|
command :setup do |c|
|
@@ -23,6 +23,13 @@ module RanchHandCLI
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
desc 'Installs ranch hand Oh My Zsh shortcuts'
|
27
|
+
command :ohmyzsh do |c|
|
28
|
+
c.action do |global_options, options, args|
|
29
|
+
RanchHand::Base.install_ohmyzsh
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
26
33
|
desc 'Initializes ranch hand for project'
|
27
34
|
command :init do |c|
|
28
35
|
c.action do |global_options, command_options, args|
|
@@ -37,14 +44,14 @@ module RanchHandCLI
|
|
37
44
|
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."
|
38
45
|
c.switch [:rm, :remove], negatable: false, desc: "Used to indicated that you want to remove a previously saved command."
|
39
46
|
c.switch [:r, :repeat], negatable: false, desc: "Repeat the last command ran (against the same pod)."
|
40
|
-
|
47
|
+
|
41
48
|
c.flag [:c, :command], desc: "Command to run once (not permanently stored)"
|
42
49
|
c.flag [:f, :filter], desc: "Filter pods returned to those that contain the string provided (negative matches supported). Examples: '-f nginx', '-f -apache'"
|
43
50
|
c.flag [:n, :namespace], required: true, default_value: config[:namespace], desc: "Namespace against which to retreive pods and run command"
|
44
51
|
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"
|
45
52
|
|
46
53
|
c.action do |global_options, command_options, args|
|
47
|
-
RanchHand::KubeCtl.new.exec(command_options)
|
54
|
+
RanchHand::KubeCtl.new.exec(args: args, cmd_options: command_options)
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
data/lib/ranch_hand/base.rb
CHANGED
@@ -12,5 +12,27 @@ module RanchHand
|
|
12
12
|
RanchHand::Config.create
|
13
13
|
RanchHand::Logger.info("initialization complete")
|
14
14
|
end
|
15
|
+
|
16
|
+
def self.install_ohmyzsh
|
17
|
+
RanchHand::Logger.info("installing ranch-hand Oh My Zsh shortcuts")
|
18
|
+
|
19
|
+
unless ENV['ZSH_CUSTOM'] || ENV['ZSH']
|
20
|
+
RanchHand::Logger.warn("Could not find $ZSH_CUSTOM or $ZSH in your environment, can not install shortcuts")
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
zsh_custom_dir = ENV['ZSH_CUSTOM'] || File.join(ENV['ZSH'], 'custom')
|
25
|
+
|
26
|
+
zsh_plugin_dir = File.join(zsh_custom_dir, 'plugins', 'ranch-hand')
|
27
|
+
FileUtils.mkdir_p(zsh_plugin_dir)
|
28
|
+
|
29
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
30
|
+
gem_plugin_path = File.join(current_path, '..', '..', 'files', 'ranch-hand.plugin.zsh')
|
31
|
+
|
32
|
+
FileUtils.cp(gem_plugin_path, zsh_plugin_dir)
|
33
|
+
|
34
|
+
RanchHand::Logger.info("installation complete")
|
35
|
+
RanchHand::Logger.info("Don't forget to add 'ranch-hand' to your plugins in ~/.zshrc -- e.g. plugins=(ranch-hand) -- and then 'source ~/.zshrc'")
|
36
|
+
end
|
15
37
|
end
|
16
|
-
end
|
38
|
+
end
|
data/lib/ranch_hand/commands.rb
CHANGED
data/lib/ranch_hand/kube_ctl.rb
CHANGED
@@ -2,25 +2,25 @@ module RanchHand
|
|
2
2
|
class KubeCtl
|
3
3
|
include RanchHand::Commands
|
4
4
|
|
5
|
-
def exec(
|
6
|
-
|
5
|
+
def exec(args: [], cmd_options: {})
|
6
|
+
args = Array(args)
|
7
7
|
|
8
|
-
namespace =
|
8
|
+
namespace = cmd_options.delete(:namespace)
|
9
9
|
|
10
|
-
if
|
10
|
+
if cmd_options[:remove]
|
11
11
|
remove_command(namespace)
|
12
|
-
elsif
|
12
|
+
elsif cmd_options[:repeat]
|
13
13
|
repeat_command(namespace)
|
14
|
-
elsif
|
15
|
-
pod = select_pod(namespace,
|
16
|
-
run_command(namespace, pod,
|
14
|
+
elsif cmd_options[:command]
|
15
|
+
pod = select_pod(namespace, cmd_options)
|
16
|
+
run_command(namespace, pod, cmd_options[:command], args)
|
17
17
|
else
|
18
|
-
choose_command(namespace,
|
18
|
+
choose_command(namespace, cmd_options)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def run_command(namespace, pod, cmd)
|
23
|
-
system("rancher kubectl -n #{namespace} exec -it #{pod} -- #{cmd}")
|
22
|
+
def run_command(namespace, pod, cmd, args=[])
|
23
|
+
system("rancher kubectl -n #{namespace} exec -it #{pod} -- #{cmd} #{args.join(' ')}".strip)
|
24
24
|
end
|
25
25
|
|
26
26
|
def choose_command(namespace, options={})
|
@@ -175,7 +175,9 @@ module RanchHand
|
|
175
175
|
|
176
176
|
def pods(namespace)
|
177
177
|
pods_cmd = "rancher kubectl -n #{namespace} get po"
|
178
|
-
command(printer: :null).run(pods_cmd).out.split("\n")[1..-1]
|
178
|
+
pods = command(printer: :null).run(pods_cmd).out.split("\n")[1..-1]&.map{|l| l.split(/\s+/)[0]}
|
179
|
+
|
180
|
+
pods || []
|
179
181
|
end
|
180
182
|
|
181
183
|
def storage
|
data/lib/ranch_hand/version.rb
CHANGED
data/ranch-hand.gemspec
CHANGED
@@ -23,12 +23,14 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^bin/ranch-hand}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
+
spec.required_ruby_version = '~> 3.0'
|
27
|
+
|
26
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
27
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
31
|
|
30
|
-
spec.add_runtime_dependency "gli", "~> 2.
|
31
|
-
spec.add_runtime_dependency "pry", "~> 0.
|
32
|
-
spec.add_runtime_dependency "tty-command", "~> 0.
|
33
|
-
spec.add_runtime_dependency "tty-prompt", "~> 0.
|
32
|
+
spec.add_runtime_dependency "gli", "~> 2.20"
|
33
|
+
spec.add_runtime_dependency "pry", "~> 0.14"
|
34
|
+
spec.add_runtime_dependency "tty-command", "~> 0.10"
|
35
|
+
spec.add_runtime_dependency "tty-prompt", "~> 0.23"
|
34
36
|
end
|
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
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peregrinator
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,56 +58,56 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '2.
|
61
|
+
version: '2.20'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '2.
|
68
|
+
version: '2.20'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: '0.14'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: '0.14'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: tty-command
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: '0.10'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: '0.10'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: tty-prompt
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: '0.23'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: '0.23'
|
111
111
|
description: ''
|
112
112
|
email:
|
113
113
|
- bob.burbach@gmail.com
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- ".rspec"
|
121
121
|
- ".travis.yml"
|
122
122
|
- CODE_OF_CONDUCT.md
|
123
|
+
- Changelog.md
|
123
124
|
- Gemfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- README.md
|
@@ -128,6 +129,7 @@ files:
|
|
128
129
|
- bin/ranch-hand
|
129
130
|
- bin/setup
|
130
131
|
- doc/ranch-hand-demo.gif
|
132
|
+
- files/ranch-hand.plugin.zsh
|
131
133
|
- lib/ranch_hand.rb
|
132
134
|
- lib/ranch_hand/base.rb
|
133
135
|
- lib/ranch_hand/commands.rb
|
@@ -148,17 +150,16 @@ require_paths:
|
|
148
150
|
- lib
|
149
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
150
152
|
requirements:
|
151
|
-
- - "
|
153
|
+
- - "~>"
|
152
154
|
- !ruby/object:Gem::Version
|
153
|
-
version: '0'
|
155
|
+
version: '3.0'
|
154
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
157
|
requirements:
|
156
158
|
- - ">="
|
157
159
|
- !ruby/object:Gem::Version
|
158
160
|
version: '0'
|
159
161
|
requirements: []
|
160
|
-
|
161
|
-
rubygems_version: 2.7.6.2
|
162
|
+
rubygems_version: 3.2.22
|
162
163
|
signing_key:
|
163
164
|
specification_version: 4
|
164
165
|
summary: Provides an interface between the Rancher CLI and the Kubectl commands
|