@@ -11,49 +11,49 @@ import (
11
11
"github.com/mitchellh/colorstring"
12
12
)
13
13
14
- type WorkspaceDeprecationInfo struct {
15
- ModuleDeprecationInfos []* ModuleDeprecationInfo
14
+ type DirectoryDeprecationInfo struct {
15
+ ModuleVersionDeprecationInfos []* ModuleVersionDeprecationInfo
16
16
}
17
17
18
- type ModuleDeprecationInfo struct {
18
+ type ModuleVersionDeprecationInfo struct {
19
19
SourceName string
20
- RegistryDeprecation * RegistryModuleDeprecation
21
- ExternalDependencies []* ModuleDeprecationInfo
20
+ RegistryDeprecation * RegistryModuleVersionDeprecation
21
+ ExternalDependencies []* ModuleVersionDeprecationInfo
22
22
}
23
23
24
- type RegistryModuleDeprecation struct {
24
+ type RegistryModuleVersionDeprecation struct {
25
25
Version string
26
26
Link string
27
27
Message string
28
28
}
29
29
30
- type ModuleDeprecationDiagnosticExtra struct {
31
- MessageCode string `json:"message_code"`
32
- Deprecations []* ModuleDeprecationDiagnosticExtraDeprecationItem `json:"deprecations"`
30
+ type ModuleVersionDeprecationDiagnosticExtra struct {
31
+ MessageCode string `json:"message_code"`
32
+ Deprecations []* ModuleVersionDeprecationDiagnosticExtraDeprecationItem `json:"deprecations"`
33
33
}
34
34
35
- func (m * ModuleDeprecationDiagnosticExtra ) IsPublic () {}
35
+ func (m * ModuleVersionDeprecationDiagnosticExtra ) IsPublic () {}
36
36
37
- type ModuleDeprecationDiagnosticExtraDeprecationItem struct {
37
+ type ModuleVersionDeprecationDiagnosticExtraDeprecationItem struct {
38
38
Version string `json:"version"`
39
39
SourceName string `json:"source_name"`
40
40
DeprecationMessage string `json:"deprecation_message"`
41
41
Link string `json:"link"`
42
42
}
43
43
44
- func (i * WorkspaceDeprecationInfo ) HasDeprecations () bool {
45
- if i == nil || i .ModuleDeprecationInfos == nil {
44
+ func (i * DirectoryDeprecationInfo ) HasDeprecations () bool {
45
+ if i == nil || i .ModuleVersionDeprecationInfos == nil {
46
46
return false
47
47
}
48
- for _ , deprecationInfo := range i .ModuleDeprecationInfos {
48
+ for _ , deprecationInfo := range i .ModuleVersionDeprecationInfos {
49
49
if deprecationInfo != nil && deprecationInfo .hasDeprecations () {
50
50
return true
51
51
}
52
52
}
53
53
return false
54
54
}
55
55
56
- func (i * ModuleDeprecationInfo ) hasDeprecations () bool {
56
+ func (i * ModuleVersionDeprecationInfo ) hasDeprecations () bool {
57
57
if i .RegistryDeprecation != nil {
58
58
return true
59
59
}
@@ -67,15 +67,15 @@ func (i *ModuleDeprecationInfo) hasDeprecations() bool {
67
67
68
68
// Deprecation info is placed as an string in the Diagnostic Detail for console view,
69
69
// as well as placed in the Diagnostic Extra for parsing for the SRO view in HCP Terraform
70
- func (i * WorkspaceDeprecationInfo ) BuildDeprecationWarning () * hcl.Diagnostic {
71
- modDeprecationStrings := []string {}
70
+ func (i * DirectoryDeprecationInfo ) BuildDeprecationWarning () * hcl.Diagnostic {
71
+ modDeprecations := []string {}
72
72
color := colorstring.Colorize {
73
73
Colors : colorstring .DefaultColors ,
74
74
Disable : false ,
75
75
Reset : true ,
76
76
}
77
- deprecationList := make ([]* ModuleDeprecationDiagnosticExtraDeprecationItem , 0 , len (i .ModuleDeprecationInfos ))
78
- for _ , modDeprecationInfo := range i .ModuleDeprecationInfos {
77
+ deprecationList := make ([]* ModuleVersionDeprecationDiagnosticExtraDeprecationItem , 0 , len (i .ModuleVersionDeprecationInfos ))
78
+ for _ , modDeprecationInfo := range i .ModuleVersionDeprecationInfos {
79
79
if modDeprecationInfo != nil && modDeprecationInfo .RegistryDeprecation != nil {
80
80
msg := color .Color ("[reset][bold]Version %s of %s[reset]" )
81
81
modDeprecation := fmt .Sprintf (msg , modDeprecationInfo .RegistryDeprecation .Version , modDeprecationInfo .SourceName )
@@ -86,39 +86,39 @@ func (i *WorkspaceDeprecationInfo) BuildDeprecationWarning() *hcl.Diagnostic {
86
86
if modDeprecationInfo .RegistryDeprecation .Link != "" {
87
87
modDeprecation = modDeprecation + fmt .Sprintf ("\n \n Link for more information: %s" , modDeprecationInfo .RegistryDeprecation .Link )
88
88
}
89
- deprecationList = append (deprecationList , & ModuleDeprecationDiagnosticExtraDeprecationItem {
89
+ deprecationList = append (deprecationList , & ModuleVersionDeprecationDiagnosticExtraDeprecationItem {
90
90
Version : modDeprecationInfo .RegistryDeprecation .Version ,
91
91
SourceName : modDeprecationInfo .SourceName ,
92
92
DeprecationMessage : modDeprecationInfo .RegistryDeprecation .Message ,
93
93
Link : modDeprecationInfo .RegistryDeprecation .Link ,
94
94
})
95
- modDeprecationStrings = append (modDeprecationStrings , modDeprecation )
95
+ modDeprecations = append (modDeprecations , modDeprecation )
96
96
}
97
97
deprecationStrings , deprecationStructs := buildChildModuleDeprecations (modDeprecationInfo .ExternalDependencies , []string {modDeprecationInfo .SourceName })
98
98
deprecationList = append (deprecationList , deprecationStructs ... )
99
- modDeprecationStrings = append (modDeprecationStrings , deprecationStrings ... )
99
+ modDeprecations = append (modDeprecations , deprecationStrings ... )
100
100
}
101
- deprecationsMessage := strings .Join (modDeprecationStrings , "\n \n " )
101
+ deprecationsMessage := strings .Join (modDeprecations , "\n \n " )
102
102
103
103
return & hcl.Diagnostic {
104
104
Severity : hcl .DiagWarning ,
105
105
Summary : "Deprecated modules found, consider installing updated versions. The following are affected:" ,
106
106
Detail : deprecationsMessage ,
107
- Extra : & ModuleDeprecationDiagnosticExtra {
107
+ Extra : & ModuleVersionDeprecationDiagnosticExtra {
108
108
MessageCode : "module_deprecation_warning" ,
109
109
Deprecations : deprecationList ,
110
110
},
111
111
}
112
112
}
113
113
114
- func buildChildModuleDeprecations (modDeprecations []* ModuleDeprecationInfo , parentMods []string ) ([]string , []* ModuleDeprecationDiagnosticExtraDeprecationItem ) {
114
+ func buildChildModuleDeprecations (modDeprecations []* ModuleVersionDeprecationInfo , parentMods []string ) ([]string , []* ModuleVersionDeprecationDiagnosticExtraDeprecationItem ) {
115
115
color := colorstring.Colorize {
116
116
Colors : colorstring .DefaultColors ,
117
117
Disable : false ,
118
118
Reset : true ,
119
119
}
120
120
modDeprecationStrings := []string {}
121
- var deprecationList []* ModuleDeprecationDiagnosticExtraDeprecationItem
121
+ var deprecationList []* ModuleVersionDeprecationDiagnosticExtraDeprecationItem
122
122
for _ , deprecation := range modDeprecations {
123
123
if deprecation .RegistryDeprecation != nil {
124
124
msg := color .Color ("[reset][bold]Version %s of %s %s[reset]" )
@@ -132,7 +132,7 @@ func buildChildModuleDeprecations(modDeprecations []*ModuleDeprecationInfo, pare
132
132
}
133
133
modDeprecationStrings = append (modDeprecationStrings , modDeprecation )
134
134
}
135
- deprecationList = append (deprecationList , & ModuleDeprecationDiagnosticExtraDeprecationItem {
135
+ deprecationList = append (deprecationList , & ModuleVersionDeprecationDiagnosticExtraDeprecationItem {
136
136
Version : deprecation .RegistryDeprecation .Version ,
137
137
SourceName : deprecation .SourceName ,
138
138
DeprecationMessage : deprecation .RegistryDeprecation .Message ,
0 commit comments