Skip to content

Commit

Permalink
Support configuring ownership (almost) everywhere (#4932)
Browse files Browse the repository at this point in the history
* support configuring ownership for file/dir mounts

TODO: the other types of mounts

Signed-off-by: Alex Suraci <alex@dagger.io>

* Container: support uid/gid for copy operations

* WithFile
* WithDirectory
* WithNewFile

Signed-off-by: Alex Suraci <alex@dagger.io>

* Container.WithMountedCache: support owner

Signed-off-by: Alex Suraci <alex@dagger.io>

* support configuring secret/socket owner

Signed-off-by: Alex Suraci <alex@dagger.io>

* appease linter

Signed-off-by: Alex Suraci <alex@dagger.io>

* resolve UID/GID in one solve instead of two

Signed-off-by: Alex Suraci <alex@dagger.io>

* remove TODOs

I'm not sure these are worth exposing; let's wait for a use case to come
up.

Signed-off-by: Alex Suraci <alex@dagger.io>

* fix up WithNewFileOwner test

Signed-off-by: Alex Suraci <alex@dagger.io>

* add scalar FilesystemOwner type

Signed-off-by: Alex Suraci <alex@dagger.io>

* Revert "add scalar FilesystemOwner type"

nevermind. too much trouble for too little benefit.

This reverts commit 908576434819e457e6d7ad51ab1a18078eb13732.

Signed-off-by: Alex Suraci <alex@dagger.io>

* container content inherits current user as owner

Signed-off-by: Alex Suraci <alex@dagger.io>

* avoid uid/gid remapping for tmpfs mounts

Signed-off-by: Alex Suraci <alex@dagger.io>

* don't apply uid/gid stuff on Windows

Signed-off-by: Alex Suraci <alex@dagger.io>

* fix setting subdir as rootfs

Signed-off-by: Alex Suraci <alex@dagger.io>

* mark chown vertex as internal

Signed-off-by: Alex Suraci <alex@dagger.io>

* fix writing to subdirectory of container

Previously WithRootFS would ignore the given directory's relative path,
which was necessary for this to work. Now we'll explicitly repoint the
directory to /. Updated naming along the way.

Signed-off-by: Alex Suraci <alex@dagger.io>

* clearer custom name

Signed-off-by: Alex Suraci <alex@dagger.io>

* disable dupl and gosec linters for tests

Signed-off-by: Alex Suraci <alex@dagger.io>

* don't inherit container user as file/dir owner

Signed-off-by: Alex Suraci <alex@dagger.io>

* remove 'Owner' mount field, process them at mount time instead

I think this was originally done so it can be inherited at runtime, but
that's no longer necessary, and it required "re-writing" container
mounts at WithExec time which seemed strange.

also remove Container.WithUser now that we don't need to do anything
special there anymore

Signed-off-by: Alex Suraci <alex@dagger.io>

* resolve socket/secret ownership before WithExec

Signed-off-by: Alex Suraci <alex@dagger.io>

* tidy up leftover cruft/unneeded changes

Signed-off-by: Alex Suraci <alex@dagger.io>

* preserve dir mode when changing ownership

Signed-off-by: Alex Suraci <alex@dagger.io>

* improve cache mount owner docs

Signed-off-by: Alex Suraci <alex@dagger.io>

* fixup comment

Signed-off-by: Alex Suraci <alex@dagger.io>

---------

Signed-off-by: Alex Suraci <alex@dagger.io>
  • Loading branch information
vito committed Apr 21, 2023
1 parent 71054e3 commit 48fb31d
Show file tree
Hide file tree
Showing 13 changed files with 1,341 additions and 129 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ linters:
- unused
- unused
- whitespace

issues:
exclude-rules:
- path: _test\.go
linters:
- dupl
- gosec
Loading

0 comments on commit 48fb31d

Please sign in to comment.