server: make ImageStore configurable
It's a bit odd to have ImageStore be part of the config and yet we don't allow people to modify it. However, leave it out of the commented version because it's currently unused. Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
cb7239caa6
commit
33f47d6a6b
4 changed files with 11 additions and 6 deletions
|
@ -68,6 +68,9 @@ selinux = {{ .SELinux }}
|
|||
pause = "{{ .Pause }}"
|
||||
`))
|
||||
|
||||
// TODO: Currently ImageDir isn't really used, so we haven't added it to this
|
||||
// template. Add it once the storage code has been merged.
|
||||
|
||||
// DefaultConfig returns the default configuration for ocid.
|
||||
func DefaultConfig() *server.Config {
|
||||
return &server.Config{
|
||||
|
@ -88,8 +91,8 @@ func DefaultConfig() *server.Config {
|
|||
SELinux: selinux.SelinuxEnabled(),
|
||||
},
|
||||
ImageConfig: server.ImageConfig{
|
||||
Pause: pausePath,
|
||||
ImageStore: filepath.Join(ocidRoot, "store"),
|
||||
Pause: pausePath,
|
||||
ImageDir: filepath.Join(ocidRoot, "store"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,9 @@ type ImageConfig struct {
|
|||
Pause string `toml:"pause"`
|
||||
|
||||
// ImageStore is the directory where the ocid image store will be stored.
|
||||
ImageStore string
|
||||
// TODO: This is currently not really used because we don't have
|
||||
// containers/storage integrated.
|
||||
ImageDir string `toml:"image_dir"`
|
||||
}
|
||||
|
||||
// tomlConfig is another way of looking at a Config, which is
|
||||
|
|
|
@ -59,10 +59,10 @@ func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.P
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err = os.Mkdir(filepath.Join(s.config.ImageStore, tr.StringWithinTransport()), 0755); err != nil {
|
||||
if err = os.Mkdir(filepath.Join(s.config.ImageDir, tr.StringWithinTransport()), 0755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dir, err := directory.NewReference(filepath.Join(s.config.ImageStore, tr.StringWithinTransport()))
|
||||
dir, err := directory.NewReference(filepath.Join(s.config.ImageDir, tr.StringWithinTransport()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ func New(config *Config) (*Server, error) {
|
|||
|
||||
utils.StartReaper()
|
||||
|
||||
if err := os.MkdirAll(config.ImageStore, 0755); err != nil {
|
||||
if err := os.MkdirAll(config.ImageDir, 0755); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue