fix: error unmarshal empty app config (#609)

This commit is contained in:
Pedro Nasser
2017-03-27 13:58:03 -03:00
committed by Travis Reeder
parent a036563b9f
commit 5761ce3499

View File

@@ -8,12 +8,12 @@ import (
"context"
"bytes"
"github.com/Sirupsen/logrus"
"github.com/iron-io/functions/api/datastore/internal/datastoreutil"
"github.com/iron-io/functions/api/models"
"github.com/lib/pq"
_ "github.com/lib/pq"
"bytes"
"github.com/iron-io/functions/api/datastore/internal/datastoreutil"
)
const routesTableCreate = `
@@ -185,8 +185,8 @@ func (ds *PostgresDatastore) GetApp(ctx context.Context, name string) (*models.A
Name: resName,
}
if err := json.Unmarshal([]byte(config), &res.Config); err != nil {
return nil, err
if len(config) > 0 {
json.Unmarshal([]byte(config), &res.Config)
}
return res, nil
@@ -295,7 +295,6 @@ func (ds *PostgresDatastore) InsertRoute(ctx context.Context, route *models.Rout
return err
})
if err != nil {
return nil, err
}
@@ -563,7 +562,6 @@ func (ds *PostgresDatastore) Get(ctx context.Context, key []byte) ([]byte, error
return []byte(value), nil
}
func (ds *PostgresDatastore) Tx(f func(*sql.Tx) error) error {
tx, err := ds.db.Begin()
if err != nil {