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:
Aleksa Sarai 2016-10-21 20:50:49 +11:00 committed by Aleksa Sarai
parent cb7239caa6
commit 33f47d6a6b
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4
4 changed files with 11 additions and 6 deletions

View file

@ -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"),
},
}
}

View file

@ -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

View file

@ -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
}

View file

@ -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
}