main: Properly handle provider installation method exclusions
Previously we were incorrectly using the Include configuration for both the include and exclude list, making the include portion totally ineffective.
This commit is contained in:
parent
3167067029
commit
6b2050f42a
|
@ -229,13 +229,17 @@ type ProviderInstallationLocation interface {
|
|||
providerInstallationLocation()
|
||||
}
|
||||
|
||||
type configProviderInstallationDirect [0]byte
|
||||
type providerInstallationDirect [0]byte
|
||||
|
||||
func (i configProviderInstallationDirect) providerInstallationLocation() {}
|
||||
func (i providerInstallationDirect) providerInstallationLocation() {}
|
||||
|
||||
// ProviderInstallationDirect is a ProviderInstallationSourceLocation
|
||||
// representing installation from a provider's origin registry.
|
||||
var ProviderInstallationDirect ProviderInstallationLocation = configProviderInstallationDirect{}
|
||||
var ProviderInstallationDirect ProviderInstallationLocation = providerInstallationDirect{}
|
||||
|
||||
func (i providerInstallationDirect) GoString() string {
|
||||
return "cliconfig.ProviderInstallationDirect"
|
||||
}
|
||||
|
||||
// ProviderInstallationFilesystemMirror is a ProviderInstallationSourceLocation
|
||||
// representing installation from a particular local filesystem mirror. The
|
||||
|
@ -244,6 +248,10 @@ type ProviderInstallationFilesystemMirror string
|
|||
|
||||
func (i ProviderInstallationFilesystemMirror) providerInstallationLocation() {}
|
||||
|
||||
func (i ProviderInstallationFilesystemMirror) GoString() string {
|
||||
return fmt.Sprintf("cliconfig.ProviderInstallationFilesystemMirror(%q)", i)
|
||||
}
|
||||
|
||||
// ProviderInstallationNetworkMirror is a ProviderInstallationSourceLocation
|
||||
// representing installation from a particular local network mirror. The
|
||||
// string value is the HTTP base URL exactly as written in the configuration,
|
||||
|
@ -251,3 +259,7 @@ func (i ProviderInstallationFilesystemMirror) providerInstallationLocation() {}
|
|||
type ProviderInstallationNetworkMirror string
|
||||
|
||||
func (i ProviderInstallationNetworkMirror) providerInstallationLocation() {}
|
||||
|
||||
func (i ProviderInstallationNetworkMirror) GoString() string {
|
||||
return fmt.Sprintf("cliconfig.ProviderInstallationNetworkMirror(%q)", i)
|
||||
}
|
||||
|
|
|
@ -2,4 +2,7 @@ provider_installation {
|
|||
filesystem_mirror {
|
||||
path = "./fs-mirror"
|
||||
}
|
||||
direct {
|
||||
exclude = ["example.com/*/*"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func explicitProviderSource(config *cliconfig.ProviderInstallation, services *di
|
|||
var diags tfdiags.Diagnostics
|
||||
var searchRules []getproviders.MultiSourceSelector
|
||||
|
||||
log.Printf("[DEBUG] Explicit provider installation configuration is set")
|
||||
for _, methodConfig := range config.Methods {
|
||||
source, moreDiags := providerSourceForCLIConfigLocation(methodConfig.Location, services)
|
||||
diags = diags.Append(moreDiags)
|
||||
|
@ -53,14 +54,16 @@ func explicitProviderSource(config *cliconfig.ProviderInstallation, services *di
|
|||
"Invalid provider source inclusion patterns",
|
||||
fmt.Sprintf("CLI config specifies invalid provider inclusion patterns: %s.", err),
|
||||
))
|
||||
continue
|
||||
}
|
||||
exclude, err := getproviders.ParseMultiSourceMatchingPatterns(methodConfig.Include)
|
||||
exclude, err := getproviders.ParseMultiSourceMatchingPatterns(methodConfig.Exclude)
|
||||
if err != nil {
|
||||
diags = diags.Append(tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
"Invalid provider source exclusion patterns",
|
||||
fmt.Sprintf("CLI config specifies invalid provider exclusion patterns: %s.", err),
|
||||
))
|
||||
continue
|
||||
}
|
||||
|
||||
searchRules = append(searchRules, getproviders.MultiSourceSelector{
|
||||
|
@ -68,6 +71,8 @@ func explicitProviderSource(config *cliconfig.ProviderInstallation, services *di
|
|||
Include: include,
|
||||
Exclude: exclude,
|
||||
})
|
||||
|
||||
log.Printf("[TRACE] Selected provider installation method %#v with includes %s and excludes %s", methodConfig.Location, include, exclude)
|
||||
}
|
||||
|
||||
return getproviders.MultiSource(searchRules), diags
|
||||
|
|
Loading…
Reference in New Issue