AZS005

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

README

AZS005

The AZS005 analyzer reports registered resources that have no data source of the same terraform type name registered in the service package. Every registration flavour contributes to both sides of the comparison, so a resource registered one way is covered by a data source registered any other way:

  • untyped plugin SDK: SupportedResources() / SupportedDataSources() map keys
  • typed SDK: Resources() / DataSources() elements, correlated via their ResourceType() methods
  • framework: FrameworkResources() / FrameworkDataSources() elements, correlated via their ResourceType() methods

Conditionally registered entries (resources["azurerm_x"] = ... assignments and append(out, FooResource{}) calls behind feature flags) are collected too, and generated auto-registration delegation (append(out, r.autoRegistration.Resources()...)) is followed — the delegated-to methods' own literal entries are collected when their declarations are visited. Type names declared as package-level vars (var FooResourceName = "azurerm_foo", common for sharing with locks helpers) resolve through their initializer. Invoke-style "action" resources — ones that perform an operation or mint a credential rather than manage a durable object, currently recognised by the name suffixes _run_command and _sas_token — have no meaningful data source form and are never reported. Registration methods are recognised by name plus return shape (map[string]*Resource, []Resource, []DataSource, []FrameworkWrappedResource, []FrameworkWrappedDataSource), and terraform type names are resolved through the type checker, so named constants work. If any data source entry's name cannot be resolved statically the package is skipped entirely, so an unresolvable data source can never produce a false "missing data source" report; unresolvable resource entries are skipped individually.

Flagged Code

func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
	return map[string]*pluginsdk.Resource{
		"azurerm_example": resourceExample(), // no data source named azurerm_example registered
	}
}

Passing Code

func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
	return map[string]*pluginsdk.Resource{
		"azurerm_example": resourceExample(),
	}
}

func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource {
	return map[string]*pluginsdk.Resource{
		"azurerm_example": dataSourceExample(),
	}
}

Ignoring Reports

Not every resource needs a data source, so suppressions are expected — the check exists to make the gap a deliberate decision rather than an accident. When run via golangci-lint, reports can be ignored with a //nolint:azproviderlint Go code comment at the end of the offending line or on the line immediately preceding it:

"azurerm_example": resourceExample(), //nolint:azproviderlint

To ignore only this check on a line — leaving any other azproviderlint checks active — use a //azignore:AZS005 - <reason> comment instead, in the same positions:

"azurerm_example": resourceExample(), //azignore:AZS005 - <reason>

Documentation

Overview

Package AZS005 defines an analyzer that reports registered resources that have no corresponding data source of the same name, across every registration flavour: untyped plugin SDK maps, typed sdk.Resource slices and framework wrapped resource slices.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "AZS005",
	Doc:      "check for registered resources that have no corresponding data source",
	URL:      "https://github.com/katbyte/azproviderlint/blob/main/checks/AZS/AZS005_resource_missing_data_source/README.md",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

Analyzer correlates a service package's registered resources and data sources by their terraform type name and reports every resource without a matching data source. All registration flavours contribute to both sides:

  • untyped plugin SDK: `SupportedResources()` / `SupportedDataSources()` map keys
  • typed SDK: `Resources()` / `DataSources()` elements' `ResourceType()` methods
  • framework: `FrameworkResources()` / `FrameworkDataSources()` elements' `ResourceType()` methods

Conditionally registered entries (`m["azurerm_x"] = ...`, `append(out, Foo{})` behind feature flags) are collected too. If any data source entry's name cannot be resolved the package is skipped entirely, so an unresolvable data source can never produce a false "missing data source" report.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL