Skip to content

Commit

Permalink
Merge pull request #1241 from rhatdan/zstd
Browse files Browse the repository at this point in the history
PullOptions should work for rootless users also
  • Loading branch information
flouthoc authored May 17, 2022
2 parents 877a26a + b05b3b4 commit 6934beb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ type Store interface {
GraphRoot() string
GraphDriverName() string
GraphOptions() []string
PullOptions() map[string]string
UIDMap() []idtools.IDMap
GIDMap() []idtools.IDMap

Expand Down Expand Up @@ -607,6 +608,7 @@ type store struct {
graphRoot string
graphDriverName string
graphOptions []string
pullOptions map[string]string
uidMap []idtools.IDMap
gidMap []idtools.IDMap
autoUsernsUser string
Expand Down Expand Up @@ -726,6 +728,7 @@ func GetStore(options types.StoreOptions) (Store, error) {
additionalGIDs: nil,
usernsLock: usernsLock,
disableVolatile: options.DisableVolatile,
pullOptions: options.PullOptions,
}
if err := s.load(); err != nil {
return nil, err
Expand Down Expand Up @@ -776,6 +779,14 @@ func (s *store) GraphOptions() []string {
return s.graphOptions
}

func (s *store) PullOptions() map[string]string {
cp := make(map[string]string, len(s.pullOptions))
for k, v := range s.pullOptions {
cp[k] = v
}
return cp
}

func (s *store) UIDMap() []idtools.IDMap {
return copyIDMap(s.uidMap)
}
Expand Down
9 changes: 8 additions & 1 deletion store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestStore(t *testing.T) {
err = os.MkdirAll(wd, 0700)
require.NoError(t, err)

pullOpts := map[string]string{"Test1": "test1", "Test2": "test2"}
store, err := GetStore(StoreOptions{
RunRoot: filepath.Join(wd, "run"),
GraphRoot: filepath.Join(wd, "root"),
Expand All @@ -33,6 +34,7 @@ func TestStore(t *testing.T) {
HostID: os.Getgid(),
Size: 1,
}},
PullOptions: pullOpts,
})
require.NoError(t, err)

Expand All @@ -45,10 +47,15 @@ func TestStore(t *testing.T) {
root = store.GraphDriverName()
require.NotNil(t, root)

store.GraphOptions()
gopts := store.GraphOptions()
assert.Equal(t, []string{}, gopts)

store.UIDMap()
store.GIDMap()

opts := store.PullOptions()
assert.Equal(t, pullOpts, opts)

_, err = store.GraphDriver()
require.Nil(t, err)

Expand Down
1 change: 1 addition & 0 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func getRootlessStorageOpts(rootlessUID int, systemOpts StoreOptions) (StoreOpti
return opts, err
}
opts.RunRoot = rootlessRuntime
opts.PullOptions = systemOpts.PullOptions
if systemOpts.RootlessStoragePath != "" {
opts.GraphRoot, err = expandEnvPath(systemOpts.RootlessStoragePath, rootlessUID)
if err != nil {
Expand Down

0 comments on commit 6934beb

Please sign in to comment.