Use go module as dependency tool instead of glide
[src/xds/xds-agent.git] / lib / agent / projects.go
index a2d8fe1..d316c20 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");
@@ -25,11 +25,12 @@ import (
        "strings"
        "time"
 
+       st "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/syncthing"
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/lib/xsapiv1"
+
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1"
+       common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git"
        "github.com/franciscocpg/reflectme"
-       "github.com/iotbzh/xds-agent/lib/syncthing"
-       "github.com/iotbzh/xds-agent/lib/xaapiv1"
-       common "github.com/iotbzh/xds-common/golib"
-       "github.com/iotbzh/xds-server/lib/xsapiv1"
        "github.com/syncthing/syncthing/lib/sync"
 )
 
@@ -54,6 +55,7 @@ func NewProjects(ctx *Context, st *st.SyncThing) *Projects {
 
 // Init Load Projects configuration
 func (p *Projects) Init(server *XdsServer) error {
+
        svrList := make(map[string]*XdsServer)
        // If server not set, load for all servers
        if server == nil {
@@ -75,6 +77,11 @@ func (p *Projects) Init(server *XdsServer) error {
                for _, prj := range xFlds {
                        newP := svr.FolderToProject(prj)
                        if _, err := p.createUpdate(newP, false, true); err != nil {
+                               // Don't consider that as an error (allow support config without CloudSync support)
+                               if p.Context.SThg == nil && strings.Contains(err.Error(), "Server doesn't support project type CloudSync") {
+                                       continue
+                               }
+
                                errMsg += "Error while creating project id " + prj.ID + ": " + err.Error() + "\n "
                                continue
                        }
@@ -246,14 +253,12 @@ func (p *Projects) createUpdate(newF xaapiv1.ProjectConfig, create bool, initial
        // Add to folders list
        p.projects[newPrj.ID] = &fld
 
-       // Force sync after creation
+       // Force sync to get an initial sync status
        // (need to defer to be sure that WS events will arrive after HTTP creation reply)
-       if create {
-               go func() {
-                       time.Sleep(time.Millisecond * 500)
-                       fld.Sync()
-               }()
-       }
+       go func() {
+               time.Sleep(time.Millisecond * 500)
+               fld.Sync()
+       }()
 
        return newPrj, nil
 }