diff --git a/go.mod b/go.mod index ceef07f3..5ea518b3 100644 --- a/go.mod +++ b/go.mod @@ -139,7 +139,6 @@ require ( github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect - github.com/samber/lo v1.38.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/tonistiigi/fsutil v0.0.0-20230105215944-fb433841cbfa // indirect diff --git a/go.sum b/go.sum index 205974ed..edf7814b 100644 --- a/go.sum +++ b/go.sum @@ -469,8 +469,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= -github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE= github.com/shibumi/go-pathspec v1.3.0 h1:QUyMZhFo0Md5B8zV8x2tesohbb5kfbpTi9rBnKh5dkI= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= diff --git a/pkg/buildkit/buildkit.go b/pkg/buildkit/buildkit.go index 87096fa8..cad656ad 100644 --- a/pkg/buildkit/buildkit.go +++ b/pkg/buildkit/buildkit.go @@ -119,20 +119,20 @@ type Client struct { dockerAuthConfig string } -func validateCompression(compression hephconfig.BuildkitCompression, name string) map[string]string { +func setCompressionAttrs(compression hephconfig.BuildkitCompression, name string) map[string]string { attrs := make(map[string]string) attrs["name"] = name switch compression { - case "estargz": + case hephconfig.CompressionStargz: attrs["push"] = "true" attrs["compression"] = "estargz" attrs["force-compression"] = "true" attrs["oci-mediatypes"] = "true" - case "zstd": + case hephconfig.CompressionZstd: attrs["compression"] = "zstd" attrs["force-compression"] = "true" // default is gzip - default: + case hephconfig.CompressionGzip: attrs["push"] = "true" } return attrs @@ -251,7 +251,7 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error { } } for _, name := range opts.Images { - bkclientattrs := validateCompression(hephconfig.CompressionMethod, name) + bkclientattrs := setCompressionAttrs(hephconfig.CompressionMethod, name) solveOpt.Exports = append(solveOpt.Exports, bkclient.ExportEntry{ Type: bkclient.ExporterImage, Attrs: bkclientattrs, diff --git a/pkg/config/config.go b/pkg/config/config.go index 26fc6b49..455a4b6e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -9,7 +9,6 @@ import ( "strings" "time" - "github.com/samber/lo" "gopkg.in/yaml.v3" ) @@ -25,9 +24,6 @@ type Controller struct { func (c Controller) Validate() error { var errs []string - var compression = []BuildkitCompression{CompressionGzip, - CompressionStargz, CompressionZstd} - if c.ImageBuildMaxConcurrency < 1 { errs = append(errs, "imageBuildMaxConcurrency must be greater than or equal to 1") } @@ -55,11 +51,11 @@ func (c Controller) Validate() error { errs = append(errs, "newRelic.licenseKey cannot be blank") } - if !lo.Contains(compression, c.Buildkit.Compression) { - c.Buildkit.Compression = CompressionGzip - CompressionMethod = c.Buildkit.Compression - } else { + switch c.Buildkit.Compression { + case CompressionGzip, CompressionStargz, CompressionZstd: CompressionMethod = c.Buildkit.Compression + default: + CompressionMethod = CompressionGzip } if len(errs) != 0 {