Skip to content

update minimum go version to go1.23 and modernize some code - #354

Draft
thaJeztah wants to merge 9 commits into
cncf-tags:mainfrom
thaJeztah:cdi_cleans_step1
Draft

update minimum go version to go1.23 and modernize some code#354
thaJeztah wants to merge 9 commits into
cncf-tags:mainfrom
thaJeztah:cdi_cleans_step1

Conversation

@thaJeztah

@thaJeztah thaJeztah commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

go.mod: update minimum go version to go1.23

pkg/cdi: simplify some code with slices, maps packages

Both slices.Clone and maps.Clone already handles nil values, so we can
skip our own checks, making the code slightly more straightforward.

Also update GetSpecDirErrors to make sure we perform the copy after
obtaining a lock.

pkg/cdi: ListClasses: combine loops

pkg/cdi: scope variables and move them closer to where used

Add a matrix to run tests against the oldest supported version (as
specified in go.mod), as well as current and previous stable Go.

Use a custom name for the job so that the names are stable, which
helps when configuring GitHub branch policies.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
InjectDevices only needs to hold the lock while refreshing the cache and
capturing the current devices map. Release the lock before resolving devices
to reduce lock contention while applying the container edits on the passed-in
OCI spec.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This is a constructor, working on a freshly created `Cache`, so there
should be no concurrency to account for. While updating, also set the
default specDirs directly from a clone of `DefaultSpecDirs`, instead of
applying through `WithSpecDirs` to avoid the extra indirect.

Paths are still cleaned, to account for the `DefaultSpecDirs` being
a mutable, package-level variable (but generally not recommended to
update).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Rename vars that shadowed imports, and make sure that the returned errors
are properly dereferenced. Also append directory errors instead of overwriting
existing errors for the same path.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Both slices.Clone and maps.Clone already handles `nil` values, so we can
skip our own checks, making the code slightly more straightforward.

Also update GetSpecDirErrors to make sure we perform the copy after
obtaining a lock.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant