eac_docker 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/eac_docker.rb +7 -0
- data/lib/eac_docker/container.rb +50 -0
- data/lib/eac_docker/executables.rb +18 -0
- data/lib/eac_docker/images.rb +9 -0
- data/lib/eac_docker/images/base.rb +14 -0
- data/lib/eac_docker/images/named.rb +30 -0
- data/lib/eac_docker/rspec.rb +17 -0
- data/lib/eac_docker/version.rb +5 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69fd33f8ecdbc166aceda4863b765d0959337824ff8786a077c912dd0b9b1f13
|
4
|
+
data.tar.gz: ec299a2e803f2786642aae0915bc1bff70edefbd0b575566858c1c49bf88dd81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e43555681cf731f50f319c92ad92d417c8cb5d505b9d75570d2674af60e057779e8876cfb28a401116da9a9d7a58897483bd29ce68bfdd7b68accd6f8673509
|
7
|
+
data.tar.gz: 308eb14c54d1c2dd79cffd3016fc15824e7c7122120bc3235f36c883152600f4417d8993d4e907979c5decba821f8f56caebec8616d6710ccc7af798227d723f
|
data/lib/eac_docker.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacDocker
|
6
|
+
class Container
|
7
|
+
enable_immutable
|
8
|
+
immutable_accessor :interactive, :temporary, :tty, type: :boolean
|
9
|
+
immutable_accessor :env, type: :hash
|
10
|
+
immutable_accessor :command_arg, :volume, type: :array
|
11
|
+
common_constructor :image
|
12
|
+
|
13
|
+
def immutable_constructor_args
|
14
|
+
[image]
|
15
|
+
end
|
16
|
+
|
17
|
+
alias immutable_volume volume
|
18
|
+
|
19
|
+
def volume(left_part, right_part = null)
|
20
|
+
immutable_volume(right_part.if_present(left_part) { |v| "#{left_part}:#{v}" })
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_command
|
24
|
+
::EacDocker::Executables.docker.command('run', *run_command_args)
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_command_args
|
28
|
+
run_command_boolean_args + run_command_envs_args + run_command_volumes_args + [image.id] +
|
29
|
+
command_args
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def run_command_boolean_args
|
35
|
+
r = []
|
36
|
+
r << '--interactive' if interactive?
|
37
|
+
r << '--tty' if tty?
|
38
|
+
r << '--rm' if temporary?
|
39
|
+
r
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_command_volumes_args
|
43
|
+
volumes.flat_map { |volume| ['--volume', volume] }
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_command_envs_args
|
47
|
+
envs.flat_map { |name, value| ['--env', "#{name}=#{value}"] }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/envs'
|
5
|
+
|
6
|
+
module EacDocker
|
7
|
+
module Executables
|
8
|
+
class << self
|
9
|
+
def env
|
10
|
+
::EacRubyUtils::Envs.local
|
11
|
+
end
|
12
|
+
|
13
|
+
def docker
|
14
|
+
@docker ||= env.executable('docker', '--version')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_docker/executables'
|
4
|
+
require 'eac_docker/images/base'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module EacDocker
|
8
|
+
module Images
|
9
|
+
class Named < ::EacDocker::Images::Base
|
10
|
+
common_constructor :source_tag
|
11
|
+
|
12
|
+
def id
|
13
|
+
source_tag
|
14
|
+
end
|
15
|
+
|
16
|
+
def provide
|
17
|
+
provide_command.execute!
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def provide_command
|
22
|
+
::EacDocker::Executables.docker.command(*docker_provide_args)
|
23
|
+
end
|
24
|
+
|
25
|
+
def docker_provide_args
|
26
|
+
['pull', source_tag]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/rspec/conditional'
|
4
|
+
require 'eac_docker/executables'
|
5
|
+
|
6
|
+
module EacDocker
|
7
|
+
module Rspec
|
8
|
+
class << self
|
9
|
+
def configure
|
10
|
+
::EacRubyUtils::Rspec::Conditional.default.add(:docker) do
|
11
|
+
::EacDocker::Executables.docker.validate
|
12
|
+
end
|
13
|
+
RSpec.configure { |config| ::EacRubyUtils::Rspec::Conditional.default.configure(config) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eac_docker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Put here the authors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: eac_ruby_utils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.36'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.36'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: eac_ruby_gem_support
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.1.1
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.1'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.1.1
|
47
|
+
description:
|
48
|
+
email:
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/eac_docker.rb
|
54
|
+
- lib/eac_docker/container.rb
|
55
|
+
- lib/eac_docker/executables.rb
|
56
|
+
- lib/eac_docker/images.rb
|
57
|
+
- lib/eac_docker/images/base.rb
|
58
|
+
- lib/eac_docker/images/named.rb
|
59
|
+
- lib/eac_docker/rspec.rb
|
60
|
+
- lib/eac_docker/version.rb
|
61
|
+
homepage:
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.7.7
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Put here de description.
|
84
|
+
test_files: []
|