podman

Форк
0
/
volume_inspect.go 
79 строк · 2.0 Кб
1
//go:build !remote
2

3
package libpod
4

5
import (
6
	"fmt"
7

8
	"github.com/containers/podman/v5/libpod/define"
9
	pluginapi "github.com/docker/go-plugins-helpers/volume"
10
	"github.com/sirupsen/logrus"
11
)
12

13
// Inspect provides detailed information about the configuration of the given
14
// volume.
15
func (v *Volume) Inspect() (*define.InspectVolumeData, error) {
16
	if !v.valid {
17
		return nil, define.ErrVolumeRemoved
18
	}
19

20
	v.lock.Lock()
21
	defer v.lock.Unlock()
22

23
	if err := v.update(); err != nil {
24
		return nil, err
25
	}
26

27
	data := new(define.InspectVolumeData)
28

29
	data.Mountpoint = v.config.MountPoint
30
	if v.UsesVolumeDriver() {
31
		logrus.Debugf("Querying volume plugin %s for status", v.config.Driver)
32
		data.Mountpoint = v.state.MountPoint
33

34
		if v.plugin == nil {
35
			return nil, fmt.Errorf("volume %s uses volume plugin %s but it is not available, cannot inspect: %w", v.Name(), v.config.Driver, define.ErrMissingPlugin)
36
		}
37

38
		// Retrieve status for the volume.
39
		// Need to query the volume driver.
40
		req := new(pluginapi.GetRequest)
41
		req.Name = v.Name()
42
		resp, err := v.plugin.GetVolume(req)
43
		if err != nil {
44
			return nil, fmt.Errorf("retrieving volume %s information from plugin %s: %w", v.Name(), v.Driver(), err)
45
		}
46
		if resp != nil {
47
			data.Status = resp.Status
48
		}
49
	}
50

51
	data.Name = v.config.Name
52
	data.Driver = v.config.Driver
53
	data.CreatedAt = v.config.CreatedTime
54
	data.Labels = make(map[string]string)
55
	for k, v := range v.config.Labels {
56
		data.Labels[k] = v
57
	}
58
	data.Scope = v.Scope()
59
	data.Options = make(map[string]string)
60
	for k, v := range v.config.Options {
61
		data.Options[k] = v
62
	}
63
	data.UID = v.uid()
64
	data.GID = v.gid()
65
	data.Anonymous = v.config.IsAnon
66
	data.MountCount = v.state.MountCount
67
	data.NeedsCopyUp = v.state.NeedsCopyUp
68
	data.NeedsChown = v.state.NeedsChown
69
	data.StorageID = v.config.StorageID
70
	data.LockNumber = v.lock.ID()
71

72
	if v.config.Timeout != nil {
73
		data.Timeout = *v.config.Timeout
74
	} else if v.UsesVolumeDriver() {
75
		data.Timeout = v.runtime.config.Engine.VolumePluginTimeout
76
	}
77

78
	return data, nil
79
}
80

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.