Skip to content

Commit

Permalink
Merge pull request #356 from carvel-dev/bump-imgpkg-0.40.0
Browse files Browse the repository at this point in the history
Bumped imgpkg version to v0.40.0 in kbld
  • Loading branch information
sethiyash authored Jan 22, 2024
2 parents 7ce1260 + 39c13f3 commit d1df25f
Show file tree
Hide file tree
Showing 33 changed files with 10,559 additions and 115 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module carvel.dev/vendir
go 1.21

require (
carvel.dev/imgpkg v0.39.0
carvel.dev/imgpkg v0.40.0
github.com/bmatcuk/doublestar v1.2.1
github.com/carvel-dev/semver/v4 v4.0.1-0.20230221220520-8090ce423695
github.com/cppforlife/cobrautil v0.0.0-20221021151949-d60711905d65
Expand All @@ -24,7 +24,7 @@ require (
gopkg.in/inf.v0 v0.9.1
k8s.io/apimachinery v0.24.3
k8s.io/code-generator v0.17.2
sigs.k8s.io/yaml v1.3.0
sigs.k8s.io/yaml v1.4.0
)

require (
Expand Down Expand Up @@ -81,7 +81,7 @@ require (
github.com/kr/pretty v0.2.1 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
carvel.dev/imgpkg v0.39.0 h1:faaWTLGo+CyhryyihSfSQpMoE5eHJDI1eloRbmCy7gM=
carvel.dev/imgpkg v0.39.0/go.mod h1:7aFGpUJsheXAZ8/fXMiMwU4pKXafS/ddLRjTHW9fMx8=
carvel.dev/imgpkg v0.40.0 h1:ZMXhZUnLYUz3mfICYsjxvGNUJh5tWcEpGDd0yGd/epA=
carvel.dev/imgpkg v0.40.0/go.mod h1:XTpFT2AuG2fIsaf2h4bCvmzvi3cs2nnpQng37J+ZYTE=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go/compute v1.19.3 h1:DcTwsFgGev/wV5+q8o2fzgcHOaac+DKGC91ZlvpsQds=
cloud.google.com/go/compute v1.19.3/go.mod h1:qxvISKp/gYnXkSAD1ppcSOveRAmzxicEv/JlizULFrI=
Expand Down Expand Up @@ -244,8 +244,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
Expand Down Expand Up @@ -551,5 +551,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLz
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
9 changes: 9 additions & 0 deletions vendor/carvel.dev/imgpkg/pkg/imgpkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"math/rand"
"net/http"
"os"
"regexp"
Expand Down Expand Up @@ -42,6 +43,8 @@ type Opts struct {

EnvironFunc func() []string
ActiveKeychains []auth.IAASKeychain

SessionID string
}

// DeepCopy the options to a new struct
Expand Down Expand Up @@ -194,6 +197,12 @@ func NewSimpleRegistryWithTransport(opts Opts, rTripper http.RoundTripper) (*Sim
baseRoundTripper = transport.NewLogger(rTripper)
}

sessionID := opts.SessionID
if sessionID == "" {
sessionID = fmt.Sprint(rand.Intn(9999999999))
}
baseRoundTripper = NewImgpkgRoundTripper(baseRoundTripper, sessionID)

// Wrap the transport in something that can retry network flakes.
baseRoundTripper = transport.NewRetry(baseRoundTripper, transport.WithRetryBackoff(retryBackoff))

Expand Down
20 changes: 20 additions & 0 deletions vendor/carvel.dev/imgpkg/pkg/imgpkg/registry/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,23 @@ func (n NoopRoundTripperStorage) CreateRoundTripper(_ regname.Registry, _ authn.
func (n NoopRoundTripperStorage) BaseRoundTripper() http.RoundTripper {
return nil
}

// NewImgpkgRoundTripper creates a RoundTripper that will add headers to the request
func NewImgpkgRoundTripper(parent http.RoundTripper, sessionID string) *ImgpkgRoundTripper {
return &ImgpkgRoundTripper{
parent: parent,
sessionID: sessionID,
}
}

// ImgpkgRoundTripper RoundTripper that adds headers to request
type ImgpkgRoundTripper struct {
parent http.RoundTripper
sessionID string
}

// RoundTrip changes the request to add headers and calls the parent RoundTrip
func (i *ImgpkgRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Add("imgpkg-session-id", i.sessionID)
return i.parent.RoundTrip(req)
}
72 changes: 62 additions & 10 deletions vendor/carvel.dev/imgpkg/pkg/imgpkg/v1/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import (
"carvel.dev/imgpkg/pkg/imgpkg/lockconfig"
"carvel.dev/imgpkg/pkg/imgpkg/registry"
"carvel.dev/imgpkg/pkg/imgpkg/signature"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
regname "github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
)

// Author information from a Bundle
Expand All @@ -33,13 +36,19 @@ type Metadata struct {
Websites []Website `json:"websites,omitempty"`
}

// Layers image layers info
type Layers struct {
Digest string `json:"digest,omitempty"`
}

// ImageInfo URLs where the image can be found as well as annotations provided in the Images Lock
type ImageInfo struct {
Image string `json:"image,omitempty"`
Origin string `json:"origin,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
ImageType bundle.ImageType `json:"imageType"`
Error string `json:"error,omitempty"`
Layers []Layers `json:"layers,omitempty"`
}

// Content Contents present in a Bundle
Expand All @@ -55,6 +64,7 @@ type Description struct {
Annotations map[string]string `json:"annotations,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
Content Content `json:"content"`
Layers []Layers `json:"layers,omitempty"`
}

// DescribeOpts Options used when calling the Describe function
Expand Down Expand Up @@ -106,23 +116,28 @@ func DescribeWithRegistryAndSignatureFetcher(bundleImage string, opts DescribeOp
topBundle := refWithDescription{
imgRef: bundle.NewBundleImageRef(lockconfig.ImageRef{Image: newBundle.DigestRef()}),
}
return topBundle.DescribeBundle(allBundles), nil
return topBundle.DescribeBundle(allBundles)
}

type refWithDescription struct {
imgRef bundle.ImageRef
bundle Description
}

func (r *refWithDescription) DescribeBundle(bundles []*bundle.Bundle) Description {
func (r *refWithDescription) DescribeBundle(bundles []*bundle.Bundle) (Description, error) {
var visitedImgs map[string]refWithDescription
return r.describeBundleRec(visitedImgs, r.imgRef, bundles)
}

func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDescription, currentBundle bundle.ImageRef, bundles []*bundle.Bundle) Description {
func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDescription, currentBundle bundle.ImageRef, bundles []*bundle.Bundle) (Description, error) {
desc, wasVisited := visitedImgs[currentBundle.Image]
if wasVisited {
return desc.bundle
return desc.bundle, nil
}

layers, err := getImageLayersInfo(currentBundle.Image)
if err != nil {
return desc.bundle, err
}

desc = refWithDescription{
Expand All @@ -136,6 +151,7 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes
Bundles: map[string]Description{},
Images: map[string]ImageInfo{},
},
Layers: layers,
},
}
var newBundle *bundle.Bundle
Expand All @@ -146,7 +162,7 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes
}
}
if newBundle == nil {
panic(fmt.Sprintf("Internal consistency: bundle with ref '%s' could not be found in list of bundles", currentBundle.PrimaryLocation()))
return desc.bundle, fmt.Errorf("Internal inconsistency: bundle with ref '%s' could not be found in list of bundles", currentBundle.PrimaryLocation())
}

imagesRefs := newBundle.ImagesRefsWithErrors()
Expand All @@ -156,27 +172,36 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes

for _, ref := range imagesRefs {
if ref.IsBundle == nil {
panic("Internal consistency: IsBundle after processing must always have a value")
return desc.bundle, fmt.Errorf("Internal inconsistency: IsBundle after processing must always have a value")
}

if *ref.IsBundle {
bundleDesc := r.describeBundleRec(visitedImgs, ref, bundles)
bundleDesc, err := r.describeBundleRec(visitedImgs, ref, bundles)
if err != nil {
return desc.bundle, err
}

digest, err := name.NewDigest(bundleDesc.Image)
if err != nil {
panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved", bundleDesc.Image))
return desc.bundle, fmt.Errorf("Internal inconsistency: image %s should be fully resolved", bundleDesc.Image)
}
desc.bundle.Content.Bundles[digest.DigestStr()] = bundleDesc
} else {
if ref.Error == "" {
digest, err := name.NewDigest(ref.Image)
if err != nil {
panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved", ref.Image))
return desc.bundle, fmt.Errorf("Internal inconsistency: image %s should be fully resolved", ref.Image)
}
layers, err = getImageLayersInfo(ref.Image)
if err != nil {
return desc.bundle, err
}
desc.bundle.Content.Images[digest.DigestStr()] = ImageInfo{
Image: ref.PrimaryLocation(),
Origin: ref.Image,
Annotations: ref.Annotations,
ImageType: ref.ImageType,
Layers: layers,
}
} else {
desc.bundle.Content.Images[ref.Image] = ImageInfo{
Expand All @@ -187,5 +212,32 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes
}
}

return desc.bundle
return desc.bundle, nil
}

func getImageLayersInfo(image string) ([]Layers, error) {
layers := []Layers{}
parsedImgRef, err := regname.ParseReference(image, regname.WeakValidation)
if err != nil {
return nil, fmt.Errorf("Error: %s in parsing image %s", err.Error(), image)
}

v1Img, err := remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain))
if err != nil {
return nil, fmt.Errorf("Error: %s in getting remote access of image %s", err.Error(), image)
}

imgLayers, err := v1Img.Layers()
if err != nil {
return nil, fmt.Errorf("Error: %s in getting layers of image %s", err.Error(), image)
}

for _, imgLayer := range imgLayers {
digHash, err := imgLayer.Digest()
if err != nil {
return nil, fmt.Errorf("Error: %s in getting digest of layer's of image %s", err.Error(), image)
}
layers = append(layers, Layers{Digest: digHash.String()})
}
return layers, nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/mattn/go-isatty/isatty_bsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/github.com/mattn/go-isatty/isatty_others.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/mattn/go-isatty/isatty_tcgets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# carvel.dev/imgpkg v0.39.0
# carvel.dev/imgpkg v0.40.0
## explicit; go 1.21
carvel.dev/imgpkg/pkg/imgpkg/bundle
carvel.dev/imgpkg/pkg/imgpkg/image
Expand Down Expand Up @@ -327,7 +327,7 @@ github.com/mailru/easyjson/jwriter
# github.com/mattn/go-colorable v0.1.13
## explicit; go 1.15
github.com/mattn/go-colorable
# github.com/mattn/go-isatty v0.0.19
# github.com/mattn/go-isatty v0.0.20
## explicit; go 1.15
github.com/mattn/go-isatty
# github.com/mattn/go-runewidth v0.0.14
Expand Down Expand Up @@ -639,6 +639,7 @@ sigs.k8s.io/json/internal/golang/encoding/json
# sigs.k8s.io/structured-merge-diff/v4 v4.2.1
## explicit; go 1.13
sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.3.0
# sigs.k8s.io/yaml v1.4.0
## explicit; go 1.12
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
Loading

0 comments on commit d1df25f

Please sign in to comment.