Skip to content

Commit 48ac541

Browse files
Merge pull request containers#6380 from nalind/go1.24
Update to Go 1.24
2 parents 9bd608b + 6e4d1ca commit 48ac541

File tree

18 files changed

+64
-67
lines changed

18 files changed

+64
-67
lines changed

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ env:
3535
DEBIAN_NAME: "debian-13"
3636

3737
# Image identifiers
38-
IMAGE_SUFFIX: "c20250812t173301z-f42f41d13"
38+
IMAGE_SUFFIX: "c20250910t092246z-f42f41d13"
3939
FEDORA_CACHE_IMAGE_NAME: "fedora-${IMAGE_SUFFIX}"
4040
PRIOR_FEDORA_CACHE_IMAGE_NAME: "prior-fedora-${IMAGE_SUFFIX}"
4141
DEBIAN_CACHE_IMAGE_NAME: "debian-${IMAGE_SUFFIX}"
@@ -124,7 +124,7 @@ vendor_task:
124124

125125
# Runs within Cirrus's "community cluster"
126126
container:
127-
image: docker.io/library/golang:1.23.3
127+
image: docker.io/library/golang:1.24.0
128128
cpu: 1
129129
memory: 1
130130

buildah.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ type Builder struct {
132132
ImageHistoryComment string `json:"history-comment,omitempty"`
133133

134134
// Image metadata and runtime settings, in multiple formats.
135-
OCIv1 v1.Image `json:"ociv1,omitempty"`
136-
Docker docker.V2Image `json:"docker,omitempty"`
135+
OCIv1 v1.Image `json:"ociv1"`
136+
Docker docker.V2Image `json:"docker"`
137137
// DefaultMountsFilePath is the file path holding the mounts to be mounted in "host-path:container-path" format.
138138
DefaultMountsFilePath string `json:"defaultMountsFilePath,omitempty"`
139139

cmd/buildah/containers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ func containerOutputHeader(truncate bool) {
277277

278278
func parseCtrFilter(filter string) (*containerFilterParams, error) {
279279
params := new(containerFilterParams)
280-
filters := strings.Split(filter, ",")
281-
for _, param := range filters {
280+
filters := strings.SplitSeq(filter, ",")
281+
for param := range filters {
282282
pair := strings.SplitN(param, "=", 2)
283283
if len(pair) != 2 {
284284
return nil, fmt.Errorf("incorrect filter value %q, should be of form filter=value", param)

copier/copier.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ type request struct {
162162
preservedDirectory string
163163
Globs []string `json:",omitempty"` // used by stat, get
164164
preservedGlobs []string
165-
StatOptions StatOptions `json:",omitempty"`
166-
GetOptions GetOptions `json:",omitempty"`
167-
PutOptions PutOptions `json:",omitempty"`
168-
MkdirOptions MkdirOptions `json:",omitempty"`
169-
RemoveOptions RemoveOptions `json:",omitempty"`
170-
EnsureOptions EnsureOptions `json:",omitempty"`
171-
ConditionalRemoveOptions ConditionalRemoveOptions `json:",omitempty"`
165+
StatOptions StatOptions
166+
GetOptions GetOptions
167+
PutOptions PutOptions
168+
MkdirOptions MkdirOptions
169+
RemoveOptions RemoveOptions
170+
EnsureOptions EnsureOptions
171+
ConditionalRemoveOptions ConditionalRemoveOptions
172172
}
173173

174174
func (req *request) Excludes() []string {
@@ -248,15 +248,15 @@ func (req *request) GIDMap() []idtools.IDMap {
248248

249249
// Response encodes a single response.
250250
type response struct {
251-
Error string `json:",omitempty"`
252-
Stat statResponse `json:",omitempty"`
253-
Eval evalResponse `json:",omitempty"`
254-
Get getResponse `json:",omitempty"`
255-
Put putResponse `json:",omitempty"`
256-
Mkdir mkdirResponse `json:",omitempty"`
257-
Remove removeResponse `json:",omitempty"`
258-
Ensure ensureResponse `json:",omitempty"`
259-
ConditionalRemove conditionalRemoveResponse `json:",omitempty"`
251+
Error string `json:",omitempty"`
252+
Stat statResponse
253+
Eval evalResponse
254+
Get getResponse
255+
Put putResponse
256+
Mkdir mkdirResponse
257+
Remove removeResponse
258+
Ensure ensureResponse
259+
ConditionalRemove conditionalRemoveResponse
260260
}
261261

262262
// statResponse encodes a response for a single Stat request.
@@ -801,7 +801,7 @@ func copierWithSubprocess(bulkReader io.Reader, bulkWriter io.Writer, req reques
801801
}
802802
loggedOutput := strings.TrimSuffix(errorBuffer.String(), "\n")
803803
if len(loggedOutput) > 0 {
804-
for _, output := range strings.Split(loggedOutput, "\n") {
804+
for output := range strings.SplitSeq(loggedOutput, "\n") {
805805
logrus.Debug(output)
806806
}
807807
}
@@ -1588,8 +1588,8 @@ func mapWithPrefixedKeysWithoutKeyPrefix[K any](m map[string]K, p string) map[st
15881588
}
15891589
cloned := make(map[string]K, len(m))
15901590
for k, v := range m {
1591-
if strings.HasPrefix(k, p) {
1592-
cloned[strings.TrimPrefix(k, p)] = v
1591+
if after, ok := strings.CutPrefix(k, p); ok {
1592+
cloned[after] = v
15931593
}
15941594
}
15951595
return cloned
@@ -1819,7 +1819,7 @@ func copierHandlerPut(bulkReader io.Reader, req request, idMappings *idtools.IDM
18191819
return fmt.Errorf("%q is not a subdirectory of %q: %w", directory, req.Root, err)
18201820
}
18211821
subdir := ""
1822-
for _, component := range strings.Split(rel, string(os.PathSeparator)) {
1822+
for component := range strings.SplitSeq(rel, string(os.PathSeparator)) {
18231823
subdir = filepath.Join(subdir, component)
18241824
path := filepath.Join(req.Root, subdir)
18251825
if err := os.Mkdir(path, 0o700); err == nil {
@@ -2187,7 +2187,7 @@ func copierHandlerPut(bulkReader io.Reader, req request, idMappings *idtools.IDM
21872187
}
21882188

21892189
func copierHandlerMkdir(req request, idMappings *idtools.IDMappings) (*response, func() error, error) {
2190-
errorResponse := func(fmtspec string, args ...any) (*response, func() error, error) {
2190+
errorResponse := func(fmtspec string, args ...any) (*response, func() error, error) { //nolint:unparam
21912191
return &response{Error: fmt.Sprintf(fmtspec, args...), Mkdir: mkdirResponse{}}, nil, nil
21922192
}
21932193
dirUID, dirGID := 0, 0
@@ -2219,7 +2219,7 @@ func copierHandlerMkdir(req request, idMappings *idtools.IDMappings) (*response,
22192219

22202220
subdir := ""
22212221
var created []string
2222-
for _, component := range strings.Split(rel, string(os.PathSeparator)) {
2222+
for component := range strings.SplitSeq(rel, string(os.PathSeparator)) {
22232223
subdir = filepath.Join(subdir, component)
22242224
path := filepath.Join(req.Root, subdir)
22252225
if err := os.Mkdir(path, 0o700); err == nil {

copier/xattrs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func Lgetxattrs(path string) (map[string]string, error) {
6565
return nil, fmt.Errorf("unable to read list of attributes for %q: size would have been too big", path)
6666
}
6767
m := make(map[string]string)
68-
for _, attribute := range strings.Split(string(list), string('\000')) {
68+
for attribute := range strings.SplitSeq(string(list), string('\000')) {
6969
if isRelevantXattr(attribute) {
7070
attributeSize := initialXattrValueSize
7171
var attributeValue []byte

docker/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ type V1Compatibility struct {
124124
Created time.Time `json:"created"`
125125
ContainerConfig struct {
126126
Cmd []string
127-
} `json:"container_config,omitempty"`
127+
} `json:"container_config"`
128128
Author string `json:"author,omitempty"`
129129
ThrowAway bool `json:"throwaway,omitempty"`
130130
}
@@ -143,7 +143,7 @@ type V1Image struct {
143143
// Container is the id of the container used to commit
144144
Container string `json:"container,omitempty"`
145145
// ContainerConfig is the configuration of the container that is committed into the image
146-
ContainerConfig Config `json:"container_config,omitempty"`
146+
ContainerConfig Config `json:"container_config"`
147147
// DockerVersion specifies the version of Docker that was used to build the image
148148
DockerVersion string `json:"docker_version,omitempty"`
149149
// Author is the name of the author that was specified when committing the image

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/containers/buildah
22

33
// Warning: Ensure the "go" and "toolchain" versions match exactly to prevent unwanted auto-updates
44

5-
go 1.23.3
5+
go 1.24.0
66

77
require (
88
github.com/containerd/platforms v1.0.0-rc.1

imagebuildah/executor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,12 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
836836
}
837837
case "ADD", "COPY":
838838
for _, flag := range child.Flags { // flags for this instruction
839-
if strings.HasPrefix(flag, "--from=") {
839+
if after, ok := strings.CutPrefix(flag, "--from="); ok {
840840
// TODO: this didn't undergo variable and
841841
// arg expansion, so if the previous stage
842842
// was named using argument values, we might
843843
// not record the right value here.
844-
rootfs := strings.TrimPrefix(flag, "--from=")
844+
rootfs := after
845845
b.rootfsMap[rootfs] = struct{}{}
846846
logrus.Debugf("rootfs needed for COPY in stage %d: %q", stageIndex, rootfs)
847847
// Populate dependency tree and check
@@ -885,8 +885,8 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
885885
// dependency calculation.
886886
if strings.HasPrefix(flag, "--mount=") && strings.Contains(flag, "from") {
887887
mountFlags := strings.TrimPrefix(flag, "--mount=")
888-
fields := strings.Split(mountFlags, ",")
889-
for _, field := range fields {
888+
fields := strings.SplitSeq(mountFlags, ",")
889+
for field := range fields {
890890
if mountFrom, hasFrom := strings.CutPrefix(field, "from="); hasFrom {
891891
// Check if this base is a stage if yes
892892
// add base to current stage's dependency tree

imagebuildah/stage_executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ func (s *StageExecutor) getCreatedBy(node *parser.Node, addedContentSummary stri
19131913

19141914
switch command {
19151915
case "ARG":
1916-
for _, variable := range strings.Fields(node.Original) {
1916+
for variable := range strings.FieldsSeq(node.Original) {
19171917
if variable != "ARG" {
19181918
s.argsFromContainerfile = append(s.argsFromContainerfile, variable)
19191919
}

info.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ func getHostDistributionInfo() map[string]string {
183183

184184
l := bufio.NewScanner(f)
185185
for l.Scan() {
186-
if strings.HasPrefix(l.Text(), "ID=") {
187-
dist["Distribution"] = strings.TrimPrefix(l.Text(), "ID=")
186+
if after, ok := strings.CutPrefix(l.Text(), "ID="); ok {
187+
dist["Distribution"] = after
188188
}
189-
if strings.HasPrefix(l.Text(), "VERSION_ID=") {
190-
dist["Version"] = strings.Trim(strings.TrimPrefix(l.Text(), "VERSION_ID="), "\"")
189+
if after, ok := strings.CutPrefix(l.Text(), "VERSION_ID="); ok {
190+
dist["Version"] = strings.Trim(after, "\"")
191191
}
192192
}
193193
return dist

0 commit comments

Comments
 (0)