Skip to content

Commit

Permalink
CLID-160 - upgrading containers/image, oc and library-go (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
aguidirh authored Sep 16, 2024
1 parent e04028c commit 8d037ba
Show file tree
Hide file tree
Showing 16 changed files with 4,646 additions and 2,495 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ hack-build: clean
.PHONY: hack-build

tidy:
$(GO) mod tidy
$(GO) work sync
.PHONY: tidy

clean:
Expand Down
320 changes: 151 additions & 169 deletions go.mod

Large diffs are not rendered by default.

2,768 changes: 1,788 additions & 980 deletions go.sum

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,3 @@ use (
.
./v2
)

replace github.com/apcera/gssapi => github.com/openshift/gssapi v0.0.0-20161010215902-5fb4217df13b

replace github.com/containerd/stargz-snapshotter/estargz => github.com/containerd/stargz-snapshotter/estargz v0.12.0

replace github.com/google/go-containerregistry => github.com/google/go-containerregistry v0.10.0

replace github.com/vbatts/tar-split => github.com/vbatts/tar-split v0.11.2

replace github.com/docker/docker => github.com/docker/docker v20.10.21+incompatible
2,423 changes: 2,402 additions & 21 deletions go.work.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"time"

"github.com/docker/distribution/manifest"
"github.com/distribution/distribution/v3/manifest"
"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cincinnati/cincinnati.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func getGraphData(ctx context.Context, c Client) (graph graph, err error) {
klog.V(5).Infof("Using a root CA pool with 0 root CA subjects to request updates from %s", uri)
} else {

klog.V(5).Infof("Using a root CA pool with %n root CA subjects to request updates from %s", len(transport.TLSClientConfig.RootCAs.Subjects()), uri)
klog.V(5).Infof("Using a root CA pool with %d root CA subjects to request updates from %s", len(transport.TLSClientConfig.RootCAs.Subjects()), uri)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/mirror/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func unpack(archiveFilePath, dest string, filesInArchive map[string]string) erro
if archiveFilePath == config.CatalogsDir {
err := unarchive(archivePath, dest)
if err != nil {
klog.V(2).Info("unarchive failed with the error: %s", err.Error())
klog.V(2).Infof("unarchive failed with the error: %s", err.Error())
return err
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/mirror/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (o *ReleaseOptions) Plan(ctx context.Context, lastRun v1alpha2.PastMirror,

// Create release mapping and get images list
// before mirroring actions
mappings, err := o.getMapping(opts)
mappings, err := o.getMapping(ctx, opts)
if err != nil {
return mmapping, fmt.Errorf("error retrieving mapping information for %s: %v", img, err)
}
Expand Down Expand Up @@ -370,7 +370,7 @@ func (o *ReleaseOptions) newMirrorReleaseOptions(fileDir string) (*release.Mirro
}

// getMapping will run release mirror with ToMirror set to true to get mapping information
func (o *ReleaseOptions) getMapping(opts *release.MirrorOptions) (image.TypedImageMapping, error) {
func (o *ReleaseOptions) getMapping(ctx context.Context, opts *release.MirrorOptions) (image.TypedImageMapping, error) {
mappingPath := filepath.Join(o.Dir, mappingFile)
file, err := os.Create(filepath.Clean(mappingPath))
defer os.Remove(mappingPath)
Expand All @@ -385,7 +385,7 @@ func (o *ReleaseOptions) getMapping(opts *release.MirrorOptions) (image.TypedIma
if err := opts.Validate(); err != nil {
return nil, err
}
if err := opts.Run(); err != nil {
if err := opts.Run(ctx); err != nil {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/image/association_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"path/filepath"

ctrsimgmanifest "github.com/containers/image/v5/manifest"
"github.com/docker/distribution"
"github.com/docker/distribution/manifest/manifestlist"
"github.com/docker/distribution/manifest/schema2"
"github.com/distribution/distribution/v3"
"github.com/distribution/distribution/v3/manifest/manifestlist"
"github.com/distribution/distribution/v3/manifest/schema2"
"github.com/opencontainers/go-digest"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/openshift/oc/pkg/cli/image/imagesource"
Expand Down
46 changes: 41 additions & 5 deletions pkg/image/builder/image_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ import (
"k8s.io/klog/v2"
)

const (
// Mode constants from the USTAR spec:
// See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06
c_ISUID = 04000 // Set uid
c_ISGID = 02000 // Set gid
c_ISVTX = 01000 // Save text (sticky bit)
)

// ImageBuilder use an OCI workspace to add layers and change configuration to images.
type ImageBuilder struct {
NameOpts []name.Option
Expand Down Expand Up @@ -403,15 +411,27 @@ func LayerFromPathWithUidGid(targetPath, path string, uid int, gid int) (v1.Laye
}

hdr := &tar.Header{
Name: filepath.Join(targetPath, filepath.ToSlash(rel)),
Mode: int64(info.Mode()),
Name: filepath.Join(targetPath, filepath.ToSlash(rel)),
Format: tar.FormatPAX,
Mode: int64(info.Mode().Perm()),
}
if uid != -1 {
hdr.Uid = uid
}
if gid != -1 {
hdr.Gid = gid
}

if info.Mode()&os.ModeSetuid != 0 {
hdr.Mode |= c_ISUID
}
if info.Mode()&os.ModeSetgid != 0 {
hdr.Mode |= c_ISGID
}
if info.Mode()&os.ModeSticky != 0 {
hdr.Mode |= c_ISVTX
}

if err := processPaths(hdr, info, fp); err != nil {
return err
}
Expand All @@ -425,15 +445,27 @@ func LayerFromPathWithUidGid(targetPath, path string, uid int, gid int) (v1.Laye
} else {
base := filepath.Base(path)
hdr := &tar.Header{
Name: filepath.Join(targetPath, filepath.ToSlash(base)),
Mode: int64(pathInfo.Mode()),
Name: filepath.Join(targetPath, filepath.ToSlash(base)),
Format: tar.FormatPAX,
Mode: int64(pathInfo.Mode().Perm()),
}
if uid != -1 { // uid was specified in the input param
hdr.Uid = uid
}
if gid != -1 { // gid was specified in the input param
hdr.Gid = gid
}

if pathInfo.Mode()&os.ModeSetuid != 0 {
hdr.Mode |= c_ISUID
}
if pathInfo.Mode()&os.ModeSetgid != 0 {
hdr.Mode |= c_ISGID
}
if pathInfo.Mode()&os.ModeSticky != 0 {
hdr.Mode |= c_ISVTX
}

if err := processPaths(hdr, pathInfo, path); err != nil {
return nil, err
}
Expand All @@ -442,5 +474,9 @@ func LayerFromPathWithUidGid(targetPath, path string, uid int, gid int) (v1.Laye
if err := tw.Close(); err != nil {
return nil, fmt.Errorf("failed to finish tar: %w", err)
}
return tarball.LayerFromReader(&b)

opener := func() (io.ReadCloser, error) {
return io.NopCloser(bytes.NewReader(b.Bytes())), nil
}
return tarball.LayerFromOpener(opener)
}
2 changes: 1 addition & 1 deletion pkg/image/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func ConvertToAssociationSet(assocs []v1alpha2.Association) (AssociationSet, err
}
assocSet.Add(value.Name, value)
for _, digest := range value.ManifestDigests {
klog.V(4).Info("image %q: processing child manifest %s", value.Name, digest)
klog.V(4).Infof("image %s: processing child manifest %s", value.Name, digest)
child, ok := assocMapping[digest+value.Path]
if !ok {
return assocSet, fmt.Errorf("invalid associations: association for %q is missing", digest)
Expand Down
2 changes: 1 addition & 1 deletion pkg/metadata/storage/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"path/filepath"
"time"

"github.com/docker/distribution/registry/client/auth"
"github.com/distribution/distribution/v3/registry/client/auth"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/name"
Expand Down
1 change: 0 additions & 1 deletion test/e2e/testcases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ function m2m_release_with_oci_catalog {

go build -mod=readonly -o test/e2e/graph test/e2e/graph/main.go

go build -mod=readonly -o test/e2e/graph test/e2e/graph/main.go
test/e2e/graph/main & PID_GO=$!
echo -e "go cincinnatti web service PID: ${PID_GO}"
# copy relevant files and start the mirror process
Expand Down
Loading

0 comments on commit 8d037ba

Please sign in to comment.