Class: VagrantLXD::Action::CheckForSyncedFolderSupport

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxd/action.rb

Overview

Issue a warning when the machine wants synced folders but the host doesn’t support it (according to the relevant shadow files).

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CheckForSyncedFolderSupport

Returns a new instance of CheckForSyncedFolderSupport.



121
122
123
124
# File 'lib/vagrant-lxd/action.rb', line 121

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/vagrant-lxd/action.rb', line 126

def call(env)
  enabled_folders = env[:machine].config.vm.synced_folders.reject do |_, options|
    next true if options[:disabled]
    next true unless options[:type].nil? or options[:type] == :lxd
  end

  if enabled_folders.any? and not env[:host].capability(:synced_folders)
    env[:ui].error 'The host machine does not support LXD synced folders.'
    env[:ui].warn ''
    env[:ui].warn 'To use this feature, you must first configure ID mappings for the'
    env[:ui].warn 'current user in /etc/subuid and /etc/subgid. For more information,'
    env[:ui].warn "refer to `#{File.basename($0)} lxd shadow --help`."
    env[:ui].warn ''
  end

  @app.call(env)
end