Skip to content

Commit

Permalink
Added defaultpath for volume mounts (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
craig-willis authored and bodom0015 committed Jul 26, 2017
1 parent 1d31619 commit efabd4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 12 additions & 3 deletions apiserver/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1558,8 +1558,8 @@ func (s *Server) PostStack(w rest.ResponseWriter, r *rest.Request) {
if stackService.VolumeMounts == nil {
stackService.VolumeMounts = map[string]string{}
}
volPath := fmt.Sprintf("AppData/%s", s.getAppDataDir(stackService.Id))

volPath := s.getVolPath(&mount, stackService.Id)
stackService.VolumeMounts[volPath] = mount.MountPath
}
}
Expand Down Expand Up @@ -1710,7 +1710,7 @@ func (s *Server) PutStack(w rest.ResponseWriter, r *rest.Request) {
}

if len(fromPath) == 0 {
volPath := fmt.Sprintf("AppData/%s", s.getAppDataDir(stackService.Id))
volPath := s.getVolPath(&mount, stackService.Id)
stackService.VolumeMounts[volPath] = mount.MountPath
}
}
Expand All @@ -1723,7 +1723,7 @@ func (s *Server) PutStack(w rest.ResponseWriter, r *rest.Request) {

if found == 0 {
// Create a new temporary folder
volPath := fmt.Sprintf("AppData/%s", s.getAppDataDir(stackService.Id))
volPath := s.getVolPath(&mount, stackService.Id)
stackService.VolumeMounts[volPath] = mount.MountPath
}
}
Expand Down Expand Up @@ -3184,3 +3184,12 @@ func (s *Server) getAccountByEmail(email string) *api.Account {
}
return nil
}

// NDS-970
func (s *Server) getVolPath(mount *api.VolumeMount, ssid string) string {
if len(mount.DefaultPath) == 0 {
return fmt.Sprintf("AppData/%s", s.getAppDataDir(ssid))
} else {
return mount.DefaultPath
}
}
7 changes: 4 additions & 3 deletions apiserver/pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ type Port struct {
}

type VolumeMount struct {
Type MountType `json:"type"`
MountPath string `json:"mountPath"`
Default bool `json:"default"`
Type MountType `json:"type"`
MountPath string `json:"mountPath"`
Default bool `json:"default"`
DefaultPath string `json:"defaultPath"`
}

type MountType string
Expand Down

0 comments on commit efabd4f

Please sign in to comment.