Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 1 addition & 6 deletions .github/actions/bootstrap/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ inputs:
go-version:
description: "Go version to install"
required: true
default: "1.26.x"
default: "1.26.2"
cache-key-prefix:
description: "Prefix all cache keys with this value"
required: true
default: "831180ac25"
bootstrap-apt-packages:
description: "Space delimited list of tools to install via apt"
default: ""

runs:
using: "composite"
steps:
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ inputs.go-version }}

- name: Restore tool cache
id: tool-cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
Expand All @@ -29,15 +27,12 @@ runs:
restore-keys: |
${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('Taskfile.yaml') }}
${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool

- name: (cache-miss) Bootstrap project tools
shell: bash
run: make ci-bootstrap-tools

- name: Bootstrap go dependencies
shell: bash
run: make ci-bootstrap-go

- name: Install apt packages
if: inputs.bootstrap-apt-packages != ''
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions cmd/binny/cli/option/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (d *JSONDuration) UnmarshalText(text []byte) error {
}

// support "Nd" shorthand for days
if strings.HasSuffix(s, "d") {
prefix := strings.TrimSuffix(s, "d")
if before, ok := strings.CutSuffix(s, "d"); ok {
prefix := before
days, err := strconv.Atoi(prefix)
if err != nil {
return fmt.Errorf("invalid duration %q: %w", string(text), err)
Expand Down Expand Up @@ -63,7 +63,7 @@ func (d JSONDuration) MarshalText() ([]byte, error) {
return []byte(d.Duration.String()), nil
}

func (d *JSONDuration) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (d *JSONDuration) UnmarshalYAML(unmarshal func(any) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/binny/cli/option/duration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestJSONDuration_UnmarshalYAML(t *testing.T) {
}

var d JSONDuration
err := d.UnmarshalYAML(func(v interface{}) error {
err := d.UnmarshalYAML(func(v any) error {
ptr, ok := v.(*string)
if !ok {
t.Fatal("expected *string")
Expand Down
4 changes: 2 additions & 2 deletions event/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ type ToolUpdate interface {
type ErrBadPayload struct {
Type partybus.EventType
Field string
Value interface{}
Value any
}

func (e *ErrBadPayload) Error() string {
return fmt.Sprintf("event='%s' has bad event payload field='%v': '%+v'", string(e.Type), e.Field, e.Value)
}

func newPayloadErr(t partybus.EventType, field string, value interface{}) error {
func newPayloadErr(t partybus.EventType, field string, value any) error {
return &ErrBadPayload{
Type: t,
Field: field,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/anchore/binny

go 1.24.2
go 1.26.2

require (
github.com/Masterminds/semver/v3 v3.4.0
Expand Down
8 changes: 4 additions & 4 deletions internal/http/logger_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ func NewLeveledLogger(lgr logger.Logger) retryablehttp.LeveledLogger {
return &leveledLoggerAdapter{lgr: lgr}
}

func (l *leveledLoggerAdapter) Error(msg string, keysAndValues ...interface{}) {
func (l *leveledLoggerAdapter) Error(msg string, keysAndValues ...any) {
l.lgr.WithFields(keysAndValues...).Error(msg)
}

func (l *leveledLoggerAdapter) Warn(msg string, keysAndValues ...interface{}) {
func (l *leveledLoggerAdapter) Warn(msg string, keysAndValues ...any) {
l.lgr.WithFields(keysAndValues...).Warn(msg)
}

func (l *leveledLoggerAdapter) Info(msg string, keysAndValues ...interface{}) {
func (l *leveledLoggerAdapter) Info(msg string, keysAndValues ...any) {
l.lgr.WithFields(keysAndValues...).Info(msg)
}

func (l *leveledLoggerAdapter) Debug(msg string, keysAndValues ...interface{}) {
func (l *leveledLoggerAdapter) Debug(msg string, keysAndValues ...any) {
l.lgr.WithFields(keysAndValues...).Debug(msg)
}
24 changes: 12 additions & 12 deletions internal/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,61 +27,61 @@ func Get() logger.Logger {
}

// Errorf takes a formatted template string and template arguments for the error logging level.
func Errorf(format string, args ...interface{}) {
func Errorf(format string, args ...any) {
log.Errorf(format, args...)
}

// Error logs the given arguments at the error logging level.
func Error(args ...interface{}) {
func Error(args ...any) {
log.Error(args...)
}

// Warnf takes a formatted template string and template arguments for the warning logging level.
func Warnf(format string, args ...interface{}) {
func Warnf(format string, args ...any) {
log.Warnf(format, args...)
}

// Warn logs the given arguments at the warning logging level.
func Warn(args ...interface{}) {
func Warn(args ...any) {
log.Warn(args...)
}

// Infof takes a formatted template string and template arguments for the info logging level.
func Infof(format string, args ...interface{}) {
func Infof(format string, args ...any) {
log.Infof(format, args...)
}

// Info logs the given arguments at the info logging level.
func Info(args ...interface{}) {
func Info(args ...any) {
log.Info(args...)
}

// Debugf takes a formatted template string and template arguments for the debug logging level.
func Debugf(format string, args ...interface{}) {
func Debugf(format string, args ...any) {
log.Debugf(format, args...)
}

// Debug logs the given arguments at the debug logging level.
func Debug(args ...interface{}) {
func Debug(args ...any) {
log.Debug(args...)
}

// Tracef takes a formatted template string and template arguments for the trace logging level.
func Tracef(format string, args ...interface{}) {
func Tracef(format string, args ...any) {
log.Tracef(format, args...)
}

// Trace logs the given arguments at the trace logging level.
func Trace(args ...interface{}) {
func Trace(args ...any) {
log.Trace(args...)
}

// WithFields returns a message logger with multiple key-value fields.
func WithFields(fields ...interface{}) logger.MessageLogger {
func WithFields(fields ...any) logger.MessageLogger {
return log.WithFields(fields...)
}

// Nested returns a new logger with hard coded key-value pairs
func Nested(fields ...interface{}) logger.Logger {
func Nested(fields ...any) logger.Logger {
return log.Nested(fields...)
}
11 changes: 9 additions & 2 deletions scripts/list_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
def go_list_exclude_pattern(owner, project):
exclude_pattern = f"{owner}/{project}/test"

result = subprocess.run(["go", "list", "./..."], stdout=subprocess.PIPE, text=True, check=True)
# restrict to packages that contain test files so `go test -coverprofile`
# does not drag test-less packages through the covdata toolchain
result = subprocess.run(
["go", "list", "-f", "{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}", "./..."],
stdout=subprocess.PIPE,
text=True,
check=True,
)

filtered_lines = [line for line in result.stdout.splitlines() if exclude_pattern not in line]
filtered_lines = [line for line in result.stdout.splitlines() if line and exclude_pattern not in line]

joined_output = ' '.join(filtered_lines)

Expand Down
2 changes: 1 addition & 1 deletion test/cli/trait_assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func assertFileOutput(tb testing.TB, path string, assertions ...traitAssertion)

func assertJson(tb testing.TB, _, stdout, _ string, _ int) {
tb.Helper()
var data interface{}
var data any

if err := json.Unmarshal([]byte(stdout), &data); err != nil {
tb.Errorf("expected to find a JSON report, but was unmarshalable: %+v", err)
Expand Down
4 changes: 2 additions & 2 deletions tool/githubrelease/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func downloadAndExtractAsset(ctx context.Context, asset ghAsset, checksumAsset *
}
}

logFields := map[string]interface{}{
logFields := map[string]any{
"destination": assetPath,
}

Expand Down Expand Up @@ -868,7 +868,7 @@ func fetchReleaseGithubV4API(ctx context.Context, user, repo, tag string) (*ghRe

RateLimit rateLimit
}
variables := map[string]interface{}{
variables := map[string]any{
"repositoryOwner": githubv4.String(user),
"repositoryName": githubv4.String(repo),
"tagName": githubv4.String(tag), // Null after argument to get first page.
Expand Down
2 changes: 1 addition & 1 deletion tool/githubrelease/version_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func fetchAllReleasesFromGithubV4API(ctx context.Context, user, repo string) ([]

RateLimit rateLimit
}
variables := map[string]interface{}{
variables := map[string]any{
"repositoryOwner": githubv4.String(user),
"repositoryName": githubv4.String(repo),
"releasesCursor": (*githubv4.String)(nil), // Null after argument to get first page.
Expand Down
4 changes: 2 additions & 2 deletions tool/githubrelease/version_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) {
name: "cooldown error when all versions are too new",
cooldown: 7 * 24 * time.Hour,
version: "latest",
wantErr: func(t require.TestingT, err error, _ ...interface{}) {
wantErr: func(t require.TestingT, err error, _ ...any) {
require.Error(t, err)
var cooldownErr *binny.CooldownError
require.ErrorAs(t, err, &cooldownErr)
Expand Down Expand Up @@ -484,7 +484,7 @@ func TestVersionResolver_UpdateVersion_withCooldown(t *testing.T) {
name: "update with cooldown error when all too new",
cooldown: 7 * 24 * time.Hour,
version: "1.0.0",
wantErr: func(t require.TestingT, err error, _ ...interface{}) {
wantErr: func(t require.TestingT, err error, _ ...any) {
require.Error(t, err)
var cooldownErr *binny.CooldownError
require.ErrorAs(t, err, &cooldownErr)
Expand Down
5 changes: 1 addition & 4 deletions tool/goproxy/version_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ func (v VersionResolver) checkCandidatesForCooldown(ctx context.Context, candida
result.absoluteLatest = candidates[0].original
}

limit := maxCooldownCandidates
if limit > len(candidates) {
limit = len(candidates)
}
limit := min(maxCooldownCandidates, len(candidates))
result.checkedCount = limit

for i := 0; i < limit; i++ {
Expand Down
8 changes: 4 additions & 4 deletions tool/goproxy/version_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) {
name: "cooldown error when all versions are too new",
cooldown: 7 * 24 * time.Hour,
version: "latest",
wantErr: func(t require.TestingT, err error, _ ...interface{}) {
wantErr: func(t require.TestingT, err error, _ ...any) {
require.Error(t, err)
var cooldownErr *binny.CooldownError
require.ErrorAs(t, err, &cooldownErr)
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) {
availableVersionsFetcher: func(_ context.Context, _ string) ([]string, error) {
// generate more candidates than maxCooldownCandidates
var versions []string
for i := 0; i < maxCooldownCandidates+5; i++ {
for i := range maxCooldownCandidates + 5 {
versions = append(versions, fmt.Sprintf("1.0.%d", i))
}
return versions, nil
Expand All @@ -239,7 +239,7 @@ func TestVersionResolver_ResolveVersion_withCooldown(t *testing.T) {
// all checked versions are too new
return &versionInfo{Version: "1.0.0", Time: newDate}, nil
},
wantErr: func(t require.TestingT, err error, _ ...interface{}) {
wantErr: func(t require.TestingT, err error, _ ...any) {
require.Error(t, err)
var cooldownErr *binny.CooldownError
require.ErrorAs(t, err, &cooldownErr)
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestVersionResolver_UpdateVersion_withCooldown(t *testing.T) {
name: "update with cooldown error when all too new",
cooldown: 7 * 24 * time.Hour,
version: "1.0.0",
wantErr: func(t require.TestingT, err error, _ ...interface{}) {
wantErr: func(t require.TestingT, err error, _ ...any) {
require.Error(t, err)
var cooldownErr *binny.CooldownError
require.ErrorAs(t, err, &cooldownErr)
Expand Down
Loading