Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-retornam committed Jun 29, 2023
1 parent b2b476f commit 52b14b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 5 additions & 5 deletions pkg/buildkit/buildkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 4 additions & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"time"

"github.com/samber/lo"
"gopkg.in/yaml.v3"
)

Expand All @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 52b14b4

Please sign in to comment.