Skip to content

Commit 4e65895

Browse files
committed
Change the message shown when a provider is reused during the second provider download step.
When downloading providers described only in the state then the provider may already be downloaded from a previous init (i.e. is recorded in the deps lock file) or downloaded during step 1 of provider download. The message here needs to cover both potential scenarios.
1 parent 0ea0c6f commit 4e65895

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

internal/command/init.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ func (c *InitCommand) getProvidersFromConfig(ctx context.Context, config *config
868868
log.Printf("[DEBUG] will search for provider plugins in %s", pluginDirs)
869869
}
870870

871-
evts := c.prepareInstallerEvents(ctx, reqs, diags, inst, view, views.InitializingProviderPluginFromConfigMessage)
871+
evts := c.prepareInstallerEvents(ctx, reqs, diags, inst, view, views.InitializingProviderPluginFromConfigMessage, views.ReusingPreviousVersionInfo)
872872
ctx = evts.OnContext(ctx)
873873

874874
mode := providercache.InstallNewProvidersOnly
@@ -982,7 +982,7 @@ func (c *InitCommand) getProvidersFromState(ctx context.Context, state *states.S
982982
// things relatively concise. Later it'd be nice to have a progress UI
983983
// where statuses update in-place, but we can't do that as long as we
984984
// are shimming our vt100 output to the legacy console API on Windows.
985-
evts := c.prepareInstallerEvents(ctx, reqs, diags, inst, view, views.InitializingProviderPluginFromStateMessage)
985+
evts := c.prepareInstallerEvents(ctx, reqs, diags, inst, view, views.InitializingProviderPluginFromStateMessage, views.ReusingVersionIdentifiedFromConfig)
986986
ctx = evts.OnContext(ctx)
987987

988988
mode := providercache.InstallNewProvidersOnly
@@ -1091,7 +1091,7 @@ func (c *InitCommand) saveDependencyLockFile(previousLocks, configLocks, stateLo
10911091
// prepareInstallerEvents returns an instance of *providercache.InstallerEvents. This struct defines callback functions that will be executed
10921092
// when a specific type of event occurs during provider installation.
10931093
// The calling code needs to provide a tfdiags.Diagnostics collection, so that provider installation code returns diags to the calling code using closures
1094-
func (c *InitCommand) prepareInstallerEvents(ctx context.Context, reqs providerreqs.Requirements, diags tfdiags.Diagnostics, inst *providercache.Installer, view views.Init, initMsg views.InitMessageCode) *providercache.InstallerEvents {
1094+
func (c *InitCommand) prepareInstallerEvents(ctx context.Context, reqs providerreqs.Requirements, diags tfdiags.Diagnostics, inst *providercache.Installer, view views.Init, initMsg views.InitMessageCode, reuseMsg views.InitMessageCode) *providercache.InstallerEvents {
10951095

10961096
// Because we're currently just streaming a series of events sequentially
10971097
// into the terminal, we're showing only a subset of the events to keep
@@ -1117,7 +1117,7 @@ func (c *InitCommand) prepareInstallerEvents(ctx context.Context, reqs providerr
11171117
},
11181118
QueryPackagesBegin: func(provider addrs.Provider, versionConstraints getproviders.VersionConstraints, locked bool) {
11191119
if locked {
1120-
view.LogInitMessage(views.ReusingPreviousVersionInfo, provider.ForDisplay())
1120+
view.LogInitMessage(reuseMsg, provider.ForDisplay())
11211121
} else {
11221122
if len(versionConstraints) > 0 {
11231123
view.LogInitMessage(views.FindingMatchingVersionMessage, provider.ForDisplay(), getproviders.VersionConstraintsString(versionConstraints))

internal/command/views/init.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ var MessageRegistry map[InitMessageCode]InitMessage = map[InitMessageCode]InitMe
226226
HumanValue: "- Reusing previous version of %s from the dependency lock file",
227227
JSONValue: "%s: Reusing previous version from the dependency lock file",
228228
},
229+
"reusing_version_during_state_provider_init": {
230+
HumanValue: "- Reusing previous version of %s.",
231+
JSONValue: "%s: Reusing previous version of %s.",
232+
},
229233
"finding_matching_version_message": {
230234
HumanValue: "- Finding %s versions matching %q...",
231235
JSONValue: "Finding matching versions for provider: %s, version_constraint: %q",
@@ -289,6 +293,7 @@ const (
289293
ProviderAlreadyInstalledMessage InitMessageCode = "provider_already_installed_message"
290294
BuiltInProviderAvailableMessage InitMessageCode = "built_in_provider_available_message"
291295
ReusingPreviousVersionInfo InitMessageCode = "reusing_previous_version_info"
296+
ReusingVersionIdentifiedFromConfig InitMessageCode = "reusing_version_during_state_provider_init"
292297
FindingMatchingVersionMessage InitMessageCode = "finding_matching_version_message"
293298
FindingLatestVersionMessage InitMessageCode = "finding_latest_version_message"
294299
UsingProviderFromCacheDirInfo InitMessageCode = "using_provider_from_cache_dir_info"

0 commit comments

Comments
 (0)