Fix some bugs in provider options handling
- Defaultable needs to default to true when it's not specified - We need to allow a non-defaultable provider to be selected if it shows up in the config
This commit is contained in:
parent
00829ba9e6
commit
71cc8ee7bb
@ -161,8 +161,21 @@ func (p *Project) DefaultProvider(opts *core.DefaultProviderOptions) (string, er
|
||||
}
|
||||
|
||||
plugOpts := plug.Options.(*component.ProviderOptions)
|
||||
logger.Debug("got provider options", "options", fmt.Sprintf("%#v", plugOpts))
|
||||
|
||||
// Skip providers that can't be defaulted, unless they're in our
|
||||
// config, in which case someone made our decision for us.
|
||||
if !plugOpts.Defaultable {
|
||||
logger.Debug("skipping non-defaultable provider", "provider", pp.Name)
|
||||
inConfig := false
|
||||
for _, cp := range configProviders {
|
||||
if cp == pp.Name {
|
||||
inConfig = true
|
||||
}
|
||||
}
|
||||
if !inConfig {
|
||||
logger.Debug("skipping non-defaultable provider", "provider", pp.Name)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Skip the providers that aren't usable.
|
||||
@ -174,6 +187,7 @@ func (p *Project) DefaultProvider(opts *core.DefaultProviderOptions) (string, er
|
||||
return "", err
|
||||
}
|
||||
if !usable {
|
||||
logger.Debug("Skipping unusable provider", "provider", pp.Name)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,14 +103,20 @@ module VagrantPlugins
|
||||
when :PROVIDER
|
||||
_, popts = class_or_tuple_with_class_and_options
|
||||
return SDK::PluginInfo::ProviderOptions.new(
|
||||
# Priority is always set in V2::Plugin.provider
|
||||
priority: popts[:priority],
|
||||
parallel: !!popts[:parallel],
|
||||
box_optional: !!popts[:box_optional],
|
||||
defaultable: !!popts[:defaultable],
|
||||
# Parallel is passed along to Environment#batch which defaults it to true
|
||||
parallel: popts.fetch(:parallel, true),
|
||||
# BoxOptional defaults to falsy when it's used in Kernel_V2::VMConfig
|
||||
box_optional: popts.fetch(:box_optional, false),
|
||||
# Defaultable is considered true when it is not specified in Environment#default_provider
|
||||
defaultable: popts.fetch(:defaultable, true),
|
||||
)
|
||||
when :PROVISIONER
|
||||
# No options for provisioners
|
||||
return Google::Protobuf::Empty.new
|
||||
when :PUSH
|
||||
# Push plugins accept an options hash but it's never used.
|
||||
return Google::Protobuf::Empty.new
|
||||
when :SYNCEDFOLDER
|
||||
_, sf_priority = class_or_tuple_with_class_and_options
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user