Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Redesign OCI image status: Display the image's exact repository digest #307

Merged
merged 6 commits into from
Aug 9, 2019

Conversation

twelho
Copy link
Contributor

@twelho twelho commented Aug 9, 2019

Fixes #298. This PR implements the new OCI image status API representation described in the aforementioned issue complete with parsing and conversion logic.

cc @luxas

@twelho twelho added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/design Categorizes issue or PR as related to the design of the project. kind/enhancement Categorizes issue or PR as related to improving an existing feature. labels Aug 9, 2019
@twelho twelho added this to the v0.5.0 milestone Aug 9, 2019
@twelho twelho changed the title Status redesign OCI image status representation redesign Aug 9, 2019
Copy link
Contributor

@luxas luxas left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM 💯

Just some minor nits/questions

}

// Digest is a getter for the digest field
func (o *OCIContentID) Digest() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

return digest.Digest? I think that would make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in d4495d0 and also for RepoDigest()

@@ -47,3 +45,89 @@ func (i *OCIImageRef) UnmarshalJSON(b []byte) error {
*i, err = NewOCIImageRef(str)
return err
}

func ParseOCIContentID(str string) (*OCIContentID, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a short godoc showing sample valid/invalid strings you can give it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in d4495d0.

return fmt.Sprintf("oci://%s", o.RepoDigest())
}

return fmt.Sprintf("docker://%s", o.Digest())
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe make local constants for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in d4495d0.

}

// Remove the "docker://" or "oci://" scheme by only caring about the host and path
return ParseOCIContentID(u.Host + u.Path)
Copy link
Contributor

Choose a reason for hiding this comment

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

if the input is oci://docker.io/library/node@sha256:abc, is the stuff after @ really preserved? have you tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's preserved. I tested it will multiple combinations: https://play.golang.org/p/KMFTEOUBVh_W

// ID defines the source's ID (e.g. the Docker image ID)
ID string `json:"id"`
// ID defines the source's content ID (e.g. the canonical OCI path or Docker image ID)
ID *meta.OCIContentID `json:"id"`
Copy link
Contributor

Choose a reason for hiding this comment

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

add omitempty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't this pretty much required? I can't think of a situation where only the image/kernel size would be reported.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, true 👍

// ID defines the source's ID (e.g. the Docker image ID)
ID string `json:"id"`
// ID defines the source's content ID (e.g. the canonical OCI path or Docker image ID)
ID *meta.OCIContentID `json:"id"`
Copy link
Contributor

Choose a reason for hiding this comment

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

add omitempty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above, IMO this field is required.

@twelho
Copy link
Contributor Author

twelho commented Aug 9, 2019

Feedback addressed and CI is now green, going ahead and merging

@twelho twelho merged commit 5f9f4fc into weaveworks:master Aug 9, 2019
@twelho twelho deleted the status-redesign branch August 9, 2019 14:46
@luxas luxas removed the kind/enhancement Categorizes issue or PR as related to improving an existing feature. label Aug 12, 2019
@luxas luxas changed the title OCI image status representation redesign Redesign OCI image status: Display the image's exact repository digest Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/design Categorizes issue or PR as related to the design of the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign image and kernel status for VMs
2 participants