Skip to content

Commit

Permalink
Bump imgutil and docker
Browse files Browse the repository at this point in the history
Signed-off-by: Natalie Arellano <[email protected]>
  • Loading branch information
natalieparellano committed Jul 29, 2024
1 parent 7f8729b commit 5b1f05e
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 131 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ install-mockgen:

install-golangci-lint:
@echo "> Installing golangci-lint..."
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2

lint: install-golangci-lint
@echo "> Linting code..."
Expand Down
61 changes: 4 additions & 57 deletions cmd/lifecycle/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
"github.com/buildpacks/imgutil/layout"
"github.com/buildpacks/imgutil/local"
"github.com/buildpacks/imgutil/remote"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
Expand Down Expand Up @@ -234,7 +232,7 @@ func (e *exportCmd) export(group buildpack.Group, cacheStore lifecycle.Cache, an
}

func (e *exportCmd) initDaemonAppImage(analyzedMD files.Analyzed) (imgutil.Image, string, error) {
var opts = []local.ImageOption{
var opts = []imgutil.ImageOption{
local.FromBaseImage(e.RunImageRef),
}
if e.supportsRunImageExtension() {
Expand All @@ -243,7 +241,7 @@ func (e *exportCmd) initDaemonAppImage(analyzedMD files.Analyzed) (imgutil.Image
return nil, "", cmd.FailErr(err, "get extended image config")
}
if extendedConfig != nil {
opts = append(opts, local.WithConfig(toContainerConfig(extendedConfig)))
opts = append(opts, local.WithConfig(extendedConfig))
}
}

Expand Down Expand Up @@ -285,59 +283,8 @@ func (e *exportCmd) initDaemonAppImage(analyzedMD files.Analyzed) (imgutil.Image
return appImage, runImageID.String(), nil
}

func toContainerConfig(v1C *v1.Config) *container.Config {
return &container.Config{
ArgsEscaped: v1C.ArgsEscaped,
AttachStderr: v1C.AttachStderr,
AttachStdin: v1C.AttachStdin,
AttachStdout: v1C.AttachStdout,
Cmd: v1C.Cmd,
Domainname: v1C.Domainname,
Entrypoint: v1C.Entrypoint,
Env: v1C.Env,
ExposedPorts: toNATPortSet(v1C.ExposedPorts),
Healthcheck: toHealthConfig(v1C.Healthcheck),
Hostname: v1C.Hostname,
Image: v1C.Image,
Labels: v1C.Labels,
MacAddress: v1C.MacAddress,
NetworkDisabled: v1C.NetworkDisabled,
OnBuild: v1C.OnBuild,
OpenStdin: v1C.OpenStdin,
Shell: v1C.Shell,
StdinOnce: v1C.StdinOnce,
StopSignal: v1C.StopSignal,
StopTimeout: nil,
Tty: v1C.Tty,
User: v1C.User,
Volumes: v1C.Volumes,
WorkingDir: v1C.WorkingDir,
}
}

func toHealthConfig(v1H *v1.HealthConfig) *container.HealthConfig {
if v1H == nil {
return &container.HealthConfig{}
}
return &container.HealthConfig{
Interval: v1H.Interval,
Retries: v1H.Retries,
StartPeriod: v1H.StartPeriod,
Test: v1H.Test,
Timeout: v1H.Timeout,
}
}

func toNATPortSet(v1Ps map[string]struct{}) nat.PortSet {
portSet := make(map[nat.Port]struct{})
for k, v := range v1Ps {
portSet[nat.Port(k)] = v
}
return portSet
}

func (e *exportCmd) initRemoteAppImage(analyzedMD files.Analyzed) (imgutil.Image, string, error) {
var opts = []remote.ImageOption{
var opts = []imgutil.ImageOption{
remote.FromBaseImage(e.RunImageRef),
}
if e.supportsRunImageExtension() {
Expand Down Expand Up @@ -390,7 +337,7 @@ func (e *exportCmd) initLayoutAppImage(analyzedMD files.Analyzed) (imgutil.Image
return nil, "", cmd.FailErr(err, "parsing run image reference")
}

var opts = []layout.ImageOption{
var opts = []imgutil.ImageOption{
layout.FromBaseImagePath(runImageIdentifier.Path),
}

Expand Down
20 changes: 3 additions & 17 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (e *Exporter) addExtensionLayers(opts ExportOptions) error {
Digest: layerHex.String(),
History: h,
}
if _, err = e.addOrReuseExtensionLayer(opts.WorkingImage, layer); err != nil {
if _, err = e.addExtensionLayer(opts.WorkingImage, layer); err != nil {
return err
}
}
Expand Down Expand Up @@ -694,22 +694,8 @@ func (e *Exporter) addOrReuseBuildpackLayer(image imgutil.Image, layer layers.La
return layer.Digest, image.AddLayerWithDiffIDAndHistory(layer.TarPath, layer.Digest, layer.History)
}

func (e *Exporter) addOrReuseExtensionLayer(image imgutil.Image, layer layers.Layer) (string, error) {
rc, err := image.GetLayer(layer.Digest)
if err != nil {
// FIXME: imgutil should declare an error type for missing layer
if !strings.Contains(err.Error(), "image did not have layer with diff id") && // remote
!strings.Contains(err.Error(), "does not contain layer with diff ID") {
return "", err
}
e.Logger.Infof("Adding extension layer %s\n", layer.ID)
e.Logger.Debugf("Layer '%s' SHA: %s\n", layer.ID, layer.Digest)
return layer.Digest, image.AddLayerWithDiffIDAndHistory(layer.TarPath, layer.Digest, layer.History)
}
_ = rc.Close() // close the layer reader
e.Logger.Infof("Reusing layer %s\n", layer.ID)
e.Logger.Debugf("Layer '%s' SHA: %s\n", layer.ID, layer.Digest)
return layer.Digest, image.ReuseLayerWithHistory(layer.Digest, layer.History)
func (e *Exporter) addExtensionLayer(image imgutil.Image, layer layers.Layer) (string, error) {
return layer.Digest, image.AddLayerWithDiffIDAndHistory(layer.TarPath, layer.Digest, layer.History)
}

func (e *Exporter) makeBuildReport(layersDir string) (files.BuildReport, error) {
Expand Down
6 changes: 1 addition & 5 deletions extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,11 @@ func (e *Extender) extend(kind string, baseImage v1.Image, logger log.Logger) (v
workingHistory []v1.History
)
// get config
baseImage, err = imgutil.OverrideHistoryIfNeeded(baseImage)
if err != nil {
return nil, err
}
configFile, err = baseImage.ConfigFile()
if err != nil {
return nil, err
}
workingHistory = configFile.History
workingHistory = imgutil.NormalizedHistory(configFile.History, len(configFile.RootFS.DiffIDs))
buildOptions := e.extendOptions()
userID, groupID := userFrom(*configFile)
origUserID := userID
Expand Down
27 changes: 14 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ require (
github.com/GoogleContainerTools/kaniko v1.20.1
github.com/apex/log v1.9.0
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20231213181459-b0fcec718dc6
github.com/buildpacks/imgutil v0.0.0-20230626185301-726f02e4225c
github.com/buildpacks/imgutil v0.0.0-20240605145725-186f89b2d168
github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589
github.com/containerd/containerd v1.7.14
github.com/docker/docker v25.0.5+incompatible
github.com/docker/go-connections v0.5.0
github.com/docker/docker v26.1.4+incompatible
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
github.com/google/go-containerregistry v0.19.0
github.com/google/go-containerregistry v0.19.1
github.com/google/uuid v1.5.0
github.com/heroku/color v0.0.6
github.com/moby/buildkit v0.12.5
github.com/pkg/errors v0.9.1
github.com/sclevine/spec v1.4.0
golang.org/x/sync v0.6.0
golang.org/x/sys v0.16.0
golang.org/x/sync v0.7.0
golang.org/x/sys v0.18.0
)

require (
Expand Down Expand Up @@ -68,10 +67,11 @@ require (
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v24.0.7+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand All @@ -95,6 +95,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/swarmkit/v2 v2.0.0-20230531095716-6675724599d6 // indirect
Expand All @@ -120,13 +121,13 @@ require (
github.com/vbatts/tar-split v0.11.3 // indirect
go.etcd.io/etcd/raft/v3 v3.5.9 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
Expand Down
Loading

0 comments on commit 5b1f05e

Please sign in to comment.