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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcc0b3de91a94ee5078f10a370ba357129cb84a51cc8f74f15c47b4578c0a52c
4
- data.tar.gz: 3244b71ca2590ec756ff09408a9bc02a4acf67d82370389259b2a4ed8f9f816f
3
+ metadata.gz: 5653294259d7e35a26af3b0841cb507c5a7bd69668d022af79f4f32ae7299810
4
+ data.tar.gz: c0c2cef79bb876c01ce2dc8fbb21ab138a6a0e367186c34ba94e7f35772ec12d
5
5
  SHA512:
6
- metadata.gz: 76cca256c92c5ddf1a82d8745de7e53cd932430a2eb996c4ca0ced1fe926a4063b7348fcd4e61c3b5db3dc0634f54033f782ae89a7bc7aaf189e09594357a711
7
- data.tar.gz: 23ccd50fe257b9a1464c2bc34b74f540998c044079c3e2328667a14957ab85eec671526e57e035a2b3e2b0ef35ff9880b090477a2bdca7387f7e6cbc07a69a20
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
@@ -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'
@@ -20,6 +20,8 @@ module Specinfra
20
20
  :docker_image,
21
21
  :docker_url,
22
22
  :lxc,
23
+ :lxd_remote,
24
+ :lxd_instance,
23
25
  :request_pty,
24
26
  :ssh_options,
25
27
  :ssh_without_env,
@@ -1,5 +1,5 @@
1
1
  module Specinfra
2
- VERSION = "2.87.2"
2
+ VERSION = "2.88.0"
3
3
 
4
4
  def self.ruby_is_older_than?(*version)
5
5
  (RUBY_VERSION.split('.').map(&:to_i) <=> version) < 0
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.87.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: 2023-12-25 00:00:00.000000000 Z
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