Use go module as dependency tool instead of glide
[src/xds/xds-server.git] / lib / xdsserver / apiv1-sdks.go
index ba32dc9..58154ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 "IoT.bzh"
+ * Copyright (C) 2017-2018 "IoT.bzh"
  * Author Sebastien Douheret <sebastien@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,9 +20,9 @@ package xdsserver
 import (
        "net/http"
 
+       common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git"
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/lib/xsapiv1"
        "github.com/gin-gonic/gin"
-       common "github.com/iotbzh/xds-common/golib"
-       "github.com/iotbzh/xds-server/lib/xsapiv1"
 )
 
 // getSdks returns all SDKs configuration
@@ -74,8 +74,13 @@ func (s *APIService) installSdk(c *gin.Context) {
                return
        }
 
-       sdk, err := s.sdks.Install(id, args.Filename, args.Force, args.Timeout, sess)
+       //increment lock xds counter: it will be decremented,
+       //when SDK is installed in file sdk.go in function ExitCB
+       //at line 308 or when install is aborted in following function
+       LockXdsUpdateCounter(s.Context, true)
+       sdk, err := s.sdks.Install(id, args.Filename, args.Force, args.Timeout, args.InstallArgs, sess)
        if err != nil {
+               LockXdsUpdateCounter(s.Context, false)
                common.APIError(c, err.Error())
                return
        }
@@ -103,6 +108,7 @@ func (s *APIService) abortInstallSdk(c *gin.Context) {
                return
        }
 
+       LockXdsUpdateCounter(s.Context, false)
        c.JSON(http.StatusOK, sdk)
 }
 
@@ -123,10 +129,12 @@ func (s *APIService) removeSdk(c *gin.Context) {
 
        s.Log.Debugln("Remove SDK id ", id)
 
+       LockXdsUpdateCounter(s.Context, true)
        delEntry, err := s.sdks.Remove(id, -1, sess)
        if err != nil {
                common.APIError(c, err.Error())
                return
        }
+       LockXdsUpdateCounter(s.Context, false)
        c.JSON(http.StatusOK, delEntry)
 }