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

Layout omit image.ref.name annotation #870

Closed
wants to merge 1 commit into from

Conversation

Dentrax
Copy link

@Dentrax Dentrax commented Oct 26, 2022

Fixes #869

Signed-off-by: Furkan [email protected]
Co-authored-by: Batuhan [email protected]

cc @developer-guy

  • tests a bit missing, we will add some assertions to check if all annotations are valid and correct. (if overall idea is OK)

DEMO

$ KO_DOCKER_REPO="foo" LDFLAGS="-s" go run . build -t foo,bar,baz --push=false --oci-layout-path test .

$ cat test/index.json | jq
{
  "schemaVersion": 2,
  "manifests": [
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 1943,
      "digest": "sha256:99a7a7bf1ad3fde0107b1f5909bb9a1df037f8be8b73e73d1779a0fd473cf1ed",
      "annotations": {
        "org.opencontainers.image.ref.name": "foo"
      }
    },
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 1943,
      "digest": "sha256:99a7a7bf1ad3fde0107b1f5909bb9a1df037f8be8b73e73d1779a0fd473cf1ed",
      "annotations": {
        "org.opencontainers.image.ref.name": "bar"
      }
    },
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 1943,
      "digest": "sha256:99a7a7bf1ad3fde0107b1f5909bb9a1df037f8be8b73e73d1779a0fd473cf1ed",
      "annotations": {
        "org.opencontainers.image.ref.name": "baz"
      }
    }
  ]
}

@google-cla
Copy link

google-cla bot commented Oct 26, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@developer-guy
Copy link
Collaborator

also ccing @imjasonh @jonjohnsonjr 🙈

@codecov-commenter
Copy link

codecov-commenter commented Oct 26, 2022

Codecov Report

Merging #870 (2cec78b) into main (86b6c28) will decrease coverage by 0.06%.
The diff coverage is 45.83%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main     #870      +/-   ##
==========================================
- Coverage   52.42%   52.36%   -0.06%     
==========================================
  Files          43       43              
  Lines        3325     3344      +19     
==========================================
+ Hits         1743     1751       +8     
- Misses       1353     1363      +10     
- Partials      229      230       +1     
Impacted Files Coverage Δ
pkg/commands/resolver.go 36.55% <0.00%> (ø)
pkg/publish/layout.go 43.07% <47.82%> (-0.41%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Dentrax
Copy link
Author

Dentrax commented Oct 31, 2022

/check-cla

@developer-guy
Copy link
Collaborator

kindly ping @imjasonh ☝️

Copy link
Member

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thanks for doing this, and sorry as always for the delay.

{
name: "no tags",
tags: nil,
want: nil,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want is nil in all of these cases. If none of these cases test the error scenario we can just remove want from the struct here.

}

// NewLayout returns a new publish.Interface that saves images to an OCI Image Layout.
func NewLayout(path string) (Interface, error) {
func NewLayout(path string, tags []string) (Interface, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this changes the method signature, and will break anyone that uses this as a library. I don't think this is a blocker, but if we expect that to be something people do more in the future we should be more careful.

Not a blocker this time though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change it as a variadic function, this does not affect people who might be using the ko project as a library.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be good now

if err != nil {
t.Fatalf("random.Image() = %v", err)
}
importpath := "github.com/Google/go-containerregistry/cmd/crane"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have to be a real importpath, right? Could we make it something more obviously a placeholder, to avoid confusion? Something like github.com/example/importpath?

@developer-guy
Copy link
Collaborator

kindly ping @Dentrax, we should fix the tests 🙈

@developer-guy
Copy link
Collaborator

kindly ping @imjasonh 🙈

@developer-guy
Copy link
Collaborator

kindly ping @imjasonh 🕺🏻

imjasonh
imjasonh previously approved these changes Nov 30, 2022
@imjasonh
Copy link
Member

@jonjohnsonjr any concerns?

p, err := layout.FromPath(path)
if err != nil {
p, err = layout.Write(path, empty.Index)
if err != nil {
return nil, err
}
}
return &LayoutPublisher{p}, nil
if len(tags) == 0 {
tags = []string{"latest"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop this so it's possible to use this without adding tags?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dentrax are you still interested in working on this?

@github-actions
Copy link

github-actions bot commented Mar 1, 2023

This Pull Request 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.

Fixes ko-build#869

Signed-off-by: Furkan <[email protected]>
Co-authored-by: Batuhan <[email protected]>
Signed-off-by: Batuhan Apaydın <[email protected]>
@developer-guy
Copy link
Collaborator

kindly ping @jonjohnsonjr @imjasonh, it seems that everything is working fine.

@developer-guy
Copy link
Collaborator

kindly ping @Dentrax

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

This Pull Request 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.

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

Successfully merging this pull request may close these issues.

associate oci-image-layout directory with the tag of an image
5 participants