ranch-hand 0.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/ranch-hand +56 -0
- data/bin/setup +8 -0
- data/lib/ranch_hand.rb +17 -0
- data/lib/ranch_hand/base.rb +10 -0
- data/lib/ranch_hand/commands.rb +13 -0
- data/lib/ranch_hand/constants.rb +4 -0
- data/lib/ranch_hand/kube_ctl.rb +133 -0
- data/lib/ranch_hand/logger.rb +11 -0
- data/lib/ranch_hand/storage.rb +24 -0
- data/lib/ranch_hand/version.rb +3 -0
- data/ranch-hand.gemspec +34 -0
- metadata +166 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6810dd022dd993929014b497c21309de90d66a78dfc606216a5e36a621256c8b
|
|
4
|
+
data.tar.gz: 704ae19d0977277481eb7bd563d82d271dbab936faa0c273e053433eb6d77dc2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 31a7c159877709b9c5486dd7dae9a7cf3e9c6df9be3e3b6a58fe17ac5d1c56f42e24aad18218c216b7baa6ae6e3d82e04eeda9db185ea0725219b0761471d15d
|
|
7
|
+
data.tar.gz: 7fe741b1e01dc48e7c5d62fcf2f2c17e639899ac8daf4ed47b348bcd7c2393a138b778198443790f41b9222ec4bb8569ca3924d7cdc308b4eea4bd568863d159
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at bob.burbach@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
ranch-hand (0.2.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
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Peregrinator
|
|
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.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# RanchHand
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ranch_hand`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'ranch-hand'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install ranch-hand
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/peregrinator/ranch-hand. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
40
|
+
|
|
41
|
+
## Code of Conduct
|
|
42
|
+
|
|
43
|
+
Everyone interacting in the Ranch::Hand project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/peregrinator/ranch-hand/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "ranch_hand"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
require "pry"
|
|
11
|
+
Pry.start
|
|
12
|
+
|
|
13
|
+
# require "irb"
|
|
14
|
+
# IRB.start(__FILE__)
|
data/bin/ranch-hand
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
module RanchHandCLI
|
|
3
|
+
require 'gli'
|
|
4
|
+
require 'ranch_hand'
|
|
5
|
+
|
|
6
|
+
include GLI::App
|
|
7
|
+
# our cli is wrapped in a module (to not pollute the global namespace with GLI methods),
|
|
8
|
+
# so we need to extend here for things to work
|
|
9
|
+
extend self
|
|
10
|
+
|
|
11
|
+
program_desc 'Command line tools for using Rancher in a Kubernetes development environment'
|
|
12
|
+
|
|
13
|
+
version RanchHand::VERSION
|
|
14
|
+
|
|
15
|
+
subcommand_option_handling :normal
|
|
16
|
+
arguments :strict
|
|
17
|
+
|
|
18
|
+
desc 'Sets up ranch hand'
|
|
19
|
+
command :setup do |c|
|
|
20
|
+
c.action do |global_options, options, args|
|
|
21
|
+
RanchHand::Base.setup
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc 'Execs into a running container'
|
|
26
|
+
arg_name 'namespace'
|
|
27
|
+
command :exec do |c|
|
|
28
|
+
c.switch [:rm, :remove], negatable: false
|
|
29
|
+
c.action do |global_options, options, args|
|
|
30
|
+
RanchHand::KubeCtl.new.exec(args[0], options)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
pre do |global, command, options, args|
|
|
35
|
+
# Pre logic here
|
|
36
|
+
# Return true to proceed; false to abort and not call the
|
|
37
|
+
# chosen command
|
|
38
|
+
# Use skips_pre before a command to skip this block
|
|
39
|
+
# on that command only
|
|
40
|
+
true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
post do |global, command, options, args|
|
|
44
|
+
# Post logic here
|
|
45
|
+
# Use skips_post before a command to skip this
|
|
46
|
+
# block on that command only
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
on_error do |exception|
|
|
50
|
+
# Error logic here
|
|
51
|
+
# return false to skip default error handling
|
|
52
|
+
true
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
exit run(ARGV)
|
|
56
|
+
end
|
data/bin/setup
ADDED
data/lib/ranch_hand.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# stdlib
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'logger'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
|
|
6
|
+
# gems
|
|
7
|
+
require 'tty-command'
|
|
8
|
+
require 'tty-prompt'
|
|
9
|
+
|
|
10
|
+
# our files
|
|
11
|
+
require 'ranch_hand/base.rb'
|
|
12
|
+
require 'ranch_hand/commands.rb'
|
|
13
|
+
require 'ranch_hand/constants.rb'
|
|
14
|
+
require 'ranch_hand/kube_ctl.rb'
|
|
15
|
+
require 'ranch_hand/logger.rb'
|
|
16
|
+
require 'ranch_hand/storage.rb'
|
|
17
|
+
require 'ranch_hand/version.rb'
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module RanchHand
|
|
2
|
+
class KubeCtl
|
|
3
|
+
include RanchHand::Commands
|
|
4
|
+
|
|
5
|
+
def exec(namespace, options={})
|
|
6
|
+
if options[:rm]
|
|
7
|
+
remove_command(namespace)
|
|
8
|
+
else
|
|
9
|
+
run_command(namespace)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def run_command(namespace)
|
|
14
|
+
pod = select_pod(namespace)
|
|
15
|
+
type, cmd = select_command(namespace, pod)
|
|
16
|
+
|
|
17
|
+
system("rancher kubectl -n #{namespace} exec -it #{pod} -- #{cmd}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def remove_command(namespace)
|
|
21
|
+
pod = select_pod(namespace)
|
|
22
|
+
type, cmd = select_command(namespace, pod, remove: true)
|
|
23
|
+
|
|
24
|
+
storage_key = case type
|
|
25
|
+
when :global
|
|
26
|
+
"exec:commands:global"
|
|
27
|
+
when :namespace
|
|
28
|
+
"exec:commands:#{namespace}"
|
|
29
|
+
when :pod
|
|
30
|
+
"exec:commands:#{namespace}:#{pod_name(pod)}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
storage.set(storage_key, storage.get(storage_key) - Array(cmd))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def select_pod(namespace)
|
|
37
|
+
pods = pods(namespace)
|
|
38
|
+
pod = prompt.enum_select("Which pod?", pods, per_page: 10,
|
|
39
|
+
default: pods.index(
|
|
40
|
+
storage.get("exec:#{namespace}:latest:pod")
|
|
41
|
+
).to_i + 1
|
|
42
|
+
)
|
|
43
|
+
storage.set("exec:#{namespace}:latest:pod", pod)
|
|
44
|
+
pod
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def select_command(namespace, pod, options={})
|
|
48
|
+
commands = all_commands(namespace, pod, options)
|
|
49
|
+
|
|
50
|
+
ask = options[:remove] ? 'Remove command:' : 'Run command:'
|
|
51
|
+
type, cmd = prompt.enum_select(ask) do |menu|
|
|
52
|
+
menu.default commands.collect{|k,v| v}.flatten.index(
|
|
53
|
+
storage.get("exec:#{namespace}:latest:cmd")
|
|
54
|
+
).to_i + 1
|
|
55
|
+
|
|
56
|
+
commands.each do |type, commands|
|
|
57
|
+
commands.each do |cmd|
|
|
58
|
+
menu.choice cmd, [type, cmd]
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
unless options[:remove]
|
|
64
|
+
if cmd == "Add command"
|
|
65
|
+
type, cmd = add_command(namespace, pod)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# save cmd as latest
|
|
69
|
+
storage.set("exec:#{namespace}:latest:cmd", cmd)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
[type, cmd]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def add_command(namespace, pod)
|
|
76
|
+
type = prompt.ask('Global, namespace, pod? (g/N/p):')
|
|
77
|
+
cmd = prompt.ask('Command:')
|
|
78
|
+
|
|
79
|
+
if %w(global Global g G).include?(type)
|
|
80
|
+
type = :global
|
|
81
|
+
storage.set("exec:commands:global", (global_commands[:global] << cmd).uniq)
|
|
82
|
+
elsif %w(pod Pod p P).include?(type)
|
|
83
|
+
type = :pod
|
|
84
|
+
storage.set("exec:commands:#{namespace}:#{pod_name(pod)}", (pod_commands(namespace, pod)[:pod] << cmd).uniq)
|
|
85
|
+
else
|
|
86
|
+
type = :namespace
|
|
87
|
+
storage.set("exec:commands:#{namespace}", (namespace_commands(namespace)[:namespace] << cmd).uniq)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
[type, cmd]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
def all_commands(namespace, pod, options)
|
|
96
|
+
commands = [base_commands(options), global_commands, namespace_commands(namespace), pod_commands(namespace, pod)]
|
|
97
|
+
commands.inject({},:update)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def base_commands(options={})
|
|
101
|
+
if options[:remove]
|
|
102
|
+
{base: []}
|
|
103
|
+
else
|
|
104
|
+
{base: ["Add command"]}
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def global_commands
|
|
109
|
+
{global: storage.get("exec:commands:global") || []}
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def namespace_commands(namespace)
|
|
113
|
+
{namespace: storage.get("exec:commands:#{namespace}") || []}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def pod_commands(namespace, pod)
|
|
117
|
+
{pod: storage.get("exec:commands:#{namespace}:#{pod_name(pod)}") || []}
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def pod_name(pod)
|
|
121
|
+
pod.split('-')[0..-3].join('-')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def pods(namespace)
|
|
125
|
+
pods_cmd = "rancher kubectl -n #{namespace} get po"
|
|
126
|
+
command(printer: :null).run(pods_cmd).out.split("\n")[1..-1].map{|l| l.split(/\s+/)[0]}
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def storage
|
|
130
|
+
@storage ||= RanchHand::Storage.new
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module RanchHand
|
|
2
|
+
class Storage
|
|
3
|
+
def get(key)
|
|
4
|
+
store[key]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def set(key, val)
|
|
8
|
+
store[key] = val
|
|
9
|
+
save
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def store
|
|
15
|
+
@store ||= YAML.load_file(RanchHand::STORE_FILE) || {}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def save
|
|
19
|
+
File.open(RanchHand::STORE_FILE, 'w', 0640) do |f|
|
|
20
|
+
f.write(store.to_yaml)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/ranch-hand.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "ranch_hand/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "ranch-hand"
|
|
8
|
+
spec.version = RanchHand::VERSION
|
|
9
|
+
spec.authors = ["Peregrinator"]
|
|
10
|
+
spec.email = ["bob.burbach@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Provides an interface between the Rancher CLI and the Kubectl commands}
|
|
13
|
+
spec.description = %q{}
|
|
14
|
+
spec.homepage = "https://github.com/peregrinator/ranch-hand"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }.reject { |f| f.match(%r{.gem$}) }
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = "bin"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
29
|
+
|
|
30
|
+
spec.add_runtime_dependency "gli", "~> 2.18"
|
|
31
|
+
spec.add_runtime_dependency "pry", "~> 0.12.2"
|
|
32
|
+
spec.add_runtime_dependency "tty-command", "~> 0.8.2"
|
|
33
|
+
spec.add_runtime_dependency "tty-prompt", "~> 0.18.1"
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ranch-hand
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Peregrinator
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: gli
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.18'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.18'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.12.2
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.12.2
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: tty-command
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.8.2
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.8.2
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: tty-prompt
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.18.1
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.18.1
|
|
111
|
+
description: ''
|
|
112
|
+
email:
|
|
113
|
+
- bob.burbach@gmail.com
|
|
114
|
+
executables:
|
|
115
|
+
- console
|
|
116
|
+
- ranch-hand
|
|
117
|
+
- setup
|
|
118
|
+
extensions: []
|
|
119
|
+
extra_rdoc_files: []
|
|
120
|
+
files:
|
|
121
|
+
- ".gitignore"
|
|
122
|
+
- ".rspec"
|
|
123
|
+
- ".travis.yml"
|
|
124
|
+
- CODE_OF_CONDUCT.md
|
|
125
|
+
- Gemfile
|
|
126
|
+
- Gemfile.lock
|
|
127
|
+
- LICENSE.txt
|
|
128
|
+
- README.md
|
|
129
|
+
- Rakefile
|
|
130
|
+
- bin/console
|
|
131
|
+
- bin/ranch-hand
|
|
132
|
+
- bin/setup
|
|
133
|
+
- lib/ranch_hand.rb
|
|
134
|
+
- lib/ranch_hand/base.rb
|
|
135
|
+
- lib/ranch_hand/commands.rb
|
|
136
|
+
- lib/ranch_hand/constants.rb
|
|
137
|
+
- lib/ranch_hand/kube_ctl.rb
|
|
138
|
+
- lib/ranch_hand/logger.rb
|
|
139
|
+
- lib/ranch_hand/storage.rb
|
|
140
|
+
- lib/ranch_hand/version.rb
|
|
141
|
+
- ranch-hand.gemspec
|
|
142
|
+
homepage: https://github.com/peregrinator/ranch-hand
|
|
143
|
+
licenses:
|
|
144
|
+
- MIT
|
|
145
|
+
metadata: {}
|
|
146
|
+
post_install_message:
|
|
147
|
+
rdoc_options: []
|
|
148
|
+
require_paths:
|
|
149
|
+
- lib
|
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
|
+
requirements:
|
|
152
|
+
- - ">="
|
|
153
|
+
- !ruby/object:Gem::Version
|
|
154
|
+
version: '0'
|
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
requirements: []
|
|
161
|
+
rubyforge_project:
|
|
162
|
+
rubygems_version: 2.7.6.2
|
|
163
|
+
signing_key:
|
|
164
|
+
specification_version: 4
|
|
165
|
+
summary: Provides an interface between the Rancher CLI and the Kubectl commands
|
|
166
|
+
test_files: []
|