vagrant-tart 0.0.2 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c396d57625272e20fa44038feb071add4d80fc19de6cf17e8339a46bdaef72ea
4
- data.tar.gz: ff2b337cb649360c7d451b721fb8c836e75e1e549fe282ca1a79307f7da36471
3
+ metadata.gz: 3e9661a2803897b09b1601b13b608e24ea19a5f95db89c760f3c04e6a1b18c41
4
+ data.tar.gz: fd5723f36984a597846413d9fe14438dd8386116357faff32d212ba6ca265c8e
5
5
  SHA512:
6
- metadata.gz: 0bab80c64715d5292521cba50edbcbdae81c7cbe50ed42bb28bcb4a5e4169660688ddf8d4dfb903f0d65eaf861df47f5af91982ca15b4b348654be97cce4b51a
7
- data.tar.gz: 0267bb6950b5eb82c7ec11c0d2c7dedfc4d753353f372189033500709a3f3a8841090b09b9998d761718a04ceaa0b4864218316149dad08d4a96782d947b0702
6
+ metadata.gz: 942cb301b228455fac8369be172bd5c9be38cf4b4ed91fe7eac0b0af46a15ff9235ecb3e9601de039aafb0836ec493b4e417c46748da4b79058fb8957f762d53
7
+ data.tar.gz: 53d7dba4e76a42d9ea51f76cfacb5306db38397e13102ab18123c2b1bc129d65775f09cafa030981d21f2fb16b21c42ef445e5eb8f07feddb433a81605938f75
@@ -25,7 +25,7 @@ module VagrantPlugins
25
25
  return @app.call(env) if instance.nil? || instance.vagrant_state == :running
26
26
 
27
27
  env[:ui].output(I18n.t("vagrant_tart.messages.configuring_instance", name: name))
28
- driver.set(name, "cpu", config.cpu)
28
+ driver.set(name, "cpus", config.cpus)
29
29
  driver.set(name, "memory", config.memory)
30
30
  driver.set(name, "disk", config.disk)
31
31
  driver.set(name, "display", config.display)
@@ -14,11 +14,13 @@ module VagrantPlugins
14
14
  action_root = Pathname.new(File.expand_path("action", __dir__))
15
15
  autoload :CreateInstance, action_root.join("create_instance")
16
16
  autoload :DeleteInstance, action_root.join("delete_instance")
17
+ autoload :ForwardPorts, action_root.join("forward_ports")
17
18
  autoload :GetState, action_root.join("get_state")
18
19
  autoload :Login, action_root.join("login")
19
20
  autoload :PullImage, action_root.join("pull_image")
20
21
  autoload :StartInstance, action_root.join("start_instance")
21
22
  autoload :StopInstance, action_root.join("stop_instance")
23
+ autoload :SuspendInstance, action_root.join("suspend_instance")
22
24
 
23
25
  # Vargrant action "destroy".
24
26
  def self.action_destroy
@@ -26,7 +28,7 @@ module VagrantPlugins
26
28
  b.use ConfigValidate
27
29
 
28
30
  b.use Call, IsState, :not_created do |env1, b1|
29
- raise Errors::InstanceNotCreatedError if env1[:result]
31
+ raise Errors::InstanceNotCreatedError if env1[:result]
30
32
 
31
33
  b1.use Call, DestroyConfirm do |env2, b2|
32
34
  if env2[:result]
@@ -11,9 +11,9 @@ module VagrantPlugins
11
11
  class Config < Vagrant.plugin("2", :config)
12
12
  # @return [String] The image registry
13
13
  attr_accessor :registry
14
- # @return [String] The image registry username
14
+ # @return [String] The image registry username (optional)
15
15
  attr_accessor :username
16
- # @return [String] The image registry password
16
+ # @return [String] The image registry password (optional)
17
17
  attr_accessor :password
18
18
 
19
19
  # @return [String] The image source
@@ -21,14 +21,14 @@ module VagrantPlugins
21
21
  # @return [String] The name
22
22
  attr_accessor :name
23
23
 
24
+ # @return [Boolean] Show a GUI window on boot, or run headless
25
+ attr_accessor :gui
24
26
  # @return [Integer] Number of CPUs
25
- attr_accessor :cpu
27
+ attr_accessor :cpus
26
28
  # @return [Integer] Memory size in MB
27
29
  attr_accessor :memory
28
30
  # @return [Integer] Disk storage size in GB
29
31
  attr_accessor :disk
30
- # @return [Boolean] Show a GUI window on boot, or run headless
31
- attr_accessor :gui
32
32
  # @return [String] Display screen resolution
33
33
  attr_accessor :display
34
34
  # @return [Boolean] Whether the machine is suspendable
@@ -48,10 +48,10 @@ module VagrantPlugins
48
48
  @image = UNSET_VALUE
49
49
  @name = UNSET_VALUE
50
50
 
51
- @cpu = UNSET_VALUE
51
+ @gui = UNSET_VALUE
52
+ @cpus = UNSET_VALUE
52
53
  @memory = UNSET_VALUE
53
54
  @disk = UNSET_VALUE
54
- @gui = UNSET_VALUE
55
55
  @display = UNSET_VALUE
56
56
  @suspendable = UNSET_VALUE
57
57
 
@@ -67,10 +67,10 @@ module VagrantPlugins
67
67
  @image = nil if @image == UNSET_VALUE
68
68
  @name = nil if @name == UNSET_VALUE
69
69
 
70
- @cpu = 1 if @cpu == UNSET_VALUE
70
+ @gui = false if @gui == UNSET_VALUE
71
+ @cpus = 1 if @cpus == UNSET_VALUE
71
72
  @memory = 1024 if @memory == UNSET_VALUE
72
73
  @disk = 10 if @disk == UNSET_VALUE
73
- @gui = false if @gui == UNSET_VALUE
74
74
  @display = "1024x768" if @display == UNSET_VALUE
75
75
  @suspendable = false if @suspendable == UNSET_VALUE
76
76
  end
@@ -79,12 +79,6 @@ module VagrantPlugins
79
79
  def validate(_machine)
80
80
  errors = _detected_errors
81
81
 
82
- # Sanity checks for the registry
83
- unless @registry.nil?
84
- errors << I18n.t("vagrant_tart.config.username_required") if @username.nil? || @username.empty?
85
- errors << I18n.t("vagrant_tart.config.password_required") if @password.nil? || @password.empty?
86
- end
87
-
88
82
  # Sanity checks for the image and the name
89
83
  errors << I18n.t("vagrant_tart.config.image_required") if @image.nil? || @image.empty?
90
84
  errors << I18n.t("vagrant_tart.config.name_required") if @name.nil? || @name.empty?
@@ -92,10 +86,10 @@ module VagrantPlugins
92
86
  # Check that the GUI flag is a valid boolean
93
87
  errors << I18n.t("vagrant_tart.config.gui_invalid") unless @gui == true || @gui == false
94
88
 
95
- # Check that CPU is a valid number and between 1 and the maximum available CPUs
89
+ # Check that CPUs is a valid number and between 1 and the maximum available CPUs
96
90
  max_cpus = Etc.nprocessors
97
- unless (@cpu.is_a? Integer) && @cpu >= 1 && @cpu <= max_cpus
98
- errors << I18n.t("vagrant_tart.config.cpu_invalid", max_cpus: max_cpus)
91
+ unless (@cpus.is_a? Integer) && @cpus >= 1 && @cpus <= max_cpus
92
+ errors << I18n.t("vagrant_tart.config.cpus_invalid", max_cpus: max_cpus)
99
93
  end
100
94
 
101
95
  # Check that memory is a valid number and between 1 and the maximum available memory
@@ -110,6 +104,9 @@ module VagrantPlugins
110
104
  # Check that the display resolution is a valid string conforming to the format "WIDTHxHEIGHT"
111
105
  errors << I18n.t("vagrant_tart.config.display_invalid") unless @display.match?(/^\d+x\d+$/)
112
106
 
107
+ # Check that the suspendable flag is a valid boolean
108
+ errors << I18n.t("vagrant_tart.config.suspendable_invalid") unless @suspendable == true || @suspendable == false
109
+
113
110
  { "Tart Provider" => errors }
114
111
  end
115
112
 
@@ -117,8 +114,10 @@ module VagrantPlugins
117
114
  @suspendable
118
115
  end
119
116
 
117
+ # Check if the configuration uses a registry.
118
+ # @return [Boolean] True if the configuration uses a registry, false otherwise
120
119
  def use_registry?
121
- !@registry.nil? && !@username.nil? && !@password.nil?
120
+ !@registry.nil?
122
121
  end
123
122
  end
124
123
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -6,7 +6,7 @@ module VagrantPlugins
6
6
  # Represents the result of a Tart 'get' operation.
7
7
  class GetResult
8
8
  # @return [Integer] The number of CPUs of the machine.
9
- attr_accessor :cpu
9
+ attr_accessor :cpus
10
10
  # @return [Integer] The size of the machine's disk.
11
11
  attr_accessor :disk
12
12
  # @return [Boolean] Whether the machine is running.
@@ -25,7 +25,7 @@ module VagrantPlugins
25
25
  # Initialize the result from raw data.
26
26
  # @param [Hash] data The raw data.
27
27
  def initialize(data)
28
- @cpu = data["CPU"]
28
+ @cpus = data["CPU"]
29
29
  @disk = data["Disk"]
30
30
  @running = data["Running"]
31
31
  @memory = data["Memory"]
@@ -26,7 +26,6 @@ module VagrantPlugins
26
26
  # Register the provider.
27
27
  provider(:tart, box_optional: true, parallel: true) do
28
28
  setup_i18n
29
-
30
29
  require_relative "provider"
31
30
  Provider
32
31
  end
@@ -5,5 +5,10 @@ HOST="$1"
5
5
  USERNAME="$2"
6
6
  PASSWORD="$3"
7
7
 
8
- # Login to the registry with the provided credentials
9
- echo "$PASSWORD" | tart login "$HOST" --username "$USERNAME" --password-stdin
8
+ if [[ -z "$USERNAME" ]] || [[ -z "$PASSWORD" ]]; then
9
+ # Assumes that the credentials are provided in another way (e.g. environment variables)
10
+ tart login "$HOST"
11
+ else
12
+ # Login to the registry with the provided credentials
13
+ echo "$PASSWORD" | tart login "$HOST" --username "$USERNAME" --password-stdin
14
+ fi
@@ -127,7 +127,7 @@ module VagrantPlugins
127
127
  # Map the key to the correct switch
128
128
  switch = nil
129
129
  case key
130
- when "cpu"
130
+ when "cpus"
131
131
  switch = "--cpu"
132
132
  when "memory"
133
133
  switch = "--memory"
@@ -4,6 +4,6 @@ module VagrantPlugins
4
4
  # Top level module for the Tart provider plugin.
5
5
  module Tart
6
6
  # Current version of the Tart provider plugin.
7
- VERSION = "0.0.2"
7
+ VERSION = "0.0.4"
8
8
  end
9
9
  end
data/locales/en.yml CHANGED
@@ -1,21 +1,22 @@
1
1
  en:
2
2
  vagrant_tart:
3
3
  config:
4
- image_required: |-
5
- Configuration must specify an image
6
- name_required: |-
7
- Configuration must specify a virtual machine name
8
-
9
- gui_invalid: |-
10
- Configuration must specify a valid GUI setting (true or false)
11
- cpu_invalid: |-
12
- Configuration must specify a valid CPU count (between 1 and %{max_cpus})
13
- memory_invalid: |-
14
- Configuration must specify a valid memory size (between 1 and %{max_memory} MB)
4
+ cpus_invalid: |-
5
+ Configuration must specify a valid CPUs count (between 1 and %{max_cpus})
15
6
  disk_invalid: |-
16
7
  Configuration must specify a valid disk size (greater than 1 GB)
17
8
  display_invalid: |-
18
9
  Configuration must specify a valid display size (WIDTHxHEIGHT pixels)
10
+ gui_invalid: |-
11
+ Configuration must specify a valid GUI setting (true or false)
12
+ image_required: |-
13
+ Configuration must specify an image
14
+ memory_invalid: |-
15
+ Configuration must specify a valid memory size (between 1 and %{max_memory} MB)
16
+ name_required: |-
17
+ Configuration must specify a virtual machine name
18
+ suspendable_invalid: |-
19
+ Configuration must specify a valid suspendable setting (true or false)
19
20
 
20
21
  errors:
21
22
  command_error: |-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-tart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Etiemble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-05 00:00:00.000000000 Z
11
+ date: 2024-06-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Allows Vagrant to manage Tart virtual machines.
14
14
  email: