Mark configs with unique id. Use id for provisioner caching.
This commit is contained in:
parent
8a41ef3396
commit
778d009bfb
@ -127,6 +127,12 @@ module VagrantPlugins
|
||||
end
|
||||
end
|
||||
|
||||
# Include a unique identifier for this configuration instance. This
|
||||
# will allow us to identifier it later when it is decoded.
|
||||
if !data.key?("_vagrant_config_identifier")
|
||||
data["_vagrant_config_identifier"] = SecureRandom.uuid
|
||||
end
|
||||
|
||||
entries = data.map do |k, v|
|
||||
begin
|
||||
SDK::Args::HashEntry.new(
|
||||
|
||||
@ -75,10 +75,13 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
def load_provisioner(klass, machine, config)
|
||||
key = cache.key(klass, machine)
|
||||
return cache.get(key) if cache.registered?(key)
|
||||
ident = config.instance_variable_get(:@_vagrant_config_identifier)
|
||||
if ident
|
||||
key = cache.key(klass, machine, ident)
|
||||
return cache.get(key) if cache.registered?(key)
|
||||
end
|
||||
klass.new(machine, config).tap do |i|
|
||||
cache.register(key, i)
|
||||
cache.register(key, i) if key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Patch things to produce proto messages
|
||||
require "pathname"
|
||||
require "securerandom"
|
||||
require "google/protobuf/wrappers_pb"
|
||||
require "google/protobuf/well_known_types"
|
||||
|
||||
@ -147,6 +148,12 @@ class Vagrant::Plugin::V2::Config
|
||||
end
|
||||
end
|
||||
|
||||
# Include a unique identifier for this configuration instance. This
|
||||
# will allow us to identifier it later when it is decoded.
|
||||
if !data.key?("_vagrant_config_identifier")
|
||||
data["_vagrant_config_identifier"] = SecureRandom.uuid
|
||||
end
|
||||
|
||||
entries = data.map do |k, v|
|
||||
Hashicorp::Vagrant::Sdk::Args::HashEntry.new(
|
||||
key: k.to_any,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user