Skip to content

Commit

Permalink
code tesseract.CreateVolume
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroFruit authored and hea9549 committed Oct 20, 2018
1 parent 8478175 commit 9283261
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package tesseract

import (
"github.com/it-chain/tesseract/docker"
"github.com/it-chain/tesseract/pb"
"github.com/it-chain/tesseract/volume"
)

type ContainerID = string
Expand Down Expand Up @@ -85,3 +87,19 @@ type Port struct {
// Port exposed on the host
PublicPort int
}

type VolumeID = string

type Volume interface {
GetID() VolumeID
GetMountPoint() string
}

func CreateVolume(name string) (volume.Volume, error) {
res, err := docker.CreateVolume(name)
if err != nil {
return volume.Volume{}, err
}

return volume.NewVolume(res.CreatedAt, res.Driver, res.Mountpoint, res.Name, res.Options), nil
}
18 changes: 18 additions & 0 deletions volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,21 @@ type Volume struct {
Name string
Options map[string]string
}

func NewVolume(createdAt, driver, mountpoint, name string, opts map[string]string) Volume {
return Volume{
CreatedAt: createdAt,
Driver: driver,
Mountpoint: mountpoint,
Name: name,
Options: opts,
}
}

func (v Volume) GetID() string {
return v.Name
}

func (v Volume) GetMountPoint() string {
return v.Mountpoint
}

0 comments on commit 9283261

Please sign in to comment.