make SyncSourceResources exposed, so it can be used in Cloud version.
This commit is contained in:
parent
e8981ff9bb
commit
f67c369a22
|
@ -1,6 +1,7 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fastenhealth/fasten-sources/clients/factory"
|
"github.com/fastenhealth/fasten-sources/clients/factory"
|
||||||
sourceModels "github.com/fastenhealth/fasten-sources/clients/models"
|
sourceModels "github.com/fastenhealth/fasten-sources/clients/models"
|
||||||
|
@ -36,7 +37,7 @@ func CreateSource(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// after creating the source, we should do a bulk import
|
// after creating the source, we should do a bulk import
|
||||||
summary, err := syncSourceResources(c, logger, databaseRepo, sourceCred)
|
summary, err := SyncSourceResources(c, logger, databaseRepo, sourceCred)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
||||||
return
|
return
|
||||||
|
@ -59,7 +60,7 @@ func SourceSync(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// after creating the source, we should do a bulk import
|
// after creating the source, we should do a bulk import
|
||||||
summary, err := syncSourceResources(c, logger, databaseRepo, *sourceCred)
|
summary, err := SyncSourceResources(c, logger, databaseRepo, *sourceCred)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
||||||
return
|
return
|
||||||
|
@ -236,8 +237,7 @@ func RawRequestSource(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": resp})
|
c.JSON(http.StatusOK, gin.H{"success": true, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
////// private functions
|
func SyncSourceResources(c context.Context, logger *logrus.Entry, databaseRepo database.DatabaseRepository, sourceCred models.SourceCredential) (sourceModels.UpsertSummary, error) {
|
||||||
func syncSourceResources(c *gin.Context, logger *logrus.Entry, databaseRepo database.DatabaseRepository, sourceCred models.SourceCredential) (sourceModels.UpsertSummary, error) {
|
|
||||||
// after creating the source, we should do a bulk import
|
// after creating the source, we should do a bulk import
|
||||||
sourceClient, updatedSource, err := factory.GetSourceClient(sourcePkg.GetFastenEnv(), sourceCred.SourceType, c, logger, sourceCred)
|
sourceClient, updatedSource, err := factory.GetSourceClient(sourcePkg.GetFastenEnv(), sourceCred.SourceType, c, logger, sourceCred)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue