@@ -3,6 +3,7 @@ package cmd
33import (
44 "fmt"
55 "os"
6+ "regexp"
67 "strings"
78 "time"
89
@@ -190,16 +191,20 @@ func (d *DryccCmd) AppLogs(appID string, lines int) error {
190191}
191192
192193// AppRun runs a one time command in the app.
193- func (d * DryccCmd ) AppRun (appID , command string ) error {
194+ func (d * DryccCmd ) AppRun (appID , command string , volumeVars [] string ) error {
194195 s , appID , err := load (d .ConfigFile , appID )
195196
196197 if err != nil {
197198 return err
198199 }
199200
200201 d .Printf ("Running '%s'...\n " , command )
202+ volumeMap , err := parseMount (volumeVars )
203+ //volumeObj := map[string]interface{}{
204+ // "volumes": volumeMap,
205+ //}
201206
202- out , err := apps .Run (s .Client , appID , command )
207+ out , err := apps .Run (s .Client , appID , command , volumeMap )
203208 if d .checkAPICompatibility (s .Client , err ) != nil {
204209 return err
205210 }
@@ -214,6 +219,21 @@ func (d *DryccCmd) AppRun(appID, command string) error {
214219 return nil
215220}
216221
222+ func parseMount (volumeVars []string ) (map [string ]interface {}, error ) {
223+ volumeMap := make (map [string ]interface {})
224+
225+ regex := regexp .MustCompile (`^([A-z_]+[A-z0-9_]*):([\s\S]*)$` )
226+ for _ , volume := range volumeVars {
227+ if regex .MatchString (volume ) {
228+ captures := regex .FindStringSubmatch (volume )
229+ volumeMap [captures [1 ]] = captures [2 ]
230+ } else {
231+ return nil , fmt .Errorf ("'%s' does not match the pattern 'key:var', ex: MODE:test" , volume )
232+ }
233+ }
234+ return volumeMap , nil
235+ }
236+
217237// AppDestroy destroys an app.
218238func (d * DryccCmd ) AppDestroy (appID , confirm string ) error {
219239 gitSession := false
0 commit comments