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

Provide project source metadata from local git information #1137

Closed
jromero opened this issue Apr 20, 2021 · 1 comment · Fixed by #1444
Closed

Provide project source metadata from local git information #1137

jromero opened this issue Apr 20, 2021 · 1 comment · Fixed by #1444
Labels
epic/source-metadata Issues/PRs related to providing source metadata status/ready Issue ready to be worked on. type/enhancement Issue that requests a new feature or improvement.

Comments

@jromero
Copy link
Member

jromero commented Apr 20, 2021

Description

As a buildpacks user, I'd like to have the source and version information of my project embedded as metadata in the final app image.

Proposed solution

Based on the spec, we should be able to provide <layers>/project-metadata.toml in this format which would be translated into the io.buildpacks.project.metadata label on the image.

This issue should be scoped to local git information.

Acceptance Criteria

General case
Given I clone a project from git@github.com:buildpacks/pack.git
And `git rev-parse HEAD` returns "8348484564e6aa0699de0ee78c258e88240eb0b5"
And `git describe --tags --always` returns "v0.18.1-2-g83484845"
And `git branch --show-current` returns "main"
And `git remote -v | grep "fetch"` returns:
    "origin	git@github.com:buildpacks/pack.git (fetch)"
And I run `pack build my-app`
When I run the following command `docker inspect my-app | jq -r '.[0].Config.Labels["io.buildpacks.project.metadata"] | fromjson'`
Then I should see:
{
  "type": "git",
  "version": { "commit": "8348484564e6aa0699de0ee78c258e88240eb0b5", "describe": "v0.18.1-2-g83484845"},
  "metadata": {
    "refs": ["main"],
    "url": "git@github.com:buildpacks/pack.git"
  }
}
At a tag(s)
Given I clone a project from git@github.com:buildpacks/pack.git
And `git rev-parse HEAD` returns "8348484564e6aa0699de0ee78c258e88240eb0b5"
And `git describe --tags --always` returns "v0.18.1"
And `git branch --show-current` returns "main"
And `git tag --points-at HEAD` returns:
  v0.18.1
  v0.18.1-rc2
And `git remote -v | grep "fetch"` returns:
    "origin	git@github.com:buildpacks/pack.git (fetch)"
And I run `pack build my-app`
When I run the following command `docker inspect my-app | jq -r '.[0].Config.Labels["io.buildpacks.project.metadata"] | fromjson'`
Then I should see:
{
  "type": "git",
  "version": { "commit": "8348484564e6aa0699de0ee78c258e88240eb0b5", "describe": "v0.18.1"},
  "metadata": {
    "refs": ["main", "v0.18.1", "v0.18.1-rc2"],
    "url": "git@github.com:buildpacks/pack.git"
  }
}

Additional context

This issue is part of an epic of work. The related issues may be see by filtering on epic/source-metadata.

@jromero jromero added type/enhancement Issue that requests a new feature or improvement. status/triage Issue or PR that requires contributor attention. status/ready Issue ready to be worked on. epic/source-metadata Issues/PRs related to providing source metadata and removed status/triage Issue or PR that requires contributor attention. labels Apr 20, 2021
@jromero jromero changed the title Provide project source metadata to lifecycle from local git information Provide project source metadata from local git information Apr 20, 2021
@Haimantika Haimantika mentioned this issue Aug 25, 2021
2 tasks
@imnitishng
Copy link
Contributor

I see this is listed in the next milestone, and has already been worked on by someone else. I'd be happy to finish this 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic/source-metadata Issues/PRs related to providing source metadata status/ready Issue ready to be worked on. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
2 participants