Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Switch from containers/image to go-containerregistry #229

Merged
merged 1 commit into from
May 14, 2018

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Apr 27, 2018

This removes the dependency on containers/image in favor of our new go-containerregistry library.

Filesystem diffs are now done by extracting the flattened fs from the image.

Caching has been temporarily removed while I design a new solution, since the layer caching will no longer work. We can probably just naively cache the fs tarball for now.

The RPM differ needed to be rewritten to load the image into the docker daemon before running commands in a container. google/go-containerregistry#114 needs to be merged before this will compile, but should work correctly once we update the deps to pick up that commit.

@nkubala nkubala requested a review from dlorenc April 27, 2018 21:40
@vrothberg
Copy link
Contributor

@nkubala Out of curiosity: What was the reasoning behind writing the go-containerregistry library? I am asking as I consider the containers/* libraries to be quite feature rich and upstream is nice to work with.

@nkubala nkubala force-pushed the registry branch 3 times, most recently from f02546a to 09fa779 Compare May 10, 2018 00:39
@nkubala
Copy link
Contributor Author

nkubala commented May 10, 2018

@vrothberg Google has had https://github.com/google/containerregistry, a registry library written in Python, for over a year now. Since most of our tools that we're working on these days are written in Go, we decided to port the library over. containers/image is definitely nice, but maintaining our own library gives us more flexibility and control over design decisions.

@nkubala nkubala force-pushed the registry branch 3 times, most recently from ae34bcf to 41df6b0 Compare May 10, 2018 21:37
cmd/root.go Outdated
}, nil
func getImageForName(imageName string) (pkgutil.Image, error) {
if !pkgutil.IsTar(imageName) && !pkgutil.HasTag(imageName) {
imageName = imageName + pkgutil.LatestTag
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you have to add latest? WeakValidation should add that below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah you're right, removed

cmd/root.go Outdated
if err != nil {
return pkgutil.Image{}, err
}
// logrus.Infof("retrieving remote image: %v", ref)
Copy link
Contributor

Choose a reason for hiding this comment

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

uncomment?

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

}
c := configFile.Config
return []string{
fmt.Sprintf("Hostname: %s", c.Hostname),
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these need newlines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they don't, this is a list of strings that gets thrown into a generic result struct and outputted separately

fmt.Sprintf("ArgsEscaped: %t", c.ArgsEscaped),
fmt.Sprintf("Image: %s", c.Image),
fmt.Sprintf("Volumes: %v", pkgutil.SortMap(c.Volumes)),
// fmt.Sprintf("Workdir: %s", c.Workdir),
Copy link
Contributor

Choose a reason for hiding this comment

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

uncomment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeah thanks, fixed workdir and removed stoptimeout since it's not part of the returned config

@mattmoor
Copy link

@nkubala nit: We've had it for about 4 years, but most of that internally :)

dlorenc
dlorenc previously approved these changes May 14, 2018
@nkubala nkubala merged commit e4a55a7 into GoogleContainerTools:master May 14, 2018
@nkubala nkubala deleted the registry branch May 14, 2018 17:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants