Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #662 from squeed/cri-vol
Browse files Browse the repository at this point in the history
CRI: Move volume override from MountPoint to Mount
  • Loading branch information
Casey Callendrello authored Oct 7, 2016
2 parents 4f35ecf + b6896b2 commit c204336
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
7 changes: 5 additions & 2 deletions schema/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,12 @@ func (al AppList) Get(name types.ACName) *RuntimeApp {

// Mount describes the mapping between a volume and the path it is mounted
// inside of an app's filesystem.
// The AppVolume is optional. If missing, the pod-level Volume of the
// same name shall be used.
type Mount struct {
Volume types.ACName `json:"volume"`
Path string `json:"path"`
Volume types.ACName `json:"volume"`
Path string `json:"path"`
AppVolume *types.Volume `json:"appVolume,omitempty"`
}

func (r Mount) assertValid() error {
Expand Down
9 changes: 3 additions & 6 deletions schema/types/mountpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ import (
)

// MountPoint is the application-side manifestation of a Volume.
// The Volume is optional. If missing, the pod-level Volume of the
// same name shall be used
type MountPoint struct {
Name ACName `json:"name"`
Path string `json:"path"`
ReadOnly bool `json:"readOnly,omitempty"`
Volume *Volume `json:"volume,omitempty"`
Name ACName `json:"name"`
Path string `json:"path"`
ReadOnly bool `json:"readOnly,omitempty"`
}

func (mount MountPoint) assertValid() error {
Expand Down
12 changes: 7 additions & 5 deletions schema/types/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ func (v Volume) String() string {
// Example volume parameters:
// database,kind=host,source=/tmp,readOnly=true,recursive=true
func VolumeFromString(vp string) (*Volume, error) {
var vol Volume

vp = "name=" + vp
vpQuery, err := common.MakeQueryString(vp)
if err != nil {
Expand All @@ -168,7 +166,12 @@ func VolumeFromString(vp string) (*Volume, error) {
if err != nil {
return nil, err
}
for key, val := range v {
return VolumeFromParams(v)
}

func VolumeFromParams(params map[string][]string) (*Volume, error) {
var vol Volume
for key, val := range params {
val := val
if len(val) > 1 {
return nil, fmt.Errorf("label %s with multiple values %q", key, val)
Expand Down Expand Up @@ -218,8 +221,7 @@ func VolumeFromString(vp string) (*Volume, error) {

maybeSetDefaults(&vol)

err = vol.assertValid()
if err != nil {
if err := vol.assertValid(); err != nil {
return nil, err
}

Expand Down

0 comments on commit c204336

Please sign in to comment.