Skip to content

Commit df703ee

Browse files
committed
Rename methods and update godoc comments
1 parent 699a3b0 commit df703ee

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

internal/command/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ func (m *Meta) contextOpts() (*terraform.ContextOpts, error) {
546546
opts.Provisioners = m.testingOverrides.Provisioners
547547
} else {
548548
var providerFactories map[addrs.Provider]providers.Factory
549-
providerFactories, err = m.providerFactories()
549+
providerFactories, err = m.ProviderFactories()
550550
opts.Providers = providerFactories
551551
opts.Provisioners = m.provisionerFactories()
552552
}

internal/command/meta_backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ func (m *Meta) getStateStoreProviderFactory(config *configs.StateStore, configLo
23222322
config.Provider.Name))
23232323
}
23242324

2325-
factories, err := m.providerFactoriesDuringInit(configLocks)
2325+
factories, err := m.ProviderFactoriesFromLocks(configLocks)
23262326
if err != nil {
23272327
return nil, diags.Append(fmt.Errorf("error when retrieving provider factories: %w", err))
23282328
}

internal/command/meta_backend_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,7 @@ func TestMetaBackend_getStateStoreProviderFactory(t *testing.T) {
24532453

24542454
// Setup the meta and test providerFactoriesDuringInit
24552455
m := testMetaBackend(t, nil)
2456-
factories, err := m.providerFactoriesDuringInit(locks)
2456+
factories, err := m.ProviderFactoriesFromLocks(locks)
24572457
if err != nil {
24582458
t.Fatalf("unexpected error : %s", err)
24592459
}

internal/command/meta_providers.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,18 @@ func (m *Meta) providerDevOverrideRuntimeWarningsRemoteExecution() tfdiags.Diagn
247247
}
248248
}
249249

250-
// providerFactories uses the selections made previously by an installer in
250+
// ProviderFactories uses the selections made previously by an installer in
251251
// the local cache directory (m.providerLocalCacheDir) to produce a map
252-
// from provider addresses to factory functions to create instances of
252+
// of provider addresses to factory functions to create instances of
253253
// those providers.
254254
//
255-
// providerFactories will return an error if the installer's selections cannot
255+
// ProviderFactories will return an error if the installer's selections cannot
256256
// be honored with what is currently in the cache, such as if a selected
257257
// package has been removed from the cache or if the contents of a selected
258258
// package have been modified outside of the installer. If it returns an error,
259259
// the returned map may be incomplete or invalid, but will be as complete
260260
// as possible given the cause of the error.
261-
func (m *Meta) providerFactories() (map[addrs.Provider]providers.Factory, error) {
261+
func (m *Meta) ProviderFactories() (map[addrs.Provider]providers.Factory, error) {
262262
locks, diags := m.lockedDependencies()
263263
if diags.HasErrors() {
264264
return nil, fmt.Errorf("failed to read dependency lock file: %s", diags.Err())
@@ -267,9 +267,16 @@ func (m *Meta) providerFactories() (map[addrs.Provider]providers.Factory, error)
267267
return m.providerFactoriesFromLocks(locks)
268268
}
269269

270-
func (m *Meta) providerFactoriesDuringInit(configLocks *depsfile.Locks) (map[addrs.Provider]providers.Factory, error) {
270+
// ProviderFactoriesFromLocks receives in memory locks and uses them to produce a map
271+
// of provider addresses to factory functions to create instances of
272+
// those providers.
273+
//
274+
// ProviderFactoriesFromLocks should only be used if the calling code relies on locks
275+
// that have not yet been persisted to a dependency lock file on disk. Realistically, this
276+
// means only code in the init command should use this method.
277+
func (m *Meta) ProviderFactoriesFromLocks(configLocks *depsfile.Locks) (map[addrs.Provider]providers.Factory, error) {
271278
// Ensure overrides and unmanaged providers are reflected in the returned list of factories,
272-
// while avoiding mutating the in-memory locks.
279+
// while avoiding mutating the in-memory
273280
locks := m.annotateDependencyLocksWithOverrides(configLocks.DeepCopy())
274281

275282
return m.providerFactoriesFromLocks(locks)
@@ -279,8 +286,8 @@ func (m *Meta) providerFactoriesDuringInit(configLocks *depsfile.Locks) (map[add
279286
//
280287
// In most cases, calling code should not use this method directly.
281288
// Instead, use:
282-
// * `providerFactoriesDuringInit` - for use when locks aren't yet persisted to a dependency lock file.
283-
// * `providerFactories` - for use when Terraform is guaranteed to read all necessary locks from a dependency lock file.
289+
// * `ProviderFactoriesFromLocks` - for use when locks aren't yet persisted to a dependency lock file.
290+
// * `ProviderFactories` - for use when Terraform is guaranteed to read all necessary locks from a dependency lock file.
284291
func (m *Meta) providerFactoriesFromLocks(locks *depsfile.Locks) (map[addrs.Provider]providers.Factory, error) {
285292
// We'll always run through all of our providers, even if one of them
286293
// encounters an error, so that we can potentially report multiple errors

0 commit comments

Comments
 (0)