docker-cli 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.release_history.yml +4 -0
- data/.rspec +3 -0
- data/Dockerfile.cli.test +3 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +77 -0
- data/README.md +35 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docker-cli.gemspec +48 -0
- data/lib/docker/cli/command.rb +83 -0
- data/lib/docker/cli/command_factory.rb +262 -0
- data/lib/docker/cli/command_result.rb +41 -0
- data/lib/docker/cli/version.rb +7 -0
- data/lib/docker/cli.rb +29 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 772cf53882bfb45cf43be6d235ecca8ed718bbc8967cb9552b52fcdcc39ec4b7
|
4
|
+
data.tar.gz: 6ab201e6b5b70d5d3b07e0b06d9b007139c98b4a65c0a31b5cd8f47f1f774c8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3287974fed58b9d9ddc311f3ace54cc28ceb427ad9a9049efc8936374afec8866bbd393d1e61590c5ad7930873c0885e73042fd8f9d63f5ee122624f9fc293a4
|
7
|
+
data.tar.gz: e7a40193271218b1bf5100acd1a1c606d30c5d327163f74c97aed420b7f82061b91b6af00ab669efeb723a6c766ee2463b1fd0156ca44d76d5509c1815f092d9
|
data/.rspec
ADDED
data/Dockerfile.cli.test
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
docker-cli (0.1.0)
|
5
|
+
ptools
|
6
|
+
teLogger
|
7
|
+
toolrack
|
8
|
+
tty-command
|
9
|
+
tty-prompt
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
base58 (0.2.3)
|
15
|
+
devops_assist (0.3.1)
|
16
|
+
git_cli
|
17
|
+
git_cli_prompt
|
18
|
+
gvcs
|
19
|
+
teLogger
|
20
|
+
toolrack
|
21
|
+
tty-prompt
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
git_cli (0.10.0)
|
24
|
+
gvcs
|
25
|
+
ptools (~> 1.4.0)
|
26
|
+
teLogger
|
27
|
+
toolrack
|
28
|
+
git_cli_prompt (0.3.1)
|
29
|
+
teLogger
|
30
|
+
toolrack
|
31
|
+
tty-prompt
|
32
|
+
gvcs (0.1.0)
|
33
|
+
pastel (0.8.0)
|
34
|
+
tty-color (~> 0.5)
|
35
|
+
ptools (1.4.3)
|
36
|
+
rake (13.0.6)
|
37
|
+
rspec (3.12.0)
|
38
|
+
rspec-core (~> 3.12.0)
|
39
|
+
rspec-expectations (~> 3.12.0)
|
40
|
+
rspec-mocks (~> 3.12.0)
|
41
|
+
rspec-core (3.12.0)
|
42
|
+
rspec-support (~> 3.12.0)
|
43
|
+
rspec-expectations (3.12.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.12.0)
|
46
|
+
rspec-mocks (3.12.0)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.12.0)
|
49
|
+
rspec-support (3.12.0)
|
50
|
+
teLogger (0.2.0)
|
51
|
+
toolrack (0.19.1)
|
52
|
+
base58
|
53
|
+
tty-color (0.6.0)
|
54
|
+
tty-command (0.10.1)
|
55
|
+
pastel (~> 0.8)
|
56
|
+
tty-cursor (0.7.1)
|
57
|
+
tty-prompt (0.23.1)
|
58
|
+
pastel (~> 0.8)
|
59
|
+
tty-reader (~> 0.8)
|
60
|
+
tty-reader (0.9.0)
|
61
|
+
tty-cursor (~> 0.7)
|
62
|
+
tty-screen (~> 0.8)
|
63
|
+
wisper (~> 2.0)
|
64
|
+
tty-screen (0.8.1)
|
65
|
+
wisper (2.0.1)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
x86_64-linux
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
devops_assist
|
72
|
+
docker-cli!
|
73
|
+
rake (~> 13.0)
|
74
|
+
rspec (~> 3.0)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.2.28
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Docker::Cli
|
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/docker/cli`. 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 'docker-cli'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install docker-cli
|
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 the created tag, 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/[USERNAME]/docker-cli.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "docker/cli"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docker-cli.gemspec
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/docker/cli/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "docker-cli"
|
7
|
+
spec.version = Docker::Cli::VERSION
|
8
|
+
spec.authors = ["Ian"]
|
9
|
+
spec.email = ["cameronian0@protonmail.com"]
|
10
|
+
|
11
|
+
spec.summary = ""
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.required_ruby_version = ">= 2.4.0"
|
15
|
+
|
16
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
17
|
+
|
18
|
+
#spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_dependency 'toolrack'
|
34
|
+
spec.add_dependency 'teLogger'
|
35
|
+
|
36
|
+
spec.add_dependency 'ptools'
|
37
|
+
|
38
|
+
spec.add_dependency 'tty-command'
|
39
|
+
spec.add_dependency 'tty-prompt'
|
40
|
+
|
41
|
+
spec.add_development_dependency 'devops_assist'
|
42
|
+
|
43
|
+
# Uncomment to register a new dependency of your gem
|
44
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
45
|
+
|
46
|
+
# For more information and examples about making a new gem, checkout our
|
47
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
48
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
require 'tty/command'
|
3
|
+
require 'tty/prompt'
|
4
|
+
require 'ptools'
|
5
|
+
|
6
|
+
require_relative 'command_result'
|
7
|
+
|
8
|
+
module Docker
|
9
|
+
module Cli
|
10
|
+
class Command
|
11
|
+
include TR::CondUtils
|
12
|
+
|
13
|
+
attr_accessor :command_buffer
|
14
|
+
def initialize(cmd, required_interaction = false)
|
15
|
+
@command_buffer = cmd
|
16
|
+
@runner = TTY::Command.new
|
17
|
+
@required_interaction = required_interaction
|
18
|
+
@required_interaction = false if not_bool?(@required_interaction)
|
19
|
+
end
|
20
|
+
|
21
|
+
def interactive_session?
|
22
|
+
@required_interaction
|
23
|
+
end
|
24
|
+
|
25
|
+
def run(&block)
|
26
|
+
|
27
|
+
if interactive_session?
|
28
|
+
|
29
|
+
pmt = TTY::Prompt.new
|
30
|
+
terminal = pmt.select "Command is an interactive command. New terminal session is required. Please select one of the session below to proceed:" do |m|
|
31
|
+
detect_terminal.each do |t|
|
32
|
+
m.choice t, t
|
33
|
+
end
|
34
|
+
|
35
|
+
m.choice "Quit", :quit
|
36
|
+
end
|
37
|
+
|
38
|
+
if terminal != :quit
|
39
|
+
case terminal
|
40
|
+
when "terminator"
|
41
|
+
`#{terminal} -x "#{@command_buffer.join(" ")}"`
|
42
|
+
when "gnome-terminal"
|
43
|
+
`#{terminal} -- bash -c "#{@command_buffer.join(" ")}; exec bash"`
|
44
|
+
else
|
45
|
+
raise Error, "Unfinished supporting terminal : #{terminal}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
else
|
50
|
+
@outStream = []
|
51
|
+
@errStream = []
|
52
|
+
@result = @runner.run!(@command_buffer.join(" ")) do |out, err|
|
53
|
+
if block
|
54
|
+
block.call(:outstream, out)
|
55
|
+
block.call(:errstream, err)
|
56
|
+
else
|
57
|
+
@outStream << out if not_empty?(out)
|
58
|
+
@errStream << err if not_empty?(err)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
CommandResult.new(@result, @outStream, @errStream)
|
63
|
+
#{ outStream: @outStream, errStream: @errStream, result: @result }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def to_string
|
68
|
+
@command_buffer
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
def detect_terminal
|
73
|
+
possible = [ "gnome-terminal","konsole","cmd.exe", "tilix", "terminator" ]
|
74
|
+
avail = []
|
75
|
+
possible.each do |app|
|
76
|
+
avail << app if not File.which(app).nil?
|
77
|
+
end
|
78
|
+
avail
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
|
2
|
+
require_relative 'command'
|
3
|
+
|
4
|
+
module Docker
|
5
|
+
module Cli
|
6
|
+
class CommandFactory
|
7
|
+
include TR::CondUtils
|
8
|
+
|
9
|
+
def build_image(name = "", opts = { })
|
10
|
+
|
11
|
+
opts = { } if opts.nil?
|
12
|
+
cmd = []
|
13
|
+
cmd << Cli.docker_exe
|
14
|
+
cmd << "build"
|
15
|
+
if not_empty?(name)
|
16
|
+
cmd << "-t #{name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
if not_empty?(opts[:dockerfile])
|
20
|
+
cmd << "-f #{opts[:dockerfile]}"
|
21
|
+
end
|
22
|
+
|
23
|
+
root = opts[:context_root]
|
24
|
+
root = "." if is_empty?(root)
|
25
|
+
cmd << root
|
26
|
+
|
27
|
+
logger.debug "Build Image : #{cmd.join(" ")}"
|
28
|
+
Command.new(cmd)
|
29
|
+
|
30
|
+
end # build_image
|
31
|
+
|
32
|
+
|
33
|
+
def find_image(name, tag = "", opts = { })
|
34
|
+
name = "" if name.nil?
|
35
|
+
cmd = []
|
36
|
+
cmd << Cli.docker_exe
|
37
|
+
cmd << "images"
|
38
|
+
cmd << "-q"
|
39
|
+
if not_empty?(tag)
|
40
|
+
cmd << "#{name}:#{tag}"
|
41
|
+
else
|
42
|
+
cmd << name
|
43
|
+
end
|
44
|
+
|
45
|
+
logger.debug "Find image: #{cmd.join(" ")}"
|
46
|
+
|
47
|
+
Command.new(cmd)
|
48
|
+
end # find_image
|
49
|
+
|
50
|
+
def delete_image(name, tag = "", opts = { })
|
51
|
+
|
52
|
+
if not_empty?(name)
|
53
|
+
|
54
|
+
cmd = []
|
55
|
+
cmd << Cli.docker_exe
|
56
|
+
cmd << "rmi"
|
57
|
+
if not_empty?(tag)
|
58
|
+
cmd << "#{name}:#{tag}"
|
59
|
+
else
|
60
|
+
cmd << name
|
61
|
+
end
|
62
|
+
|
63
|
+
logger.debug "Delete image: #{cmd.join(" ")}"
|
64
|
+
Command.new(cmd)
|
65
|
+
|
66
|
+
else
|
67
|
+
raise Error, "Name is required for delete operation"
|
68
|
+
end
|
69
|
+
|
70
|
+
end # delete_image
|
71
|
+
|
72
|
+
|
73
|
+
def find_running_container(name, opts = { })
|
74
|
+
|
75
|
+
raise Error, "Name is mandatory" if is_empty?(name)
|
76
|
+
|
77
|
+
cmd = []
|
78
|
+
cmd << Cli.docker_exe
|
79
|
+
cmd << "ps"
|
80
|
+
cmd << "-q"
|
81
|
+
cmd << "-f"
|
82
|
+
cmd << "name=#{name}"
|
83
|
+
|
84
|
+
logger.debug "Find container: #{cmd.join(" ")}"
|
85
|
+
|
86
|
+
Command.new(cmd)
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
# Find from container even if it is already stopped
|
91
|
+
def find_from_all_container(name, opts = { })
|
92
|
+
raise Error, "Name is required" if is_empty?(name)
|
93
|
+
cmd = []
|
94
|
+
cmd << Cli.docker_exe
|
95
|
+
cmd << "ps"
|
96
|
+
cmd << "-aq"
|
97
|
+
cmd << "-f"
|
98
|
+
cmd << "name=#{name}"
|
99
|
+
|
100
|
+
logger.debug "Find from all container: #{cmd.join(" ")}"
|
101
|
+
Command.new(cmd)
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_container_from_image(image, opts = { })
|
105
|
+
opts = {} if opts.nil?
|
106
|
+
cmd = []
|
107
|
+
cmd << Cli.docker_exe
|
108
|
+
cmd << "run"
|
109
|
+
cmd << "-i" if opts[:interactive] == true
|
110
|
+
cmd << "-t" if opts[:tty] == true
|
111
|
+
if not (opts[:container_name].nil? or opts[:container_name].empty?)
|
112
|
+
cmd << "--name #{opts[:container_name]}"
|
113
|
+
end
|
114
|
+
|
115
|
+
cmd << process_mount(opts)
|
116
|
+
cmd << process_port(opts)
|
117
|
+
|
118
|
+
cmd << image
|
119
|
+
|
120
|
+
if not_empty?(opts[:command])
|
121
|
+
cmd << "\"#{opts[:command]}\""
|
122
|
+
end
|
123
|
+
|
124
|
+
interactive = false
|
125
|
+
interactive = true if opts[:interactive] or opts[:tty]
|
126
|
+
|
127
|
+
logger.debug "Run Container from Image : #{cmd.join(" ")}"
|
128
|
+
Command.new(cmd, (interactive ? true : false))
|
129
|
+
end # run_container_from_image
|
130
|
+
|
131
|
+
def start_container(container, opts = { })
|
132
|
+
|
133
|
+
opts = {} if opts.nil?
|
134
|
+
cmd = []
|
135
|
+
cmd << Cli.docker_exe
|
136
|
+
cmd << "container"
|
137
|
+
cmd << "start"
|
138
|
+
cmd << container
|
139
|
+
|
140
|
+
logger.debug "Start Container : #{cmd.join(" ")}"
|
141
|
+
Command.new(cmd)
|
142
|
+
end
|
143
|
+
|
144
|
+
def attach_container(container, opts = { })
|
145
|
+
|
146
|
+
opts = {} if opts.nil?
|
147
|
+
cmd = []
|
148
|
+
cmd << Cli.docker_exe
|
149
|
+
cmd << "container"
|
150
|
+
cmd << "attach"
|
151
|
+
cmd << container
|
152
|
+
|
153
|
+
logger.debug "Attach Container : #{cmd.join(" ")}"
|
154
|
+
# this is a bit difficult to juggle
|
155
|
+
# it depending on the previous docker configuration
|
156
|
+
# but to be save, just open up a new terminal
|
157
|
+
Command.new(cmd, true)
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def stop_container(container, opts = { })
|
162
|
+
|
163
|
+
cmd = []
|
164
|
+
cmd << Cli.docker_exe
|
165
|
+
cmd << "container"
|
166
|
+
cmd << "stop"
|
167
|
+
cmd << container
|
168
|
+
|
169
|
+
logger.debug "Stop Container : #{cmd.join(" ")}"
|
170
|
+
Command.new(cmd)
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
def delete_container(container, opts = { })
|
175
|
+
|
176
|
+
cmd = []
|
177
|
+
cmd << Cli.docker_exe
|
178
|
+
cmd << "container"
|
179
|
+
cmd << "rm"
|
180
|
+
cmd << container
|
181
|
+
|
182
|
+
logger.debug "Delete Container : #{cmd.join(" ")}"
|
183
|
+
Command.new(cmd)
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
def run_command_in_running_container(container, command, opts = { })
|
188
|
+
cmd = []
|
189
|
+
cmd << Cli.docker_exe
|
190
|
+
cmd << "container"
|
191
|
+
cmd << "exec"
|
192
|
+
|
193
|
+
isTty = false
|
194
|
+
isInteractive = false
|
195
|
+
if is_empty?(opts[:command])
|
196
|
+
if not_empty?(opts[:tty]) and opts[:tty] == true
|
197
|
+
cmd << "-t"
|
198
|
+
isTty = true
|
199
|
+
end
|
200
|
+
if not_empty?(opts[:interactive]) and opts[:interactive] == true
|
201
|
+
cmd << "-i"
|
202
|
+
isInteractive = true
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
cmd << container
|
207
|
+
|
208
|
+
if is_empty?(command)
|
209
|
+
cmd << "/bin/bash --login"
|
210
|
+
else
|
211
|
+
cmd << command
|
212
|
+
end
|
213
|
+
|
214
|
+
logger.debug "Run command in running container : #{cmd.join(" ")}"
|
215
|
+
Command.new(cmd, ((isTty or isInteractive) ? true : false))
|
216
|
+
end # container_prompt
|
217
|
+
|
218
|
+
|
219
|
+
private
|
220
|
+
# expecting :mounts => [{ "/dir/local" => "/dir/inside/docker" }]
|
221
|
+
def process_mount(opts)
|
222
|
+
if not (opts[:mount].nil? or opts[:mount].empty?)
|
223
|
+
m = opts[:mount]
|
224
|
+
m = [m] if not m.is_a?(Array)
|
225
|
+
res = []
|
226
|
+
m.each do |mm|
|
227
|
+
host = mm.keys.first
|
228
|
+
res << "-v #{host}:#{mm[host]}"
|
229
|
+
end
|
230
|
+
res.join(" ")
|
231
|
+
else
|
232
|
+
""
|
233
|
+
end
|
234
|
+
|
235
|
+
end # process_mount
|
236
|
+
|
237
|
+
def process_port(opts)
|
238
|
+
if not (opts[:ports].nil? or opts[:ports].empty?)
|
239
|
+
po = opts[:ports]
|
240
|
+
po = [po] if not po.is_a?(Array)
|
241
|
+
res = []
|
242
|
+
po.each do |host,docker|
|
243
|
+
res << "-p #{host}:#{docker}"
|
244
|
+
end
|
245
|
+
res.join(" ")
|
246
|
+
else
|
247
|
+
""
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
def logger
|
253
|
+
if @logger.nil?
|
254
|
+
@logger = TeLogger::Tlogger.new
|
255
|
+
@logger.tag = :docker_cmd
|
256
|
+
end
|
257
|
+
@logger
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Docker
|
4
|
+
|
5
|
+
module Cli
|
6
|
+
|
7
|
+
class CommandResult
|
8
|
+
include TR::CondUtils
|
9
|
+
|
10
|
+
attr_reader :out, :err, :result
|
11
|
+
def initialize(result, out, err)
|
12
|
+
@result = result
|
13
|
+
@out = out
|
14
|
+
@err = err
|
15
|
+
end
|
16
|
+
|
17
|
+
def is_out_stream_empty?
|
18
|
+
is_empty?(@out)
|
19
|
+
end
|
20
|
+
|
21
|
+
def out_stream
|
22
|
+
@out.join("\n")
|
23
|
+
end
|
24
|
+
|
25
|
+
def err_stream
|
26
|
+
@err.join("\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
def failed?
|
30
|
+
if @result.nil?
|
31
|
+
true
|
32
|
+
else
|
33
|
+
@result.failed?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/docker/cli.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'toolrack'
|
4
|
+
require 'teLogger'
|
5
|
+
|
6
|
+
require 'ptools'
|
7
|
+
|
8
|
+
require_relative "cli/version"
|
9
|
+
require_relative 'cli/command'
|
10
|
+
require_relative 'cli/command_factory'
|
11
|
+
|
12
|
+
module Docker
|
13
|
+
module Cli
|
14
|
+
class Error < StandardError; end
|
15
|
+
# Your code goes here...
|
16
|
+
|
17
|
+
def Cli.docker_exe
|
18
|
+
|
19
|
+
path = File.which("docker")
|
20
|
+
if path.nil?
|
21
|
+
"docker"
|
22
|
+
else
|
23
|
+
path
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docker-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ian
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: toolrack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: teLogger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ptools
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-command
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-prompt
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: devops_assist
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- cameronian0@protonmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".release_history.yml"
|
105
|
+
- ".rspec"
|
106
|
+
- Dockerfile.cli.test
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/console
|
112
|
+
- bin/setup
|
113
|
+
- docker-cli.gemspec
|
114
|
+
- lib/docker/cli.rb
|
115
|
+
- lib/docker/cli/command.rb
|
116
|
+
- lib/docker/cli/command_factory.rb
|
117
|
+
- lib/docker/cli/command_result.rb
|
118
|
+
- lib/docker/cli/version.rb
|
119
|
+
homepage: ''
|
120
|
+
licenses: []
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 2.4.0
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubygems_version: 3.2.22
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: ''
|
141
|
+
test_files: []
|