Module: Kplay::Minikube
- Defined in:
- lib/kplay/minikube.rb
Class Method Summary collapse
-
.host_path_in_vm(path_host) ⇒ String
Given the path on host returns the corresponding path in VM.
-
.hostfolder_host ⇒ Object
Returns the host folder, path on host.
-
.hostfolder_vm ⇒ Object
Returns the host folder mount point, path on minikube VM.
-
.ssh_forwarding_available? ⇒ Boolean
Returns true if SSH agent forwarding can be enabled (socket resides in VM mounted folders).
-
.ssh_forwarding_socket_vm ⇒ Object
Returns path to SSH agent forwarding socket in a VM.
Class Method Details
.host_path_in_vm(path_host) ⇒ String
Given the path on host returns the corresponding path in VM. Raises an error if the folder on host is not mounted.
40 41 42 43 44 45 |
# File 'lib/kplay/minikube.rb', line 40 def self.host_path_in_vm(path_host) unless path_host.to_s.start_with?(hostfolder_host.to_s) raise ArgumentError, "Failed to find mount point for: '#{path_host}', parent is not mounted" end Pathname.new(path_host.to_s.sub(hostfolder_host.to_s, hostfolder_vm.to_s)) end |
.hostfolder_host ⇒ Object
Returns the host folder, path on host.
Host folder is the single folder Minikube mounts by default into the VM. Usually it’s /home or /Users.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kplay/minikube.rb', line 10 def self.hostfolder_host case Kplay.host_os when :linux '/home/' when :macosx '/Users/' else raise 'Cannot identify mounted host folder, unknown OS' end end |
.hostfolder_vm ⇒ Object
Returns the host folder mount point, path on minikube VM
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kplay/minikube.rb', line 23 def self.hostfolder_vm case Kplay.host_os when :linux '/hosthome/' when :macosx '/Users/' else raise 'Cannot identify mounted host folder, unknown OS' end end |
.ssh_forwarding_available? ⇒ Boolean
Returns true if SSH agent forwarding can be enabled (socket resides in VM mounted folders)
51 52 53 |
# File 'lib/kplay/minikube.rb', line 51 def self.ssh_forwarding_available? !!ssh_forwarding_socket_vm end |
.ssh_forwarding_socket_vm ⇒ Object
Returns path to SSH agent forwarding socket in a VM
57 58 59 60 61 |
# File 'lib/kplay/minikube.rb', line 57 def self.ssh_forwarding_socket_vm socket_path = ENV['SSH_AUTH_SOCK'] return nil unless socket_path Minikube.host_path_in_vm(socket_path) rescue nil end |