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 bb09d5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
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 bb09d5f

Please sign in to comment.