summaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/sdk.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xdsserver/sdk.go')
-rw-r--r--lib/xdsserver/sdk.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/xdsserver/sdk.go b/lib/xdsserver/sdk.go
index 2736246..374fb12 100644
--- a/lib/xdsserver/sdk.go
+++ b/lib/xdsserver/sdk.go
@@ -64,9 +64,18 @@ type CrossSDK struct {
}
// ListCrossSDK List all available and installed SDK (call "db-dump" script)
-func ListCrossSDK(scriptDir string, log *logrus.Logger) ([]xsapiv1.SDK, error) {
+func ListCrossSDK(scriptDir string, update bool, log *logrus.Logger) ([]xsapiv1.SDK, error) {
sdksList := []xsapiv1.SDK{}
+ // First update sdk DB when requested
+ if update {
+ out, err := UpdateSDKDb(scriptDir, log)
+ if err != nil {
+ log.Errorf("SDK DB update failure (%v): %v", err, out)
+ return sdksList, fmt.Errorf("Error while updating SDK DB (%v)", err)
+ }
+ }
+
// Retrieve SDKs list and info
cmd := exec.Command(path.Join(scriptDir, scriptDbDump))
stdout, err := cmd.CombinedOutput()
@@ -111,6 +120,15 @@ func GetSDKInfo(scriptDir, url, filename, md5sum string, log *logrus.Logger) (xs
return sdk, nil
}
+// UpdateSDKDb Used db-update script to update SDK database
+func UpdateSDKDb(scriptDir string, log *logrus.Logger) (string, error) {
+ args := []string{}
+ cmd := exec.Command(path.Join(scriptDir, scriptDbUpdate), args...)
+ stdout, err := cmd.CombinedOutput()
+
+ return string(stdout), err
+}
+
// NewCrossSDK creates a new instance of CrossSDK
func NewCrossSDK(ctx *Context, sdk xsapiv1.SDK, scriptDir string) (*CrossSDK, error) {
s := CrossSDK{