коммит произвёл
GitHub
родитель
668a2aa856
Коммит
64d12c08e9
@@ -3864,7 +3864,7 @@ func (s *OpenTracingLayerJobStore) UpdateStatusOptimistically(id string, current
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerLicenseStore) Get(id string) (*model.LicenseRecord, *model.AppError) {
|
||||
func (s *OpenTracingLayerLicenseStore) Get(id string) (*model.LicenseRecord, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "LicenseStore.Get")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -3882,7 +3882,7 @@ func (s *OpenTracingLayerLicenseStore) Get(id string) (*model.LicenseRecord, *mo
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, *model.AppError) {
|
||||
func (s *OpenTracingLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "LicenseStore.Save")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package sqlstore
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
|
||||
@@ -39,7 +39,7 @@ func (ls SqlLicenseStore) createIndexesIfNotExists() {
|
||||
// database it returns the license stored in the database. If not, it saves the
|
||||
// new database and returns the created license with the CreateAt field
|
||||
// updated.
|
||||
func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, *model.AppError) {
|
||||
func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) {
|
||||
license.PreSave()
|
||||
if err := license.IsValid(); err != nil {
|
||||
return nil, err
|
||||
@@ -50,13 +50,13 @@ func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseReco
|
||||
Where(sq.Eq{"Id": license.Id})
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlLicenseStore.Save", "store.sql.build_query.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrap(err, "license_tosql")
|
||||
}
|
||||
var storedLicense model.LicenseRecord
|
||||
if err := ls.GetReplica().SelectOne(&storedLicense, queryString, args...); err != nil {
|
||||
// Only insert if not exists
|
||||
if err := ls.GetMaster().Insert(license); err != nil {
|
||||
return nil, model.NewAppError("SqlLicenseStore.Save", "store.sql_license.save.app_error", nil, "license_id="+license.Id+", "+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to get License with licenseId=%s", license.Id)
|
||||
}
|
||||
return license, nil
|
||||
}
|
||||
@@ -66,13 +66,13 @@ func (ls SqlLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseReco
|
||||
// Get obtains the license with the provided id parameter from the database.
|
||||
// If the license doesn't exist it returns a model.AppError with
|
||||
// http.StatusNotFound in the StatusCode field.
|
||||
func (ls SqlLicenseStore) Get(id string) (*model.LicenseRecord, *model.AppError) {
|
||||
func (ls SqlLicenseStore) Get(id string) (*model.LicenseRecord, error) {
|
||||
obj, err := ls.GetReplica().Get(model.LicenseRecord{}, id)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlLicenseStore.Get", "store.sql_license.get.app_error", nil, "license_id="+id+", "+err.Error(), http.StatusInternalServerError)
|
||||
return nil, errors.Wrapf(err, "failed to get License with licenseId=%s", id)
|
||||
}
|
||||
if obj == nil {
|
||||
return nil, model.NewAppError("SqlLicenseStore.Get", "store.sql_license.get.missing.app_error", nil, "license_id="+id, http.StatusNotFound)
|
||||
return nil, store.NewErrNotFound("License", id)
|
||||
}
|
||||
return obj.(*model.LicenseRecord), nil
|
||||
}
|
||||
|
||||
@@ -493,8 +493,8 @@ type PreferenceStore interface {
|
||||
}
|
||||
|
||||
type LicenseStore interface {
|
||||
Save(license *model.LicenseRecord) (*model.LicenseRecord, *model.AppError)
|
||||
Get(id string) (*model.LicenseRecord, *model.AppError)
|
||||
Save(license *model.LicenseRecord) (*model.LicenseRecord, error)
|
||||
Get(id string) (*model.LicenseRecord, error)
|
||||
}
|
||||
|
||||
type TokenStore interface {
|
||||
|
||||
@@ -15,7 +15,7 @@ type LicenseStore struct {
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: id
|
||||
func (_m *LicenseStore) Get(id string) (*model.LicenseRecord, *model.AppError) {
|
||||
func (_m *LicenseStore) Get(id string) (*model.LicenseRecord, error) {
|
||||
ret := _m.Called(id)
|
||||
|
||||
var r0 *model.LicenseRecord
|
||||
@@ -27,20 +27,18 @@ func (_m *LicenseStore) Get(id string) (*model.LicenseRecord, *model.AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(id)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: license
|
||||
func (_m *LicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, *model.AppError) {
|
||||
func (_m *LicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) {
|
||||
ret := _m.Called(license)
|
||||
|
||||
var r0 *model.LicenseRecord
|
||||
@@ -52,13 +50,11 @@ func (_m *LicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(*model.LicenseRecord) *model.AppError); ok {
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*model.LicenseRecord) error); ok {
|
||||
r1 = rf(license)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
|
||||
@@ -3518,7 +3518,7 @@ func (s *TimerLayerJobStore) UpdateStatusOptimistically(id string, currentStatus
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerLicenseStore) Get(id string) (*model.LicenseRecord, *model.AppError) {
|
||||
func (s *TimerLayerLicenseStore) Get(id string) (*model.LicenseRecord, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.LicenseStore.Get(id)
|
||||
@@ -3534,7 +3534,7 @@ func (s *TimerLayerLicenseStore) Get(id string) (*model.LicenseRecord, *model.Ap
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (s *TimerLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, *model.AppError) {
|
||||
func (s *TimerLayerLicenseStore) Save(license *model.LicenseRecord) (*model.LicenseRecord, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
resultVar0, resultVar1 := s.LicenseStore.Save(license)
|
||||
|
||||
Ссылка в новой задаче
Block a user