|
|
@@ -9,6 +9,8 @@ import (
|
|
|
"github.com/fatih/color"
|
|
|
"github.com/google/go-containerregistry/pkg/authn"
|
|
|
"github.com/google/go-containerregistry/pkg/name"
|
|
|
+ "github.com/google/go-containerregistry/pkg/v1"
|
|
|
+ "github.com/google/go-containerregistry/pkg/v1/partial"
|
|
|
"github.com/google/go-containerregistry/pkg/v1/remote"
|
|
|
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
|
|
"github.com/sirupsen/logrus"
|
|
|
@@ -26,6 +28,21 @@ type OutResponse struct {
|
|
|
Metadata []resource.MetadataField `json:"metadata"`
|
|
|
}
|
|
|
|
|
|
+type imageWithConfigAsLayer struct {
|
|
|
+ v1.Image
|
|
|
+}
|
|
|
+
|
|
|
+func (i imageWithConfigAsLayer) LayerByDigest(h v1.Hash) (v1.Layer, error) {
|
|
|
+ // Support returning the ConfigFile when asked for its hash.
|
|
|
+ if cfgName, err := i.ConfigName(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else if cfgName == h {
|
|
|
+ return partial.ConfigLayer(i)
|
|
|
+ }
|
|
|
+
|
|
|
+ return i.Image.LayerByDigest(h)
|
|
|
+}
|
|
|
+
|
|
|
func main() {
|
|
|
logrus.SetOutput(os.Stderr)
|
|
|
logrus.SetFormatter(&logrus.TextFormatter{
|
|
|
@@ -76,6 +93,10 @@ func main() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ img = imageWithConfigAsLayer{
|
|
|
+ Image: img,
|
|
|
+ }
|
|
|
+
|
|
|
auth := &authn.Basic{
|
|
|
Username: req.Source.Username,
|
|
|
Password: req.Source.Password,
|