-
Notifications
You must be signed in to change notification settings - Fork 237
Add a "MutableSource" type that allows for basic image modifications. #180
Conversation
pkg/image/mutable_source.go
Outdated
} | ||
|
||
// GetManifest marshals the stored manifest to the byte format. | ||
func (m *MutableSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is instanceDigest
being used for anything? if not can you remove it as a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed to implement the interface now... I think it's only real purpose is multi-image images, a.k.a manifest lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add it as a GetManifest(_ *digest.Digest) if its not used
pkg/image/mutable_source.go
Outdated
|
||
// Also add it to the config. | ||
b := bytes.NewReader(content) | ||
gz, err := gzip.NewReader(b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this always guaranteed to be gzipped? is it possible some other compression was used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's always gzipped. I think I want to enforce that though with some checks, or possibly take the uncompressed layer instead and do the gzip ourselves, for performance.
pkg/image/mutable_source.go
Outdated
m.cfg.RootFS.DiffIDs = append(m.cfg.RootFS.DiffIDs, diffID) | ||
history := manifest.Schema2History{ | ||
Created: time.Now(), | ||
Author: "dlorenc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably want a different placeholder author and comment here :)
cc @nkubala this should be ready for review, I had to fix the cache to make it idempotent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the test 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment about embedding the types in ProxySource
pkg/image/mutable_source.go
Outdated
} | ||
|
||
// GetManifest marshals the stored manifest to the byte format. | ||
func (m *MutableSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add it as a GetManifest(_ *digest.Digest) if its not used
|
||
// ProxySource is a type that implements types.ImageSource by proxying all calls to an underlying implementation. | ||
type ProxySource struct { | ||
Ref types.ImageReference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could consider embedding these three types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Left the one un-embedded.
pkg/image/proxy_types.go
Outdated
} | ||
|
||
// GetSignatures returns the image's signatures. It may use a remote (= slow) service. | ||
func (p *ProxySource) GetSignatures(ctx context.Context, d *digest.Digest) ([][]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you embed, you can get rid of all the functions you aren't overriding
OK, this should be RFAL. |
This also introduces a "ProxySource" type, which allows for easier customization.
The main logic in "MutableSource" is in the bookkeeping of changes to the image config and manifest.