Merge remote-tracking branch 'origin/master' into wip
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Fri, 17 Nov 2017 09:31:07 +0000 (10:31 +0100)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Fri, 17 Nov 2017 09:31:07 +0000 (10:31 +0100)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Conflicts:
Makefile
webapp/package.json

1  2 
lib/apiv1/exec.go

diff --combined lib/apiv1/exec.go
@@@ -19,8 -19,7 +19,8 @@@ type 
        // ExecArgs JSON parameters of /exec command
        ExecArgs struct {
                ID              string   `json:"id" binding:"required"`
 -              SdkID           string   `json:"sdkid"` // sdk ID to use for setting env
 +              SdkID           string   `json:"sdkID"` // sdk ID to use for setting env
 +              CmdID           string   `json:"cmdID"` // command unique ID
                Cmd             string   `json:"cmd" binding:"required"`
                Args            []string `json:"args"`
                Env             []string `json:"env"`
@@@ -105,19 -104,15 +105,19 @@@ func (s *APIService) execCmd(c *gin.Con
        }
  
        // Allow to pass id in url (/exec/:id) or as JSON argument
 -      id := c.Param("id")
 -      if id == "" {
 -              id = args.ID
 +      idArg := c.Param("id")
 +      if idArg == "" {
 +              idArg = args.ID
        }
 -      if id == "" {
 +      if idArg == "" {
                common.APIError(c, "Invalid id")
                return
        }
 -
 +      id, err := s.mfolders.ResolveID(idArg)
 +      if err != nil {
 +              common.APIError(c, err.Error())
 +              return
 +      }
        f := s.mfolders.Get(id)
        if f == nil {
                common.APIError(c, "Unknown id")
                }
        }
  
-       cmd = append(cmd, "cd", fld.GetFullPath(args.RPath))
+       cmd = append(cmd, "cd", "\""+fld.GetFullPath(args.RPath)+"\"")
        // FIXME - add 'exec' prevents to use syntax:
        //       xds-exec -l debug -c xds-config.env -- "cd build && cmake .."
        //  but exec is mandatory to allow to pass correctly signals
        }
  
        // Unique ID for each commands
 -      cmdID := strconv.Itoa(execCommandID)
 -      execCommandID++
 +      if args.CmdID == "" {
 +              args.CmdID = s.cfg.ServerUID[:18] + "_" + strconv.Itoa(execCommandID)
 +              execCommandID++
 +      }
  
        // Create new execution over WS context
 -      execWS := eows.New(strings.Join(cmd, " "), cmdArgs, sop, sess.ID, cmdID)
 +      execWS := eows.New(strings.Join(cmd, " "), cmdArgs, sop, sess.ID, args.CmdID)
        execWS.Log = s.log
  
        // Append client project dir to environment