Skip to content

[cmd/mdatagen] Imports in generated files should match linting requirements #14306

@crobert-1

Description

@crobert-1

Component(s)

cmd/mdatagen

Describe the issue you're reporting

I'm filing this issue as a result of open-telemetry/opentelemetry-collector-contrib#45013

Currently, after generating files using mdatagen, the generated go code must be formatted and the import order must be overwritten (in contrib this means running make generate, make fmt, and make gci.) This solution works, but it means users may forget to run the formatting and gci commands, resulting in improperly formatted go code, or more steps to getting CI/CD green on a PR.

That being said, to handle this in mdatagen could make import logic considerably more complicated, since all imports would need to be known, and blank lines could only be added if a block has imports, etc. I'll defer to code owners to decide if this enhancement is worth the effort, or if we should stick with requiring make fmt and make gci to be run every time after mdatagen.

An alternative solution may just be to somehow built in the make fmt and make gci calls to the mdatagen functionality, but that may also just be another level of complexity.

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions