Skip to content

feat: Add global ldflags #1304

@nmittler

Description

@nmittler

When creating images for multiple builds (e.g. in a monorepo), the ldflags would have to be duplicated in each build in .ko.yaml. This creates a lot of boilerplate and potential for inconsistencies, etc.

Instead, a better experience would be to allow a global set of ldflags that will automatically be applied to each build as their generated. Additionally, they can have all the same template parameters that you would have under the build section, since they will be re-evaluated for each build.

There is one choice to make that comes to mind, however:

  • defaultLDFlags: This naming would be in keeping with some other values, like defaultBaseImage. In this case, they would be a default that would simply be replaced if ldflags were specified for a particular binary.
  • ldflags: In this case, they're simply globally ldfags that would always be prepended to any per-build ldflags.

I think I'm fine either way. Happy to discuss.

Also, I'm happy to do the work and send a PR if folks think this is a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions