Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ install-goimports:
## install-golangci-lint: Install golangci-lint dependency
install-golangci-lint:
@echo "=====> Installing golangci-lint..."
cd tools && $(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
cd tools && $(GOCMD) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2

## mod-tidy: Tidy Go modules
mod-tidy:
$(GOCMD) mod tidy -compat=1.23
cd tools && $(GOCMD) mod tidy -compat=1.23
$(GOCMD) mod tidy -compat=1.24
cd tools && $(GOCMD) mod tidy -compat=1.24

## tidy: Tidy modules and format the code
tidy: mod-tidy format
Expand Down
4 changes: 2 additions & 2 deletions builder/config_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type ModuleConfig struct {
}

func (c *ModuleConfig) DisplayString() string {
if c.ModuleInfo.FullName() != "" {
return c.ModuleInfo.FullName()
if c.FullName() != "" {
return c.FullName()
}

return c.ImageOrURI.DisplayString()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ require (

replace github.com/BurntSushi/toml => github.com/BurntSushi/toml v1.3.2

go 1.23.0
go 1.24.0

toolchain go1.23.3
toolchain go1.24.2
53 changes: 36 additions & 17 deletions golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
run:
timeout: 6m

version: "2"
linters:
disable-all: true
default: none
enable:
- bodyclose
- exportloopref
- dogsled
- gocritic
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
- whitespace

linters-settings:
goimports:
local-prefixes: github.com/buildpacks/pack
revive:
rules:
- name: error-strings
disabled: true
settings:
revive:
rules:
- name: error-strings
disabled: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- goimports
settings:
goimports:
local-prefixes:
- github.com/buildpacks/pack
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
issues:
default: info
rules:
- linters:
- staticcheck: info
2 changes: 1 addition & 1 deletion internal/builder/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (v *Version) Equal(other *Version) bool {

// MarshalText makes Version satisfy the encoding.TextMarshaler interface.
func (v *Version) MarshalText() ([]byte, error) {
return []byte(v.Version.Original()), nil
return []byte(v.Original()), nil
}

// UnmarshalText makes Version satisfy the encoding.TextUnmarshaler interface.
Expand Down
6 changes: 3 additions & 3 deletions pkg/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ func NormalizeHeader(header *tar.Header, normalizeModTime bool) {
func IsZip(path string) (bool, error) {
r, err := zip.OpenReader(path)

switch {
case err == nil:
switch err {
case nil:
r.Close()
return true, nil
case err == zip.ErrFormat:
case zip.ErrFormat:
return false, nil
default:
return false, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/buildpack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func validateBuildpacks(mainBP BuildModule, depBPs []BuildModule) error {
bpd := bp.Descriptor()
for _, orderEntry := range bpd.Order() {
for _, groupEntry := range orderEntry.Group {
bpFullName, err := groupEntry.ModuleInfo.FullNameWithVersion()
bpFullName, err := groupEntry.FullNameWithVersion()
if err != nil {
return errors.Wrapf(
err,
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ type layoutPathConfig struct {
func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
var pathsConfig layoutPathConfig

if RunningInContainer() && !(opts.PullPolicy == image.PullAlways) {
if RunningInContainer() && (opts.PullPolicy != image.PullAlways) {
c.logger.Warnf("Detected pack is running in a container; if using a shared docker host, failing to pull build inputs from a remote registry is insecure - " +
"other tenants may have compromised build inputs stored in the daemon." +
"This configuration is insecure and may become unsupported in the future." +
Expand Down Expand Up @@ -569,7 +569,7 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error {
if targetToUse.OS == "windows" {
return fmt.Errorf("builder contains image extensions which are not supported for Windows builds")
}
if !(opts.PullPolicy == image.PullAlways) {
if opts.PullPolicy != image.PullAlways {
return fmt.Errorf("pull policy must be 'always' when builder contains image extensions")
}
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/client/register_buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (c *Client) RegisterBuildpack(ctx context.Context, opts RegisterBuildpackOp
Yanked: false,
}

if opts.Type == "github" {
switch opts.Type {
case "github":
issueURL, err := registry.GetIssueURL(opts.URL)
if err != nil {
return err
Expand All @@ -76,7 +77,7 @@ func (c *Client) RegisterBuildpack(ctx context.Context, opts RegisterBuildpackOp
}

return cmd.Start()
} else if opts.Type == "git" {
case "git":
registryCache, err := getRegistry(c.logger, opts.Name)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/dist/dist.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ type ImageOrURI struct {
}

func (c *ImageOrURI) DisplayString() string {
if c.BuildpackURI.URI != "" {
return c.BuildpackURI.URI
if c.URI != "" {
return c.URI
}

return c.ImageRef.ImageName
return c.ImageName
}

type Platform struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/logging/logger_writers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewLogWithWriters(stdout, stderr io.Writer, opts ...func(*LogWithWriters))
out: stdout,
errOut: stderr,
}
lw.Logger.Handler = lw
lw.Handler = lw

for _, opt := range opts {
opt(lw)
Expand Down
5 changes: 3 additions & 2 deletions pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ func warnIfTomlContainsKeysNotSupportedBySchema(schemaVersion string, tomlMetaDa
}

func unsupportedKey(keyName, schemaVersion string) bool {
if schemaVersion == "0.1" {
switch schemaVersion {
case "0.1":
// filter out any keys from [metadata] and any other custom table defined by end-users
return strings.HasPrefix(keyName, "project.") || strings.HasPrefix(keyName, "build.") || strings.Contains(keyName, "io.buildpacks")
} else if schemaVersion == "0.2" {
case "0.2":
// filter out any keys from [_.metadata] and any other custom table defined by end-users
return strings.Contains(keyName, "io.buildpacks") || (strings.HasPrefix(keyName, "_.") && !strings.HasPrefix(keyName, "_.metadata"))
}
Expand Down
6 changes: 3 additions & 3 deletions testhelpers/comparehelpers/deep_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func mapContains(v1, v2 reflect.Value, depth int) bool {
}

func arrayLikeContains(v1, v2 reflect.Value, depth int) bool {
t2 := v2.Kind()
if t2 == reflect.Interface {
switch v2.Kind() {
case reflect.Interface:
return mapContains(v1, v2.Elem(), depth+1)
} else if t2 == reflect.Array || t2 == reflect.Slice {
case reflect.Array, reflect.Slice:
v1Index := 0
v2Index := 0
for v1Index < v1.Len() && v2Index < v2.Len() {
Expand Down
Loading
Loading