@@ -84,7 +84,7 @@ func (check *FileMismatchCheck) Run() error {
84
84
return result
85
85
}
86
86
87
- // ResourceFileMismatchCheck checks for mismatched files, either missing or extraneous, against the resource/datasouce schema
87
+ // ResourceFileMismatchCheck checks for mismatched files, either missing or extraneous, against the resource/datasource schema
88
88
func (check * FileMismatchCheck ) ResourceFileMismatchCheck (files []os.DirEntry , resourceType string , schemas map [string ]* tfjson.Schema ) error {
89
89
if len (files ) == 0 {
90
90
log .Printf ("[DEBUG] Skipping %s file mismatch checks due to missing file list" , resourceType )
@@ -200,7 +200,11 @@ func (check *FileMismatchCheck) FunctionFileMismatchCheck(files []os.DirEntry, f
200
200
201
201
func (check * FileMismatchCheck ) IgnoreFileMismatch (file string ) bool {
202
202
for _ , ignoreResourceName := range check .Options .IgnoreFileMismatch {
203
- if ignoreResourceName == fileResourceName (check .Options .ProviderShortName , file ) {
203
+ if ignoreResourceName == fileResourceNameWithProvider (check .Options .ProviderShortName , file ) {
204
+ return true
205
+ } else if ignoreResourceName == TrimFileExtension (file ) {
206
+ // While uncommon, it is valid for a resource type to be named the same as the provider itself.
207
+ // https://github.com/hashicorp/terraform-plugin-docs/issues/419
204
208
return true
205
209
}
206
210
}
@@ -219,7 +223,13 @@ func (check *FileMismatchCheck) IgnoreFileMissing(resourceName string) bool {
219
223
}
220
224
221
225
func fileHasResource (schemaResources map [string ]* tfjson.Schema , providerName , file string ) bool {
222
- if _ , ok := schemaResources [fileResourceName (providerName , file )]; ok {
226
+ if _ , ok := schemaResources [fileResourceNameWithProvider (providerName , file )]; ok {
227
+ return true
228
+ }
229
+
230
+ // While uncommon, it is valid for a resource type to be named the same as the provider itself.
231
+ // https://github.com/hashicorp/terraform-plugin-docs/issues/419
232
+ if _ , ok := schemaResources [TrimFileExtension (file )]; ok {
223
233
return true
224
234
}
225
235
@@ -234,7 +244,7 @@ func fileHasFunction(functions map[string]*tfjson.FunctionSignature, file string
234
244
return false
235
245
}
236
246
237
- func fileResourceName (providerName , fileName string ) string {
247
+ func fileResourceNameWithProvider (providerName , fileName string ) string {
238
248
resourceSuffix := TrimFileExtension (fileName )
239
249
240
250
return fmt .Sprintf ("%s_%s" , providerName , resourceSuffix )
@@ -244,7 +254,12 @@ func resourceHasFile(files []os.DirEntry, providerName, resourceName string) boo
244
254
var found bool
245
255
246
256
for _ , file := range files {
247
- if fileResourceName (providerName , file .Name ()) == resourceName {
257
+ if fileResourceNameWithProvider (providerName , file .Name ()) == resourceName {
258
+ found = true
259
+ break
260
+ } else if TrimFileExtension (file .Name ()) == resourceName {
261
+ // While uncommon, it is valid for a resource type to be named the same as the provider itself.
262
+ // https://github.com/hashicorp/terraform-plugin-docs/issues/419
248
263
found = true
249
264
break
250
265
}
0 commit comments