Skip to content

Support configurable location for main.go via --main-file flag #4984

@afritzler

Description

@afritzler

What do you want to happen?

Currently, kubebuilder scaffolding expects the manager’s main.go to be located at the root of the cmd directory (cmd/main.go). This assumption limits flexibility when structuring projects according to standard Go project layouts.

For example, if I want to add additional commands (e.g., CLI tooling), I would like to place them in their own subdirectories under cmd/, such as:

cmd/
  manager/
    main.go
  foocli/
    main.go

To support this structure, I propose adding a --main-file flag (e.g., --main-file=cmd/manager/main.go) to allow the main manager entry point to be specified explicitly during scaffolding or plugin operations.

Additionally, this path could be recorded in the PROJECT config file to persist the custom layout and support tooling/codegen accordingly.

Would the maintainers be open to a PR adding this feature?

Extra Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions