specinfra 2.87.2 → 2.88.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra/backend/lxd.rb +65 -0
- data/lib/specinfra/backend.rb +1 -0
- data/lib/specinfra/configuration.rb +2 -0
- data/lib/specinfra/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5653294259d7e35a26af3b0841cb507c5a7bd69668d022af79f4f32ae7299810
|
4
|
+
data.tar.gz: c0c2cef79bb876c01ce2dc8fbb21ab138a6a0e367186c34ba94e7f35772ec12d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f97e98b911c4354b87de096cc6af94d8d4c7e793d8fab46ed72cea47b95ee4803cce160e2dcd54d7c61e3b076877018d904641050d99fa28b3a354afff4a58
|
7
|
+
data.tar.gz: 14eebac1837c79a17e352eada2496dbea730463de4a94782fe366e6f72f172e37715ec7c6068bc1c63259882f0865124f8fafc12d61171e6dc586b2d8c462acf
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'shellwords'
|
6
|
+
require 'sfl' if Specinfra.ruby_is_older_than?(1, 9, 0)
|
7
|
+
|
8
|
+
module Specinfra
|
9
|
+
module Backend
|
10
|
+
# LXD transport
|
11
|
+
class Lxd < Exec
|
12
|
+
def initialize(config = {})
|
13
|
+
super
|
14
|
+
|
15
|
+
raise 'Please specify lxd_instance' unless (@instance = get_config(:lxd_instance))
|
16
|
+
raise 'Please specify lxd_remote' unless (@remote = get_config(:lxd_remote))
|
17
|
+
|
18
|
+
@remote_instance = [@remote, @instance].compact.join(':')
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
protected
|
23
|
+
|
24
|
+
def run_command(cmd, opts = {})
|
25
|
+
cmd = build_command(cmd)
|
26
|
+
run_pre_command(opts)
|
27
|
+
stdout, stderr, exit_status = with_env do
|
28
|
+
spawn_command(cmd)
|
29
|
+
end
|
30
|
+
|
31
|
+
if @example
|
32
|
+
@example.metadata[:command] = cmd
|
33
|
+
@example.metadata[:stdout] = stdout
|
34
|
+
end
|
35
|
+
|
36
|
+
CommandResult.new :stdout => stdout, :stderr => stderr, :exit_status => exit_status
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_command(cmd)
|
40
|
+
cmd = super(cmd)
|
41
|
+
"lxc exec #{@remote_instance} -- #{cmd}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def send_file(source, destination)
|
45
|
+
flags = %w[--create-dirs]
|
46
|
+
if File.directory?(source)
|
47
|
+
flags << '--recursive'
|
48
|
+
destination = Pathname.new(destination).dirname.to_s
|
49
|
+
end
|
50
|
+
cmd = %W[lxc file push #{source} #{@remote_instance}#{destination}] + flags
|
51
|
+
spawn_command(cmd.join(' '))
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def run_pre_command(_opts)
|
57
|
+
return unless get_config(:pre_command)
|
58
|
+
|
59
|
+
cmd = build_command(get_config(:pre_command))
|
60
|
+
spawn_command(cmd)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/specinfra/backend.rb
CHANGED
@@ -6,6 +6,7 @@ require 'specinfra/backend/powershell/command'
|
|
6
6
|
require 'specinfra/backend/cmd'
|
7
7
|
require 'specinfra/backend/docker'
|
8
8
|
require 'specinfra/backend/lxc'
|
9
|
+
require 'specinfra/backend/lxd'
|
9
10
|
require 'specinfra/backend/winrm'
|
10
11
|
require 'specinfra/backend/shell_script'
|
11
12
|
require 'specinfra/backend/dockerfile'
|
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.88.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:
|
11
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/specinfra/backend/exec.rb
|
129
129
|
- lib/specinfra/backend/jexec.rb
|
130
130
|
- lib/specinfra/backend/lxc.rb
|
131
|
+
- lib/specinfra/backend/lxd.rb
|
131
132
|
- lib/specinfra/backend/powershell/command.rb
|
132
133
|
- lib/specinfra/backend/powershell/script_helper.rb
|
133
134
|
- lib/specinfra/backend/powershell/support/check_file_access_rules.ps1
|