Merge pull request #20 from 30x/fix-register
Ensure locally generated instance ID is noted for registration
diff --git a/apigee_sync.go b/apigee_sync.go
index 4826b0a..4e3d89c 100644
--- a/apigee_sync.go
+++ b/apigee_sync.go
@@ -289,6 +289,11 @@
}
token = oauthResp.AccessToken
+ if newInstanceID {
+ newInstanceID = false
+ updateApidInstanceInfo()
+ }
+
/*
* This stores the bearer token for any other plugin to
* consume.
diff --git a/data.go b/data.go
index 0eef7a3..2531c8d 100644
--- a/data.go
+++ b/data.go
@@ -251,6 +251,7 @@
} else {
// first start - no row, generate a UUID and store it
err = nil
+ newInstanceID = true
info.InstanceID = generateUUID()
db.Exec("INSERT INTO APID (instance_id) VALUES (?)", info.InstanceID)
diff --git a/init.go b/init.go
index 19f4a97..b96f681 100644
--- a/init.go
+++ b/init.go
@@ -34,6 +34,7 @@
events apid.EventsService
apidInfo apidInstanceInfo
apidPluginDetails string
+ newInstanceID bool
)
type apidInstanceInfo struct {