@@ -49,28 +49,6 @@ type moduleVersion struct {
49
49
version string
50
50
}
51
51
52
- // TypeModuleVersionDeprecation is a constant of TypeDiagnosticExtra indicating
53
- // that a Warning is related to a deprecated module version is in use.
54
- type TypeDiagnosticExtra string
55
-
56
- const TypeModuleVersionDeprecation TypeDiagnosticExtra = "module_version_deprecation"
57
-
58
- // ModuleVersionDeprecationDiagnosticExtra holds the diagnostic information
59
- // about the deprecation of a module version. This ends up being serialized as extra data within a
60
- // diagnostic and should be considered public API.
61
- type ModuleVersionDeprecationDiagnosticExtra struct {
62
- Type TypeDiagnosticExtra `json:"type"`
63
- Version string `json:"version"`
64
- SourceAddr string `json:"source_name"`
65
- DeprecationMessage string `json:"deprecation_message"`
66
- Link string `json:"link"`
67
- }
68
-
69
- // IsPublic confirms the visibility of the extra field in the public API.
70
- func (m ModuleVersionDeprecationDiagnosticExtra ) IsPublic () {
71
- // NOP
72
- }
73
-
74
52
func NewModuleInstaller (modsDir string , loader * configload.Loader , reg * registry.Client ) * ModuleInstaller {
75
53
return & ModuleInstaller {
76
54
modsDir : modsDir ,
@@ -276,32 +254,6 @@ func (i *ModuleInstaller) moduleInstallWalker(ctx context.Context, manifest mods
276
254
}
277
255
278
256
log .Printf ("[TRACE] ModuleInstaller: Module installer: %s %s already installed in %s" , key , record .Version , record .Dir )
279
-
280
- // Checking for module deprecations in the case no new module versions need installation
281
- if addr , isRegistryModule := req .SourceAddr .(addrs.ModuleSourceRegistry ); isRegistryModule {
282
- regClient := i .reg
283
-
284
- regsrcAddr := regsrc .ModuleFromRegistryPackageAddr (addr .Package )
285
- resp , err := regClient .ModuleVersions (ctx , regsrcAddr )
286
- if err != nil {
287
- log .Printf ("[WARN] Deprecation for %s could not be checked: call to registry failed: %v" , addr .Package .String (), err )
288
-
289
- } else {
290
- found:
291
- for _ , modProviderVersions := range resp .Modules {
292
- for _ , modVersion := range modProviderVersions .Versions {
293
- vm , _ := version .NewVersion (modVersion .Version )
294
- if vm .Equal (record .Version ) {
295
- if modVersion .Deprecation != nil {
296
- diags = append (diags , buildModuleVersionDeprecationWarning (modVersion , req , addr .Package .String ()))
297
- }
298
- break found
299
- }
300
- }
301
- }
302
- }
303
- }
304
-
305
257
return mod , record .Version , diags
306
258
}
307
259
}
@@ -528,8 +480,7 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
528
480
529
481
modMeta := resp .Modules [0 ]
530
482
531
- var latestMatch * response.ModuleVersion
532
- var latestMatchVersion * version.Version
483
+ var latestMatch * version.Version
533
484
var latestVersion * version.Version
534
485
for _ , mv := range modMeta .Versions {
535
486
v , err := version .NewVersion (mv .Version )
@@ -594,9 +545,8 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
594
545
}
595
546
596
547
if req .VersionConstraint .Required .Check (v ) {
597
- if latestMatch == nil || v .GreaterThan (latestMatchVersion ) {
598
- latestMatch = mv
599
- latestMatchVersion = v
548
+ if latestMatch == nil || v .GreaterThan (latestMatch ) {
549
+ latestMatch = v
600
550
}
601
551
}
602
552
}
@@ -621,27 +571,23 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
621
571
return nil , nil , diags
622
572
}
623
573
624
- if latestMatch .Deprecation != nil {
625
- diags = diags .Append (buildModuleVersionDeprecationWarning (latestMatch , req , addr .Package .String ()))
626
- }
627
-
628
574
// Report up to the caller that we're about to start downloading.
629
- hooks .Download (key , packageAddr .String (), latestMatchVersion )
575
+ hooks .Download (key , packageAddr .String (), latestMatch )
630
576
631
577
// If we manage to get down here then we've found a suitable version to
632
578
// install, so we need to ask the registry where we should download it from.
633
579
// The response to this is a go-getter-style address string.
634
580
635
581
// first check the cache for the download URL
636
- moduleAddr := moduleVersion {module : packageAddr , version : latestMatchVersion .String ()}
582
+ moduleAddr := moduleVersion {module : packageAddr , version : latestMatch .String ()}
637
583
if _ , exists := i .registryPackageSources [moduleAddr ]; ! exists {
638
- realAddrRaw , err := reg .ModuleLocation (ctx , regsrcAddr , latestMatchVersion .String ())
584
+ realAddrRaw , err := reg .ModuleLocation (ctx , regsrcAddr , latestMatch .String ())
639
585
if err != nil {
640
- log .Printf ("[ERROR] %s from %s %s: %s" , key , addr , latestMatchVersion , err )
586
+ log .Printf ("[ERROR] %s from %s %s: %s" , key , addr , latestMatch , err )
641
587
diags = diags .Append (& hcl.Diagnostic {
642
588
Severity : hcl .DiagError ,
643
589
Summary : "Error accessing remote module registry" ,
644
- Detail : fmt .Sprintf ("Failed to retrieve a download URL for %s %s from %s: %s" , addr , latestMatchVersion , hostname , err ),
590
+ Detail : fmt .Sprintf ("Failed to retrieve a download URL for %s %s from %s: %s" , addr , latestMatch , hostname , err ),
645
591
})
646
592
return nil , nil , diags
647
593
}
@@ -650,7 +596,7 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
650
596
diags = diags .Append (& hcl.Diagnostic {
651
597
Severity : hcl .DiagError ,
652
598
Summary : "Invalid package location from module registry" ,
653
- Detail : fmt .Sprintf ("Module registry %s returned invalid source location %q for %s %s: %s." , hostname , realAddrRaw , addr , latestMatchVersion , err ),
599
+ Detail : fmt .Sprintf ("Module registry %s returned invalid source location %q for %s %s: %s." , hostname , realAddrRaw , addr , latestMatch , err ),
654
600
})
655
601
return nil , nil , diags
656
602
}
@@ -665,15 +611,15 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
665
611
diags = diags .Append (& hcl.Diagnostic {
666
612
Severity : hcl .DiagError ,
667
613
Summary : "Invalid package location from module registry" ,
668
- Detail : fmt .Sprintf ("Module registry %s returned invalid source location %q for %s %s: must be a direct remote package address." , hostname , realAddrRaw , addr , latestMatchVersion ),
614
+ Detail : fmt .Sprintf ("Module registry %s returned invalid source location %q for %s %s: must be a direct remote package address." , hostname , realAddrRaw , addr , latestMatch ),
669
615
})
670
616
return nil , nil , diags
671
617
}
672
618
}
673
619
674
620
dlAddr := i .registryPackageSources [moduleAddr ]
675
621
676
- log .Printf ("[TRACE] ModuleInstaller: %s %s %s is available at %q" , key , packageAddr , latestMatchVersion , dlAddr .Package )
622
+ log .Printf ("[TRACE] ModuleInstaller: %s %s %s is available at %q" , key , packageAddr , latestMatch , dlAddr .Package )
677
623
678
624
err := fetcher .FetchPackage (ctx , instPath , dlAddr .Package .String ())
679
625
if errors .Is (err , context .Canceled ) {
@@ -735,14 +681,14 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
735
681
// Note the local location in our manifest.
736
682
manifest [key ] = modsdir.Record {
737
683
Key : key ,
738
- Version : latestMatchVersion ,
684
+ Version : latestMatch ,
739
685
Dir : modDir ,
740
686
SourceAddr : req .SourceAddr .String (),
741
687
}
742
688
log .Printf ("[DEBUG] Module installer: %s installed at %s" , key , modDir )
743
- hooks .Install (key , latestMatchVersion , modDir )
689
+ hooks .Install (key , latestMatch , modDir )
744
690
745
- return mod , latestMatchVersion , diags
691
+ return mod , latestMatch , diags
746
692
}
747
693
748
694
func (i * ModuleInstaller ) installGoGetterModule (ctx context.Context , req * configs.ModuleRequest , key string , instPath string , manifest modsdir.Manifest , hooks ModuleInstallHooks , fetcher * getmodules.PackageFetcher ) (* configs.Module , hcl.Diagnostics ) {
@@ -990,27 +936,3 @@ func splitAddrSubdir(addr addrs.ModuleSource) (string, string) {
990
936
return addr .String (), ""
991
937
}
992
938
}
993
-
994
- func buildModuleVersionDeprecationWarning (modVersion * response.ModuleVersion , req * configs.ModuleRequest , packageAddr string ) * hcl.Diagnostic {
995
- var additionalInfo []string
996
- if modVersion .Deprecation .Reason != "" {
997
- additionalInfo = append (additionalInfo , modVersion .Deprecation .Reason )
998
- }
999
- if modVersion .Deprecation .Link != "" {
1000
- additionalInfo = append (additionalInfo , fmt .Sprintf ("More information: %s" , modVersion .Deprecation .Link ))
1001
- }
1002
- detail := strings .Join (additionalInfo , "\n \n " )
1003
- return & hcl.Diagnostic {
1004
- Severity : hcl .DiagWarning ,
1005
- Summary : fmt .Sprintf ("Module version %s of %s is deprecated" , modVersion .Version , packageAddr ),
1006
- Detail : detail ,
1007
- Subject : req .CallRange .Ptr (),
1008
- Extra : & ModuleVersionDeprecationDiagnosticExtra {
1009
- Type : TypeModuleVersionDeprecation ,
1010
- Version : modVersion .Version ,
1011
- SourceAddr : packageAddr ,
1012
- DeprecationMessage : modVersion .Deprecation .Reason ,
1013
- Link : modVersion .Deprecation .Link ,
1014
- },
1015
- }
1016
- }
0 commit comments