server: ensure /var/lib/ocid/images exists
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
fc3b7b5aae
commit
c5d0f23e5a
2 changed files with 10 additions and 3 deletions
|
@ -3,6 +3,7 @@ package server
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/containers/image/directory"
|
"github.com/containers/image/directory"
|
||||||
"github.com/containers/image/image"
|
"github.com/containers/image/image"
|
||||||
|
@ -52,11 +53,11 @@ func (s *Server) PullImage(ctx context.Context, req *pb.PullImageRequest) (*pb.P
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// TODO: make sure this dir exists?
|
|
||||||
if err := os.Mkdir("/var/lib/ocid/images/"+tr.StringWithinTransport(), 0755); err != nil {
|
if err := os.Mkdir(filepath.Join(imageStore, tr.StringWithinTransport()), 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dir, err := directory.NewReference("/var/lib/ocid/images/" + tr.StringWithinTransport())
|
dir, err := directory.NewReference(filepath.Join(imageStore, tr.StringWithinTransport()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/mrunalp/ocid/oci"
|
"github.com/mrunalp/ocid/oci"
|
||||||
"github.com/mrunalp/ocid/utils"
|
"github.com/mrunalp/ocid/utils"
|
||||||
|
@ -9,6 +10,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
runtimeAPIVersion = "v1alpha1"
|
runtimeAPIVersion = "v1alpha1"
|
||||||
|
imageStore = "/var/lib/ocid/images"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server implements the RuntimeService and ImageService
|
// Server implements the RuntimeService and ImageService
|
||||||
|
@ -26,6 +28,10 @@ func New(runtimePath, sandboxDir, containerDir string) (*Server, error) {
|
||||||
return nil, fmt.Errorf("failed to set server as subreaper: %v", err)
|
return nil, fmt.Errorf("failed to set server as subreaper: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(imageStore, 0755); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
r, err := oci.New(runtimePath, containerDir)
|
r, err := oci.New(runtimePath, containerDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue