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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: ./ # test our "action.yml" 👀
- name: Smoke Test
run: |
Expand All @@ -41,7 +41,7 @@ jobs:
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Go Test
run: |
docker build --pull --file Dockerfile.test --tag test .
Expand All @@ -65,15 +65,15 @@ jobs:
name: Test Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Build Dockerfile
run: |
docker build --pull .
dockerfile-release:
name: Test Dockerfile.release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Build Dockerfile.release
run: |
docker build --pull --file Dockerfile.release .
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-bookworm AS build
FROM golang:1.24-trixie AS build

SHELL ["bash", "-Eeuo", "pipefail", "-xc"]

Expand All @@ -20,7 +20,7 @@ RUN apt-get update; \
apt-get install -y --no-install-recommends \
git \
; \
rm -rf /var/lib/apt/lists/*
apt-get dist-clean

COPY --from=build /bashbrew /usr/local/bin/
RUN bashbrew --version
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-bookworm
FROM golang:1.24-trixie

SHELL ["bash", "-Eeuo", "pipefail", "-xc"]

Expand All @@ -8,7 +8,7 @@ RUN apt-get update; \
gnupg \
wget \
; \
rm -rf /var/lib/apt/lists/*
apt-get dist-clean

WORKDIR /usr/src/bashbrew
ENV CGO_ENABLED 0
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-bookworm
FROM golang:1.24-trixie

SHELL ["bash", "-Eeuo", "pipefail", "-xc"]

Expand Down
2 changes: 1 addition & 1 deletion cmd/bashbrew/cmd-cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func cmdCat(c *cli.Context) error {
"archNamespace": func(arch string) string {
return archNamespaces[arch]
},
"archFilter": func(arch string, entriesArg ...interface{}) []manifest.Manifest2822Entry {
"archFilter": func(arch string, entriesArg ...any) []manifest.Manifest2822Entry {
if len(entriesArg) < 1 {
panic(`"archFilter" requires at least one argument`)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/bashbrew/cmd-children.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"slices"
"strings"

"github.com/urfave/cli"
Expand Down Expand Up @@ -152,7 +153,7 @@ func cmdChildren(c *cli.Context) error {
for _, kid := range kids {
supported := false
for _, arch := range arches.slice(kid) {
if sliceHas[string](supportedArches, arch) {
if slices.Contains(supportedArches, arch) {
supported = true
break
}
Expand Down
25 changes: 13 additions & 12 deletions cmd/bashbrew/cmd-put-shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
var errPutShared404 = fmt.Errorf("nothing to push")

func entriesToManifestToolYaml(singleArch bool, r Repo, entries ...*manifest.Manifest2822Entry) (string, []string, error) {
yaml := ""
var yaml strings.Builder
remoteDigests := []string{}
entryIdentifiers := []string{}
for _, entry := range entries {
Expand Down Expand Up @@ -52,33 +52,34 @@ func entriesToManifestToolYaml(singleArch bool, r Repo, entries ...*manifest.Man
}
remoteDigests = append(remoteDigests, archImageDigests...)

yaml += fmt.Sprintf(" - image: %s\n", archImage)
yaml += fmt.Sprintf(" platform:\n")
yaml += fmt.Sprintf(" os: %s\n", ociArch.OS)
yaml += fmt.Sprintf(" architecture: %s\n", ociArch.Architecture)
fmt.Fprintf(&yaml, " - image: %s\n", archImage)
fmt.Fprintf(&yaml, " platform:\n")
fmt.Fprintf(&yaml, " os: %s\n", ociArch.OS)
fmt.Fprintf(&yaml, " architecture: %s\n", ociArch.Architecture)
if ociArch.Variant != "" {
yaml += fmt.Sprintf(" variant: %s\n", ociArch.Variant)
fmt.Fprintf(&yaml, " variant: %s\n", ociArch.Variant)
}
}
}

if yaml == "" {
if yaml.Len() == 0 {
// we're not even going to try pushing something, so let's inform the caller of that to skip the unnecessary call to "manifest-tool"
return "", nil, errPutShared404
}

return "manifests:\n" + yaml, remoteDigests, nil
return "manifests:\n" + yaml.String(), remoteDigests, nil
}

func tagsToManifestToolYaml(repo string, tags ...string) string {
yaml := fmt.Sprintf("image: %s:%s\n", repo, tags[0])
var yaml strings.Builder
fmt.Fprintf(&yaml, "image: %s:%s\n", repo, tags[0])
if len(tags) > 1 {
yaml += "tags:\n"
yaml.WriteString("tags:\n")
for _, tag := range tags[1:] {
yaml += fmt.Sprintf(" - %s\n", tag)
fmt.Fprintf(&yaml, " - %s\n", tag)
}
}
return yaml
return yaml.String()
}

func cmdPutShared(c *cli.Context) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/bashbrew/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (dst *FlagsConfigEntry) Apply(src FlagsConfigEntry) {
}
}

func (config FlagsConfigEntry) Vars() map[string]map[string]interface{} {
return map[string]map[string]interface{}{
func (config FlagsConfigEntry) Vars() map[string]map[string]any {
return map[string]map[string]any{
"global": {
"library": config.Library,
"cache": config.Cache,
Expand Down Expand Up @@ -160,7 +160,7 @@ func (config FlagsConfig) ApplyTo(cmd string, c *cli.Context) error {

// https://github.com/urfave/cli/blob/73aa67b7a20db7514b1c086866469c49bc93a569/altsrc/flag.go#L237-L251
func isEnvVarSet(envVars string) bool {
for _, envVar := range strings.Split(envVars, ",") {
for envVar := range strings.SplitSeq(envVars, ",") {
envVar = strings.TrimSpace(envVar)
if envVal := os.Getenv(envVar); envVal != "" {
// TODO: Can't use this for bools as
Expand Down
11 changes: 2 additions & 9 deletions cmd/bashbrew/dedupe-slice.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package main

func sliceHas[T comparable](s []T, t T) bool {
for _, i := range s {
if i == t {
return true
}
}
return false
}
import "slices"

type dedupeSlice[T comparable] struct {
s []T
}

func (s *dedupeSlice[T]) add(i T) bool {
if sliceHas[T](s.s, i) {
if slices.Contains(s.s, i) {
return false
}
s.s = append(s.s, i)
Expand Down
6 changes: 3 additions & 3 deletions cmd/bashbrew/oci-builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

// given a reader and an interface to read it into, do the JSON decoder dance
func readJSON(r io.Reader, v interface{}) error {
func readJSON(r io.Reader, v any) error {
decoder := json.NewDecoder(r)
decoder.DisallowUnknownFields()
if err := decoder.Decode(&v); err != nil {
Expand All @@ -42,7 +42,7 @@ func readJSON(r io.Reader, v interface{}) error {
}

// given an io/fs, a file reference, and an interface to read it into, read a JSON blob from the io/fs
func readJSONFile(fs iofs.FS, file string, v interface{}) error {
func readJSONFile(fs iofs.FS, file string, v any) error {
f, err := fs.Open(file)
if err != nil {
return err
Expand All @@ -53,7 +53,7 @@ func readJSONFile(fs iofs.FS, file string, v interface{}) error {
}

// given a containerd content store and an OCI descriptor, parse the JSON blob
func readContentJSON(ctx context.Context, cs content.Provider, desc imagespec.Descriptor, v interface{}) error {
func readContentJSON(ctx context.Context, cs content.Provider, desc imagespec.Descriptor, v any) error {
ra, err := cs.ReaderAt(ctx, desc)
if err != nil {
return err
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/docker-library/bashbrew

go 1.23.0
go 1.24.0

require (
github.com/containerd/containerd v1.6.19
github.com/go-git/go-git/v5 v5.16.2
github.com/go-git/go-git/v5 v5.17.0
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221013174636-8159c8264e2e
github.com/sirupsen/logrus v1.9.3
github.com/urfave/cli v1.22.10
go.etcd.io/bbolt v1.3.7
golang.org/x/term v0.31.0
pault.ag/go/debian v0.12.0
golang.org/x/term v0.37.0
pault.ag/go/debian v0.19.0
pault.ag/go/topsort v0.1.1
)

Expand All @@ -30,15 +30,15 @@ require (
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-git/go-billy/v5 v5.8.0 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.13 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
Expand All @@ -53,11 +53,11 @@ require (
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
Loading
Loading