cyclid-lxd-plugin 0.1.1 → 0.2.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
  SHA1:
3
- metadata.gz: e80ccc304ef0f78bf3f751b3ecbf54e2643ded81
4
- data.tar.gz: f84ddd8155cbb87826aca0053b7059d3e025568c
3
+ metadata.gz: 7aedf3aba54742b5b8bc41a4b0273f9cfe6e5a58
4
+ data.tar.gz: 090f443460169555421d913004bec49ac821ce04
5
5
  SHA512:
6
- metadata.gz: cb140871d9551c64dc377f410b9a0c7c5f9c833ed83050a5ce67fc40d1741a7958aa066ae28590ff27b2adc15374203729dfd5bf7c1c3e5f597d4d8c2e12ad69
7
- data.tar.gz: 8e2e30db75e1623140300e5650c0e082c6dd8df306bd29a15c8530cf0410d3dfdbb18b9f1c4ada5658563be6bf23b9740b626d5b577ab6c22dbe94f9c2cc2e39
6
+ metadata.gz: 6b31ecd9e7b5f8fd9e0de9e5233923d26ce47d3d3c869351e8a5a50ce401e5fc4f4962e4d737d9b32416aeea02b08c042655919601dc9ca44ccbc801c272f698
7
+ data.tar.gz: 3de1a041fc55f6e7182d107507905737b3060d22bea95cdd66916927bf044a1f1c6393e1455a9f26f964182626a2c433617a8413c5b480141376da6a79b4980b
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Copyright 2016 Liqwyd Ltd.
3
4
  #
4
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -109,9 +110,9 @@ module Cyclid
109
110
  raise 'the LXD API URL must be provided' \
110
111
  unless lxd_config.key? :api
111
112
 
112
- lxd_config[:client_cert] = File.join(%w(/ etc cyclid lxd_client.crt)) \
113
+ lxd_config[:client_cert] = File.join(%w[/ etc cyclid lxd_client.crt]) \
113
114
  unless lxd_config.key? :client_cert
114
- lxd_config[:client_key] = File.join(%w(/ etc cyclid lxd_client.key)) \
115
+ lxd_config[:client_key] = File.join(%w[/ etc cyclid lxd_client.key]) \
115
116
  unless lxd_config.key? :client_key
116
117
 
117
118
  lxd_config[:verify_ssl] = false \
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Copyright 2016 Liqwyd Ltd.
3
4
  #
4
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -55,8 +56,11 @@ module Cyclid
55
56
  end
56
57
 
57
58
  # Execute a command via. the LXD API
58
- def exec(cmd, path = nil)
59
- command = build_command(cmd, path)
59
+ def exec(cmd, args = {})
60
+ sudo = args[:sudo] || false
61
+ path = args[:path]
62
+
63
+ command = build_command(cmd, sudo, path)
60
64
  Cyclid.logger.debug "command=#{command}"
61
65
 
62
66
  # Ensure some important variables are set, like HOME & TERM
@@ -145,9 +149,9 @@ module Cyclid
145
149
  raise 'the LXD API URL must be provided' \
146
150
  unless lxd_config.key? :api
147
151
 
148
- lxd_config[:client_cert] = File.join(%w(/ etc cyclid lxd_client.crt)) \
152
+ lxd_config[:client_cert] = File.join(%w[/ etc cyclid lxd_client.crt]) \
149
153
  unless lxd_config.key? :client_cert
150
- lxd_config[:client_key] = File.join(%w(/ etc cyclid lxd_client.key)) \
154
+ lxd_config[:client_key] = File.join(%w[/ etc cyclid lxd_client.key]) \
151
155
  unless lxd_config.key? :client_key
152
156
 
153
157
  lxd_config[:verify_ssl] = false \
@@ -156,13 +160,15 @@ module Cyclid
156
160
  lxd_config
157
161
  end
158
162
 
159
- def build_command(cmd, path = nil)
163
+ def build_command(cmd, sudo, path = nil)
160
164
  command = []
161
165
  command << "cd #{path}" if path
162
166
  command << if @username == 'root'
163
167
  cmd
168
+ elsif sudo
169
+ "sudo -E -n $SHELL -l -c '#{cmd}'"
164
170
  else
165
- "sudo -E #{cmd}"
171
+ cmd
166
172
  end
167
173
  "sh -l -c '#{command.join(';')}'"
168
174
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclid-lxd-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Van Der Vliet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2017-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hyperkit
@@ -44,15 +44,15 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.2'
47
+ version: '0.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.2'
55
- description: Creates LXD container basedt build hosts
54
+ version: '0.4'
55
+ description: Creates LXD container based build hosts
56
56
  email: contact@cyclid.io
57
57
  executables: []
58
58
  extensions: []