Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image labels to .ko.yaml config #825

Closed
ericsmalling opened this issue Sep 23, 2022 · 9 comments
Closed

Add image labels to .ko.yaml config #825

ericsmalling opened this issue Sep 23, 2022 · 9 comments

Comments

@ericsmalling
Copy link

ericsmalling commented Sep 23, 2022

I would like to be able to configure image labels/annotations from the the .ko.yaml file so that oranizations with standardized label requirements can specify them there instead of only via the CLI --image-label flag.

Additionally, the values for these labels should be able to be interpolated/expanded at run time via environment variables.

Example config:

...
image-labels:
  - org: mycorp-devrel
  - ci-build: {{ Env.GITHUB_SERVER_URL }}/{{ Env.GITHUB_REPOSITORY }}/actions/runs/{{ Env.GITHUB_RUN_ID }}
@ericsmalling
Copy link
Author

I'm going to start hacking on a solution for this but am a novice Go coder so be kind in code reviews, plz! :)

@ericsmalling
Copy link
Author

updated description to use go template for Env var expansion since I see we already have that for other configs

@halvards
Copy link
Collaborator

If you'd like to use Skaffold to build your ko images, env var support in image labels is already available: https://skaffold.dev/docs/pipeline-stages/builders/ko/#image-labels

@developer-guy
Copy link
Collaborator

Are you still interested in working on this @ericsmalling? Maybe I can take care of this one if you don't have enough time to look at it.

@ericsmalling
Copy link
Author

I am, but my schedule this week is slammed. If you have time for it, go right ahead, otherwise I'll pick it up when I can.

dio added a commit to dio/ko that referenced this issue Nov 18, 2022
@dio
Copy link

dio commented Nov 18, 2022

@ericsmalling I think https://github.com/ko-build/ko/compare/main...dio:ko:labels?expand=1 will work.

I have a question: Do you think we need to allow to set labels for each build in builds?

@dio
Copy link

dio commented Nov 22, 2022

I have a use case for setting image-related information and putting that somehow as a map to a binary (package) build.

For example, I have the following structure:

.
├── proj1
│   ├── .ko.yaml
│   ├── Labels.mk
│   ├── Makefile
│   └── cmd
│       └── a
└── proj2
    ├── .ko.yaml
    ├── Labels.mk
    ├── Makefile
    └── cmd
        ├── a
        └── b

So for example, between proj2/cmd/a proj2/cmd/b we need different labels (for name, summary, description, etc as required by https://github.com/redhat-openshift-ecosystem/openshift-preflight). Currently, we manage that separately (inside a .mk that can be included in the corresponding Makefile), not in the .ko.yaml. Do you think we can extend .ko.yaml to accommodate this, by doing one of the following?

  1. Add an images field, each of its entries that map with each entry in builds.
  2. Extends build to allow image-related information.

For 1,

builds:
  id: a

images:
  id: a
  labels:
    - name: ok
    - release: v{{ .Env.Tag }}

or for 2,

builds:
  id: a
  image:
    labels:
      - name: ok
      - release: v{{ .Env.Tag }}

@ericsmalling @imjasonh do you think this makes sense?

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2023
@jtcarnes
Copy link

any movement/idea on the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants