kitchen-vagrant 2.1.3 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dacf84b53e50807b2391c69d3ae7f903965dde4ba59630d8074079ef90df5fc0
4
- data.tar.gz: d1858fb64df4930c100a6866cd92417419d230720f6a335857237ea719bc8aac
3
+ metadata.gz: 5f38360fb2e76468a3b8fec2cc9605529a3627fb6887fc0054db601ef2b14c1b
4
+ data.tar.gz: 8697570d8be74b4e5f674707be02a1aa45b21acd2836b033075e0bea0667bf76
5
5
  SHA512:
6
- metadata.gz: 3030c84bcf25c246c201cb851beded8c826ec25a6d54c4b37f63ae50f3099d58fc03a0cabeda3f761b3e7041bba12db9dadb8556f3a5c8a8b4b4f44801f78292
7
- data.tar.gz: c1e1b21e07c471ff3a8c963b9d98c66797904f69ab40a115520d8bc53facb220b3e8a0ed27d55c0aff2ff4c65b5f4bd2a25fb785cf4c1ed3a2925cd449c98de3
6
+ metadata.gz: 2742d9a6cf27c11dd986ff5054c9c389c94637b7cfc50bb677ca43411e8b3d336d3adce1bf50be6a20ab524f41c8cfa24237b2591d265a0b46843adaffb429e0
7
+ data.tar.gz: 02cab0d3a12310cf6da7efdfc62011a621b9daa991430fc1efce6041ebbc40d18d4c5c661562eac4d055db020c0bc06f308b98bb089daf17fd579fe222d454ad
@@ -116,6 +116,7 @@ module Kitchen
116
116
  def create(state)
117
117
  create_vagrantfile
118
118
  run_pre_create_command
119
+ check_box_outdated
119
120
  run_box_auto_update
120
121
  run_box_auto_prune
121
122
  run_vagrant_up
@@ -474,6 +475,81 @@ module Kitchen
474
475
  end
475
476
  # rubocop:enable Metrics/CyclomaticComplexity
476
477
 
478
+ # Check if a newer version of the vagrant box is available and warn the user
479
+ #
480
+ # @api private
481
+ def check_box_outdated
482
+ # Skip if box_auto_update is enabled (they'll get the update anyway)
483
+ return if config[:box_auto_update]
484
+
485
+ cmd = "#{config[:vagrant_binary]} box outdated --box #{config[:box]}"
486
+ cmd += " --provider #{config[:provider]}" if config[:provider]
487
+
488
+ begin
489
+ output = run_silently(cmd)
490
+ warn_if_outdated(output)
491
+ rescue Kitchen::ShellOut::ShellCommandFailed => e
492
+ # If the box isn't installed yet or there's an error checking, silently continue
493
+ # This can happen on first run before the box is downloaded
494
+ debug("Unable to check if box is outdated: #{e.message}")
495
+ end
496
+ end
497
+
498
+ # Parse vagrant box outdated output and warn if a new version is available
499
+ #
500
+ # @param output [String] output from vagrant box outdated command
501
+ # @api private
502
+ def warn_if_outdated(output)
503
+ return unless box_is_outdated?(output)
504
+
505
+ current_version = extract_current_version(output)
506
+ latest_version = extract_latest_version(output)
507
+
508
+ warning_msg = "A new version of the '#{config[:box]}' box is available!"
509
+ if current_version && latest_version
510
+ warning_msg += " Current: #{current_version}, Latest: #{latest_version}."
511
+ end
512
+ warning_msg += " Run `vagrant box update --box #{config[:box]}` to update."
513
+
514
+ warn(warning_msg)
515
+ end
516
+
517
+ # Check if the vagrant box outdated output indicates an outdated box
518
+ #
519
+ # @param output [String] output from vagrant box outdated command
520
+ # @return [Boolean] true if box is outdated
521
+ # @api private
522
+ def box_is_outdated?(output)
523
+ # Check for various output patterns indicating an outdated box
524
+ # Use include? instead of complex regexes to avoid ReDoS vulnerabilities
525
+ output_downcase = output.downcase
526
+ output_downcase.include?("is outdated") ||
527
+ output_downcase.include?("newer version") && output_downcase.include?("available") ||
528
+ output_downcase.include?("newer version of the box")
529
+ end
530
+
531
+ # Extract current version from vagrant box outdated output
532
+ #
533
+ # @param output [String] output from vagrant box outdated command
534
+ # @return [String, nil] current version or nil if not found
535
+ # @api private
536
+ def extract_current_version(output)
537
+ match = output.match(/Current:\s+v?(\S+)/i) ||
538
+ output.match(/currently have version\s+'?v?([^'.\s]+)/i)
539
+ match ? match[1] : nil
540
+ end
541
+
542
+ # Extract latest version from vagrant box outdated output
543
+ #
544
+ # @param output [String] output from vagrant box outdated command
545
+ # @return [String, nil] latest version or nil if not found
546
+ # @api private
547
+ def extract_latest_version(output)
548
+ match = output.match(/Latest:\s+v?(\S+)/i) ||
549
+ output.match(/latest is version\s+'?v?([^'.\s]+)/i)
550
+ match ? match[1] : nil
551
+ end
552
+
477
553
  # Tell vagrant to update vagrant box to latest version
478
554
  def run_box_auto_update
479
555
  if config[:box_auto_update]
@@ -559,6 +635,38 @@ module Kitchen
559
635
  @vagrant_root
560
636
  end
561
637
 
638
+ # @return [true,false] whether or not we're running in WSL
639
+ # @api private
640
+ def wsl?
641
+ # Check for WSL via environment variables
642
+ return true if ENV["WSL_DISTRO_NAME"]
643
+ return true if ENV["VAGRANT_WSL_ENABLE_WINDOWS_ACCESS"]
644
+
645
+ # Check for WSL via /proc/version
646
+ if File.exist?("/proc/version")
647
+ version_content = File.read("/proc/version")
648
+ return true if version_content.match?(/microsoft|wsl/i)
649
+ end
650
+
651
+ false
652
+ rescue
653
+ false
654
+ end
655
+
656
+ # Converts a Windows path to a WSL path
657
+ # @param path [String] Windows path (e.g., "C:/Users/...")
658
+ # @return [String] WSL path (e.g., "/mnt/c/users/...")
659
+ # @api private
660
+ def windows_to_wsl_path(path)
661
+ # Only convert if it looks like a Windows path
662
+ if path.match?(%r{^[A-Za-z]:/})
663
+ # Convert C:/path to /mnt/c/path
664
+ path.gsub(/^([A-Za-z]):/, '/mnt/\1').downcase
665
+ else
666
+ path
667
+ end
668
+ end
669
+
562
670
  # @param type [Symbol] either `:ssh` or `:winrm`
563
671
  # @return [Hash] key/value pairs resulting from parsing a
564
672
  # `vagrant ssh-config` or `vagrant winrm-config` local command
@@ -568,7 +676,10 @@ module Kitchen
568
676
  lines = run_silently("#{config[:vagrant_binary]} #{type}-config")
569
677
  .split("\n").map do |line|
570
678
  tokens = line.strip.partition(" ")
571
- [tokens.first, tokens.last.delete('"')]
679
+ value = tokens.last.delete('"')
680
+ # Convert Windows paths to WSL paths when running in WSL
681
+ value = windows_to_wsl_path(value) if wsl? && tokens.first == "IdentityFile"
682
+ [tokens.first, value]
572
683
  end
573
684
  Hash[lines]
574
685
  end
@@ -20,6 +20,6 @@ module Kitchen
20
20
  module Driver
21
21
 
22
22
  # Version string for Vagrant Kitchen driver
23
- VAGRANT_VERSION = "2.1.3".freeze
23
+ VAGRANT_VERSION = "2.2.0".freeze
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen