specinfra 2.17.1 → 2.18.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 +4 -4
- data/lib/specinfra/backend/docker.rb +18 -12
- data/lib/specinfra/command/alpine/base/package.rb +19 -0
- data/lib/specinfra/command/alpine/base/process.rb +20 -0
- data/lib/specinfra/command/alpine/base.rb +2 -0
- data/lib/specinfra/command/alpine.rb +1 -0
- data/lib/specinfra/command.rb +6 -0
- data/lib/specinfra/configuration.rb +1 -0
- data/lib/specinfra/helper/detect_os/alpine.rb +8 -0
- data/lib/specinfra/helper/detect_os.rb +1 -0
- data/lib/specinfra/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 986714dbef8eb87fe3feeec2a68f47b3d54c93e7
|
4
|
+
data.tar.gz: 462409f9a83ca31793a5878c39aebab6cd4d1843
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 247447e1066bfbb554f3da2d3b038e35f0f1b760158d3f21b374447095e4240d1656523706bb753a58ba5ea1887220c4ddd3f21fd73cc762ebf6602367425359
|
7
|
+
data.tar.gz: 57c398cabc517e9df36f0775655c9555bda4ee0a21a0634102229f8bb2e0a027b6da570be93168e0116f468d698efbe84c1593d78c11746cb6053a2bf7a78cda
|
@@ -13,8 +13,7 @@ module Specinfra::Backend
|
|
13
13
|
@images = []
|
14
14
|
@base_image = ::Docker::Image.get(image)
|
15
15
|
|
16
|
-
|
17
|
-
create_and_start_container(env)
|
16
|
+
create_and_start_container
|
18
17
|
ObjectSpace.define_finalizer(self, proc { cleanup_container })
|
19
18
|
elsif container = Specinfra.configuration.docker_container
|
20
19
|
@container = ::Docker::Container.get(container)
|
@@ -49,7 +48,7 @@ module Specinfra::Backend
|
|
49
48
|
|
50
49
|
private
|
51
50
|
|
52
|
-
def create_and_start_container
|
51
|
+
def create_and_start_container
|
53
52
|
opts = { 'Image' => current_image.id }
|
54
53
|
|
55
54
|
if current_image.json["Config"]["Cmd"].nil?
|
@@ -60,10 +59,13 @@ module Specinfra::Backend
|
|
60
59
|
(opts['Env'] ||= []) << "PATH=#{path}"
|
61
60
|
end
|
62
61
|
|
63
|
-
if env
|
64
|
-
|
62
|
+
if Specinfra.configuration.env.any?
|
63
|
+
env = Specinfra.configuration.env.to_a.map { |v| v.join('=') }
|
64
|
+
opts['Env'] = opts['Env'].to_a.concat(env)
|
65
65
|
end
|
66
66
|
|
67
|
+
opts.merge!(Specinfra.configuration.docker_container_create_options || {})
|
68
|
+
|
67
69
|
@container = ::Docker::Container.create(opts)
|
68
70
|
@container.start
|
69
71
|
end
|
@@ -78,13 +80,17 @@ module Specinfra::Backend
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def docker_run!(cmd, opts={})
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
stdout, stderr, status = @container.exec(['/bin/sh', '-c', cmd])
|
84
|
+
|
85
|
+
CommandResult.new :stdout => stdout.join, :stderr => stderr.join,
|
86
|
+
:exit_status => status
|
87
|
+
rescue ::Docker::Error::DockerError => e
|
88
|
+
raise
|
89
|
+
rescue => e
|
90
|
+
@container.kill
|
91
|
+
err = stderr.nil? ? ([e.message] + e.backtrace) : stderr
|
92
|
+
CommandResult.new :stdout => [stdout].join, :stderr => err.join,
|
93
|
+
:exit_status => (status || 1)
|
88
94
|
end
|
89
95
|
end
|
90
96
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Specinfra::Command::Alpine::Base::Package < Specinfra::Command::Linux::Base::Package
|
2
|
+
class << self
|
3
|
+
def check_is_installed(package, version = nil)
|
4
|
+
pkg = [escape(package), version].compact.join('=')
|
5
|
+
"apk info -qe #{pkg}"
|
6
|
+
end
|
7
|
+
|
8
|
+
alias_method :check_is_installed_by_apk, :check_is_installed
|
9
|
+
|
10
|
+
def install(package, version = nil, _option = '')
|
11
|
+
pkg = [escape(package), version].compact.join('=')
|
12
|
+
"apk add -U #{pkg}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_version(package, _opts = nil)
|
16
|
+
"apk version #{package} | tail -n1 | awk '{ print $1; }' | cut -d- -f2-"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Specinfra::Command::Alpine::Base::Process < Specinfra::Command::Base
|
2
|
+
class << self
|
3
|
+
def get(process, opts)
|
4
|
+
col = opts[:format].chomp('=')
|
5
|
+
if col == 'args'
|
6
|
+
"ps -o #{col} | grep #{escape(process)} | head -1"
|
7
|
+
else
|
8
|
+
"ps -o #{col},args | grep -E '\\s+#{process}' | awk '{ print $1 }' | head -1"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_is_running(process)
|
13
|
+
"ps -ocomm | grep -w -- #{escape(process)} | grep -qv grep"
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_count(process, count)
|
17
|
+
"test $(ps -ocomm | grep -w -- #{escape(process)} | grep -v grep | wc -l) -eq #{escape(count)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class Specinfra::Command::Alpine; end
|
data/lib/specinfra/command.rb
CHANGED
@@ -98,6 +98,12 @@ require 'specinfra/command/aix/base/port'
|
|
98
98
|
require 'specinfra/command/aix/base/service'
|
99
99
|
require 'specinfra/command/aix/base/user'
|
100
100
|
|
101
|
+
# Alpine (inherit Linux)
|
102
|
+
require 'specinfra/command/alpine'
|
103
|
+
require 'specinfra/command/alpine/base'
|
104
|
+
require 'specinfra/command/alpine/base/package'
|
105
|
+
require 'specinfra/command/alpine/base/process'
|
106
|
+
|
101
107
|
# Arch (inherit Linux)
|
102
108
|
require 'specinfra/command/arch'
|
103
109
|
require 'specinfra/command/arch/base'
|
data/lib/specinfra/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -145,6 +145,10 @@ files:
|
|
145
145
|
- lib/specinfra/command/aix/base/port.rb
|
146
146
|
- lib/specinfra/command/aix/base/service.rb
|
147
147
|
- lib/specinfra/command/aix/base/user.rb
|
148
|
+
- lib/specinfra/command/alpine.rb
|
149
|
+
- lib/specinfra/command/alpine/base.rb
|
150
|
+
- lib/specinfra/command/alpine/base/package.rb
|
151
|
+
- lib/specinfra/command/alpine/base/process.rb
|
148
152
|
- lib/specinfra/command/arch.rb
|
149
153
|
- lib/specinfra/command/arch/base.rb
|
150
154
|
- lib/specinfra/command/arch/base/file.rb
|
@@ -325,6 +329,7 @@ files:
|
|
325
329
|
- lib/specinfra/helper/configuration.rb
|
326
330
|
- lib/specinfra/helper/detect_os.rb
|
327
331
|
- lib/specinfra/helper/detect_os/aix.rb
|
332
|
+
- lib/specinfra/helper/detect_os/alpine.rb
|
328
333
|
- lib/specinfra/helper/detect_os/arch.rb
|
329
334
|
- lib/specinfra/helper/detect_os/darwin.rb
|
330
335
|
- lib/specinfra/helper/detect_os/debian.rb
|