aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-24 18:21:40 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-24 18:21:40 +0100
commit0eccaf1a33f22230ddf87051e5eef01ac045b766 (patch)
tree63814267ad863069c539819831281ce2854b36f5 /lib
parent67a7d6e46143410a5fa9cfa2554023ab7687ea34 (diff)
Fixed SDK ID resolution for /exec api.
Diffstat (limited to 'lib')
-rw-r--r--lib/apiv1/exec.go1
-rw-r--r--lib/crosssdk/sdks.go13
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/apiv1/exec.go b/lib/apiv1/exec.go
index 2adb473..f61c5b2 100644
--- a/lib/apiv1/exec.go
+++ b/lib/apiv1/exec.go
@@ -339,6 +339,7 @@ func (s *APIService) execCmd(c *gin.Context) {
}
time.Sleep(time.Second)
}
+ s.log.Debugf("OK file are synchronized.")
}
// FIXME replace by .BroadcastTo a room
diff --git a/lib/crosssdk/sdks.go b/lib/crosssdk/sdks.go
index e3d6607..a3da184 100644
--- a/lib/crosssdk/sdks.go
+++ b/lib/crosssdk/sdks.go
@@ -65,20 +65,17 @@ func (s *SDKs) ResolveID(id string) (string, error) {
match := []string{}
for iid := range s.Sdks {
- fmt.Printf("SEB prefix iid=%v id=%v\n", iid, id)
if strings.HasPrefix(iid, id) {
match = append(match, iid)
- fmt.Printf(" SEB match (%d): %v\n", len(match), match)
}
}
- fmt.Printf("SEB match (%d): %v\n", len(match), match)
if len(match) == 1 {
return match[0], nil
} else if len(match) == 0 {
- return id, fmt.Errorf("Unknown id")
+ return id, fmt.Errorf("Unknown sdk id")
}
- return id, fmt.Errorf("Multiple IDs found with provided prefix: " + id)
+ return id, fmt.Errorf("Multiple sdk IDs found with provided prefix: " + id)
}
// Get returns an SDK from id
@@ -114,8 +111,10 @@ func (s *SDKs) GetEnvCmd(id string, defaultID string) []string {
s.mutex.Lock()
defer s.mutex.Unlock()
- if sdk, exist := s.Sdks[id]; exist {
- return sdk.GetEnvCmd()
+ if iid, err := s.ResolveID(id); err == nil {
+ if sdk, exist := s.Sdks[iid]; exist {
+ return sdk.GetEnvCmd()
+ }
}
if sdk, exist := s.Sdks[defaultID]; defaultID != "" && exist {