1
0
mirror of https://github.com/moby/buildkit.git synced 2025-11-28 16:03:59 +03:00
Commit Graph

142 Commits

Author SHA1 Message Date
Tonis Tiigi
a372e4e65e client: enable git signature checks via policy
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-07 16:00:21 -08:00
Tonis Tiigi
81a79837c3 git: add signature verification to CacheKey and ResolveMetadata
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-22 10:12:10 -07:00
Tonis Tiigi
aade64489a git: test SSH signature verification
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-22 10:10:59 -07:00
Tonis Tiigi
7d8cd252c5 git: test PGP signature verification
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-22 10:10:59 -07:00
Tonis Tiigi
5f6a7ef751 source: add raw commit/tag object access to resolveMetadata
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-17 16:45:08 -07:00
Tonis Tiigi
a248127a90 git: separate remoteFetch from checkout for better reuse
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-17 16:45:08 -07:00
Tonis Tiigi
1cff633ba5 git: add resolvercache support to git source
Make sure remote ref does not change to different commit  if
git repo changes in the middle of the build.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-17 10:29:55 -07:00
Tonis Tiigi
7bb92310aa solver: add cleanup function to jobctx and pass through sources
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-13 17:39:53 -07:00
Tonis Tiigi
70e5929715 git: add git commit support to ResolveSourceMeta
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-13 07:59:09 -07:00
Tonis Tiigi
32cbdcd475 git: make Source struct public
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-13 07:59:08 -07:00
Tonis Tiigi
95762546cf git: fix potential difference between cache and snapshot
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-08 20:07:42 -07:00
Tonis Tiigi
9f5cf396f6 git: fix possible conflict on mutated branches
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-01 22:52:08 -07:00
Tonis Tiigi
d9183cb92e git: handle tag changes in upstream
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-01 10:43:56 -07:00
Tonis Tiigi
80c6fb96c4 git: allow checksum of annotated tag ref match either tag or commit sha
This is more flexible as from the user standpoint it might not
be easy to know if a version tag is annotated or not.

Downside of this change is that we can't create a cache key
automatically when checksum was set and no keep-git-dir as we
don't know which checksum is being used.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-30 12:57:14 -07:00
Tonis Tiigi
299b9cdd86 git: fix annotated tag pinning and cache keys
Pin of annotated tag should be tha SHA of tag, not
the commit it is pointing to.

Cache key of annotated tag should be SHA of the tag
if keep-git-dir is enabled and SHA of underlying
commit otherwise.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-30 12:22:08 -07:00
Tonis Tiigi
ef8e5f97db git: fix issue with checking out annotated tags by full ref
If tag was already pulled by --tags or without refs/tags
that creates ambigous reference in the shared repository.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-25 08:38:17 -07:00
Tonis Tiigi
4645296cb7 git: add sha256 commits support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-05 16:34:55 -07:00
Tianon Gravi
4bdec93057 git: partial integration tests for SHA-256
This fails in `gitSourceHandler` because it can't handle *both* SHA-1 and SHA-256 before Git 2.45 (see PR comments), and there's not a simple way to fix that without newer Git or larger refactoring.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-09-05 16:34:31 -07:00
Tonis Tiigi
3765fe3587 dockerfile: add submodules controls to git URLs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 22:31:40 -07:00
Tonis Tiigi
cf599d45ee git: fix subdir filter on submodule dir
Because subdir filter happened before the submodule update it
resulted in empty directory being filtered and submodule update
being skipped because .gitmodules was already missing.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-28 06:36:24 -07:00
Akihiro Suda
f8447d305c git url: rename GitURLFragment to GitURLOpts
No substantial code change.
Non-fragment data can be added in this structure too.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-06-05 15:12:44 +09:00
Tonis Tiigi
58f956b807 git: verify checksum early and more tests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-18 21:38:49 +09:00
Akihiro Suda
6cbf02ae5b git source: add AttrGitChecksum
Not integrated to util/giturl, as PR 5974 is not merged yet.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-05-18 21:38:45 +09:00
Tonis Tiigi
9fcedf9807 update gopls to go1.24 compatible version
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-07 18:23:20 -07:00
Tonis Tiigi
69d3d44145 lint: add unconvert
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:44:01 -07:00
Tonis Tiigi
f1f56c2b77 golangci-lint: v2 upgrade
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:17 -07:00
Jonathan A. Sternberg
66016a8c63 vendor: switch from idtools to moby/sys/user
Convert usages of `github.com/docker/docker/pkg/idtools` to
`github.com/moby/sys/user` in order to break the dependency between
buildkit and docker.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-02 10:22:02 -05:00
Tonis Tiigi
91b55e89e5 solver: fix reading secrets from any session
The current logic was incorrect in some places so that if first
session randomly chosen by `Any()` returned NotFound then other
sessions were not attempted.

For the main use case of mounting secrets as files the logic
was correct, but it was incorrect for example for the case of
adding secrets as environment variables.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-11 15:25:15 -07:00
Tonis Tiigi
b5286f8dcb apply x/tools/modernize fixes
Autogenerated with couple of manual patches.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-07 08:18:45 -08:00
Marat Radchenko
5be7edb69c Upgrade to containerd 2
Co-authored-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2025-01-13 16:42:48 -08:00
Sebastiaan van Stijn
698acd328f migrate to github.com/moby/sys/reexec
The github.com/docker/docker/pkg/reexec package was moved to
a separate module; migrate to use that module instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-18 21:11:07 +01:00
Marat Radchenko
0a5a80cfec Remove pre-Go 1.17 build tags
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-11-21 10:58:27 +03:00
Tonis Tiigi
44b1aca26a git: fix caching git commit through multiple refs
This fixes current issue when a Git commit is accessed
multiple times through different refs or ref is added
after commit has already been pulled once.

When keep-git-dir option is true, then program can
try to resolve the current reference via .git directory
and because old cache key was only the git commit, previous
.git directory can be reused without any refs inside.

There is no change to the behavior if keep-git-dir is
false as then requests through multiple refs yield to
identical content.

Only the reference in the user provided identifier is added
to the cache key, and that is the only one that can be
expected in .git because of the shallow fetches. We do not
do extra request to find named refs for a commit SHA if that is
provided in the identifier.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-23 16:59:22 -07:00
Justin Chadwell
90d2d8b1c6 git: allow cloning commit shas not referenced by branch/tag
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-10-22 11:38:04 +01:00
Justin Chadwell
ac3eb58262 git: export gitutil helper for identifying commit shas
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-10-21 14:19:54 +01:00
Justin Chadwell
ac7caa8f3b chore: use a better root for computing free disk space
We shouldn't use the cachemount root, we should actually properly
use the worker's specified root which is propagated from the config.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-09-25 10:49:52 +01:00
Tõnis Tiigi
734a6cc656 Merge pull request #5276 from slonopotamus/darwin
Add stub implementations to make buildkitd buildable for Darwin
2024-09-16 14:25:57 -07:00
Marat Radchenko
64f4631d8b Add stub implementations to make buildkitd build for Darwin
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-09-16 12:18:36 +03:00
Tonis Tiigi
610affa5fd exec: fix pruning cache mounts with parent ref on no-cache
On a build with no-cache, cache mounts were not pruned correctly
if the mount was on top of another ref. This also appeared in
Dockerfile when mode/uid/gid was set because implicit parent
ref is created in these cases in order to change the permissions
of a subdir that is used as a cache mount base.

Because it is not possible to know ahead of time what ref
will become the parent of cache mount during build, all cache
mounts matching the ID that have a parent will be pruned.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-09-05 18:09:54 -07:00
Marat Radchenko
c8c5024758 Cleanup Linux-isms in code
appdefaults_unix.go, constants_unix.go:
/run is a thing only for Linux. Other Unixes use /var/run.

diffapply_linux.go and source_linux.go:
These files use Linux-only API.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-08-26 11:21:12 +03:00
Tonis Tiigi
899cac1697 git: add file mode verification to tests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-02 22:41:07 -07:00
Tonis Tiigi
dff03a24fa git: fix pulling commit SHA only referenced from a tag
On commit SHA input we currently do a full fetch of
remote so we can pick up the commit by SHA later. This
only pulls in tags that are also part of branches. Extra
flag is needed to also get the tags that are not part of
branches.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-21 16:05:55 -07:00
Tonis Tiigi
4103099d94 ensure context.WithoutCancel in defer funcs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 19:18:32 -07:00
Tonis Tiigi
03c7a6d769 lint: fix some testifylint warnings
This does not cover all warning yet but split
into chunks to ease review.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-30 11:32:55 -07:00
Tonis Tiigi
1f9988911f lint: unusedparams fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:16 -07:00
Tonis Tiigi
8c4cdc8f43 lint: nilness fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-06 18:11:58 -07:00
CrazyMax
94e2370023 provenance: move types to a dedicated package
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-02-25 20:39:50 +01:00
Justin Chadwell
3c6f6e4ee1 chore: refactor IsGitTransport to avoid duplication
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-02-01 15:39:16 +00:00
Justin Chadwell
7eb8713972 Merge pull request #4473 from jedevc/fix-git-sha-conflict 2023-12-13 19:48:57 +00:00
Justin Chadwell
6a8d2ca2bd git: ensure that pin matches checked-out commit
Previously, it was very possible for the CacheKey function to return a
sha key that was *not* the checked out commit.

There are two cases that I've encountered where this can happen:
- An annotated tag will have the pin of the tag, and not the underlying
  commit, which will be HEAD after the checkout.
- If multiple tags have the same path component (e.g. "mytag" and
  "abc/mytag") then the first alphabetical tag will be selected when (in
  this case "abc/mytag").

To avoid this kind of case, we can't just search for a single match in
the results for ls-remote. There's no way to filter for just an exact
match, so we need to scan through the output ourselves. Additionally, we
need to dereference the annotated tags by also selecting refs ending in
"^{}" - which have the commit that the tag points at.

Finally, I've improved the test suite around this to check that:
- The cache-key pin is equivalent to the checked out commit
- We can check out non-master branches
- That full ref syntax like "refs/heads/<branch-name>" and
  "refs/tags/<tag-name>" (or even "refs/<anything>") can be used.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-12-13 10:06:42 +00:00