Implement api
This commit is contained in:
1 parent
b2e34c00a4
commit
c6148a1c1c
16 files changed
+345
-43
No files matched your search
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type ConfigHistoryService interface {
|
||||
GetAllVersion(ctx context.Context, configId string) ([]domain.ConfigVersion, error)
|
||||
DeleteConfigVersion(ctx context.Context, id string) error
|
||||
GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error)
|
||||
Delete(ctx context.Context, id string) error
|
||||
}
|
||||
|
||||
type ConfigHistory struct {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
type ModuleService interface {
|
||||
Status(ctx context.Context) ([]domain.ModuleInfo, error)
|
||||
Delete(ctx context.Context, idList []string) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
@@ -39,7 +39,7 @@ func (c Module) GetModulesAggregatedInfo(ctx context.Context) ([]domain.ModuleIn
|
||||
return modulesInfo, nil
|
||||
}
|
||||
|
||||
// DeleteModules
|
||||
// DeleteModule
|
||||
// @Summary Метод удаления объектов модулей по идентификаторам
|
||||
// @Description Возвращает количество удаленных модулей
|
||||
// @Tags Модули
|
||||
@@ -49,12 +49,12 @@ func (c Module) GetModulesAggregatedInfo(ctx context.Context) ([]domain.ModuleIn
|
||||
// @Success 200 {object} domain.DeleteResponse
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /module/delete_module [POST]
|
||||
func (c Module) DeleteModules(ctx context.Context, identities []string) (*domain.DeleteResponse, error) {
|
||||
if len(identities) == 0 {
|
||||
return nil, apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "at least one id is required", nil)
|
||||
func (c Module) DeleteModule(ctx context.Context, identities []string) (*domain.DeleteResponse, error) {
|
||||
id, err := getSingleId(identities)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := c.service.Delete(ctx, identities)
|
||||
err = c.service.Delete(ctx, id)
|
||||
if err != nil {
|
||||
return nil, apierrors.NewInternalServiceError(err)
|
||||
}
|
||||
@@ -63,3 +63,13 @@ func (c Module) DeleteModules(ctx context.Context, identities []string) (*domain
|
||||
Deleted: len(identities),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getSingleId(identities []string) (string, error) {
|
||||
if len(identities) == 0 {
|
||||
return "", apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "at least one id is required", nil)
|
||||
}
|
||||
if len(identities) > 1 {
|
||||
return "", apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "accept only single identity", nil)
|
||||
}
|
||||
return identities[0], nil
|
||||
}
|
||||
+2
-3
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
"github.com/txix-open/isp-kit/rc/schema"
|
||||
)
|
||||
|
||||
type DeleteResponse struct {
|
||||
@@ -46,7 +45,7 @@ type Config struct {
|
||||
type ConfigVersion struct {
|
||||
Id string
|
||||
ConfigId string
|
||||
ConfigVersion int32
|
||||
ConfigVersion int
|
||||
Data json.RawMessage
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -55,7 +54,7 @@ type ConfigSchema struct {
|
||||
Id string
|
||||
Version string
|
||||
ModuleId string
|
||||
Schema schema.Schema
|
||||
Schema json.RawMessage
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"isp-config-service/entity/xtypes"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNoActiveConfig = errors.New("no active config")
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrConfigNotFound = errors.New("no active config")
|
||||
ErrModuleNotFound = errors.New("module not found")
|
||||
ErrSchemaNotFound = errors.New("config schema not found")
|
||||
ErrConfigNotFoundOrActive = errors.New("config not found or markers as active")
|
||||
)
|
||||
+53
-8
@@ -2,7 +2,6 @@ package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
@@ -51,14 +50,60 @@ func (r Config) GetActive(ctx context.Context, moduleId string) (*entity.Config,
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
result := entity.Config{}
|
||||
err = r.db.SelectRow(ctx, &result, query, args...)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, entity.ErrNoActiveConfig
|
||||
}
|
||||
return selectRow[entity.Config](ctx, r.db, query, args...)
|
||||
}
|
||||
|
||||
func (r Config) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error) {
|
||||
query, args, err := squirrel.Select("*").
|
||||
From(Table("config")).
|
||||
Where(squirrel.Eq{
|
||||
"module_id": moduleId,
|
||||
}).OrderBy("created_at desc").
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "select row: %s", query)
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
result := make([]entity.Config, 0)
|
||||
err = r.db.Select(ctx, &result, query, args...)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r Config) GetById(ctx context.Context, id string) (*entity.Config, error) {
|
||||
query, args, err := squirrel.Select("*").
|
||||
From(Table("config")).
|
||||
Where(squirrel.Eq{
|
||||
"id": id,
|
||||
}).ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
return selectRow[entity.Config](ctx, r.db, query, args...)
|
||||
}
|
||||
|
||||
func (r Config) DeleteNonActiveById(ctx context.Context, id string) (bool, error) {
|
||||
query, args, err := squirrel.Delete(Table("config")).
|
||||
Where(squirrel.Eq{
|
||||
"id": id,
|
||||
"active": "0",
|
||||
}).ToSql()
|
||||
if err != nil {
|
||||
return false, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
result, err := r.db.Exec(ctx, query, args...)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "exec: %s", query)
|
||||
}
|
||||
|
||||
affected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return false, errors.WithMessage(err, "get rows affected")
|
||||
}
|
||||
return affected > 0, nil
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-config-service/entity"
|
||||
"isp-config-service/service/rqlite/db"
|
||||
)
|
||||
|
||||
type ConfigHistory struct {
|
||||
db db.DB
|
||||
}
|
||||
|
||||
func NewConfigHistory(db db.DB) ConfigHistory {
|
||||
return ConfigHistory{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r ConfigHistory) GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error) {
|
||||
query := fmt.Sprintf(`select * from %s where config_id = ? order by version desc`, Table("config_history"))
|
||||
result := make([]entity.ConfigHistory, 0)
|
||||
err := r.db.Select(ctx, &result, query, configId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r ConfigHistory) Delete(ctx context.Context, id string) error {
|
||||
query := fmt.Sprintf(`delete from %s where id = ?`, Table("config_history"))
|
||||
_, err := r.db.Exec(ctx, query, id)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "exec: %s", query)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
@@ -48,3 +49,27 @@ func (r ConfigSchema) All(ctx context.Context) ([]entity.ConfigSchema, error) {
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r ConfigSchema) GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error) {
|
||||
query, args, err := squirrel.Select("*").
|
||||
From(Table("config_schema")).
|
||||
Where(squirrel.Eq{"module_id": moduleId}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
return selectRow[entity.ConfigSchema](ctx, r.db, query, args...)
|
||||
}
|
||||
|
||||
func selectRow[T any](ctx context.Context, db db.DB, query string, args ...interface{}) (*T, error) {
|
||||
var result T
|
||||
err := db.SelectRow(ctx, &result, query, args...)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "select row: %s", query)
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
@@ -80,13 +80,8 @@ func (r Module) GetByNames(ctx context.Context, names []string) ([]entity.Module
|
||||
}
|
||||
|
||||
func (r Module) GetById(ctx context.Context, id string) (*entity.Module, error) {
|
||||
result := entity.Module{}
|
||||
query := fmt.Sprintf("select * from %s where id = ?", Table("module"))
|
||||
err := r.db.SelectRow(ctx, &result, query, id)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "select row: %s", query)
|
||||
}
|
||||
return &result, nil
|
||||
return selectRow[entity.Module](ctx, r.db, query, id)
|
||||
}
|
||||
|
||||
func (r Module) All(ctx context.Context) ([]entity.Module, error) {
|
||||
@@ -99,9 +94,9 @@ func (r Module) All(ctx context.Context) ([]entity.Module, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r Module) Delete(ctx context.Context, idList []string) error {
|
||||
func (r Module) Delete(ctx context.Context, id string) error {
|
||||
query, args, err := squirrel.Delete(Table("module")).
|
||||
Where(squirrel.Eq{"id": idList}).
|
||||
Where(squirrel.Eq{"id": id}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "build query")
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
||||
}, {
|
||||
Path: "module/delete_module",
|
||||
Inner: true,
|
||||
Handler: c.ModuleApi.DeleteModules,
|
||||
Handler: c.ModuleApi.DeleteModule,
|
||||
}, {
|
||||
Path: "config/get_active_config_by_module_name",
|
||||
Inner: true,
|
||||
|
||||
+116
-1
@@ -2,19 +2,85 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/xeipuuv/gojsonschema"
|
||||
"isp-config-service/domain"
|
||||
"isp-config-service/entity"
|
||||
)
|
||||
|
||||
type ConfigRepo interface {
|
||||
GetActive(ctx context.Context, moduleId string) (*entity.Config, error)
|
||||
GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error)
|
||||
GetById(ctx context.Context, id string) (*entity.Config, error)
|
||||
DeleteNonActiveById(ctx context.Context, id string) (bool, error)
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
configRepo ConfigRepo
|
||||
moduleRepo ModuleRepo
|
||||
schemaRepo SchemaRepo
|
||||
}
|
||||
|
||||
func NewConfig(
|
||||
configRepo ConfigRepo,
|
||||
moduleRepo ModuleRepo,
|
||||
schemaRepo SchemaRepo,
|
||||
) Config {
|
||||
return Config{
|
||||
configRepo: configRepo,
|
||||
moduleRepo: moduleRepo,
|
||||
schemaRepo: schemaRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (c Config) GetActiveConfigByModuleName(ctx context.Context, moduleName string) (*domain.Config, error) {
|
||||
modules, err := c.moduleRepo.GetByNames(ctx, []string{moduleName})
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get config by module name")
|
||||
}
|
||||
if len(modules) == 0 {
|
||||
return nil, entity.ErrModuleNotFound
|
||||
}
|
||||
|
||||
moduleId := modules[0].Id
|
||||
config, err := c.configRepo.GetActive(ctx, moduleId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get active config")
|
||||
}
|
||||
if config == nil {
|
||||
return nil, entity.ErrConfigNotFound
|
||||
}
|
||||
|
||||
result := configToDto(*config, nil)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c Config) GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error) {
|
||||
configs, err := c.configRepo.GetByModuleId(ctx, moduleId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get configs by module id")
|
||||
}
|
||||
if len(configs) == 0 {
|
||||
return make([]domain.Config, 0), nil
|
||||
}
|
||||
|
||||
schema, err := c.schemaRepo.GetByModuleId(ctx, moduleId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get config schema by module id")
|
||||
}
|
||||
var jsonSchema []byte
|
||||
if schema != nil {
|
||||
jsonSchema = schema.Data
|
||||
}
|
||||
|
||||
result := make([]domain.Config, 0)
|
||||
for _, config := range configs {
|
||||
result = append(result, configToDto(config, jsonSchema))
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c Config) CreateUpdateConfig(ctx context.Context, moduleId string) (*domain.Config, error) {
|
||||
@@ -22,13 +88,62 @@ func (c Config) CreateUpdateConfig(ctx context.Context, moduleId string) (*domai
|
||||
}
|
||||
|
||||
func (c Config) GetConfigById(ctx context.Context, configId string) (*domain.Config, error) {
|
||||
config, err := c.configRepo.GetById(ctx, configId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get config by id")
|
||||
}
|
||||
if config == nil {
|
||||
return nil, entity.ErrConfigNotFound
|
||||
}
|
||||
|
||||
result := configToDto(*config, nil)
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c Config) MarkConfigAsActive(ctx context.Context, configId string) error {
|
||||
|
||||
}
|
||||
|
||||
func (c Config) DeleteConfigs(ctx context.Context, idList []string) error {
|
||||
func (c Config) DeleteConfig(ctx context.Context, configId string) error {
|
||||
deleted, err := c.configRepo.DeleteNonActiveById(ctx, configId)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "delete config")
|
||||
}
|
||||
if !deleted {
|
||||
return entity.ErrConfigNotFoundOrActive
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func configToDto(config entity.Config, schema []byte) domain.Config {
|
||||
valid := true
|
||||
if schema != nil {
|
||||
errors, _ := validateConfig(config.Data, schema)
|
||||
valid = len(errors) == 0
|
||||
}
|
||||
return domain.Config{
|
||||
Id: config.Id,
|
||||
Name: config.Name,
|
||||
ModuleId: config.ModuleId,
|
||||
Valid: valid,
|
||||
Data: config.Data,
|
||||
Version: config.Version,
|
||||
Active: bool(config.Active),
|
||||
CreatedAt: time.Time(config.CreatedAt),
|
||||
UpdatedAt: time.Time(config.UpdatedAt),
|
||||
}
|
||||
}
|
||||
|
||||
func validateConfig(config []byte, schema []byte) (map[string]string, error) {
|
||||
schemaLoader := gojsonschema.NewBytesLoader(schema)
|
||||
configLoader := gojsonschema.NewBytesLoader(config)
|
||||
result, err := gojsonschema.Validate(schemaLoader, configLoader)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "validate config")
|
||||
}
|
||||
details := map[string]string{}
|
||||
for _, resultError := range result.Errors() {
|
||||
details[resultError.Field()] = resultError.Description()
|
||||
}
|
||||
return details, nil
|
||||
}
|
||||
@@ -2,17 +2,52 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-config-service/domain"
|
||||
"isp-config-service/entity"
|
||||
)
|
||||
|
||||
type ConfigHistoryRepo interface {
|
||||
Delete(ctx context.Context, id string) error
|
||||
GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error)
|
||||
}
|
||||
|
||||
type ConfigHistory struct {
|
||||
repo ConfigHistoryRepo
|
||||
}
|
||||
|
||||
func (c ConfigHistory) GetAllVersion(ctx context.Context, configId string) ([]domain.ConfigVersion, error) {
|
||||
|
||||
func NewConfigHistory(repo ConfigHistoryRepo) ConfigHistory {
|
||||
return ConfigHistory{
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, id string) error {
|
||||
func (s ConfigHistory) GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error) {
|
||||
versions, err := s.repo.GetByConfigId(ctx, configId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get config versions")
|
||||
}
|
||||
|
||||
result := make([]domain.ConfigVersion, 0, len(versions))
|
||||
for _, version := range versions {
|
||||
result = append(result, domain.ConfigVersion{
|
||||
Id: version.Id,
|
||||
ConfigId: version.ConfigId,
|
||||
ConfigVersion: version.Version,
|
||||
Data: version.Data,
|
||||
CreatedAt: time.Time(version.CreatedAt),
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s ConfigHistory) Delete(ctx context.Context, id string) error {
|
||||
err := s.repo.Delete(ctx, id)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "delete config version")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -2,13 +2,40 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-config-service/domain"
|
||||
"isp-config-service/entity"
|
||||
)
|
||||
|
||||
type ConfigSchema struct {
|
||||
schemaRepo SchemaRepo
|
||||
}
|
||||
|
||||
func (c ConfigSchema) SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error) {
|
||||
func NewConfigSchema(schemaRepo SchemaRepo) ConfigSchema {
|
||||
return ConfigSchema{
|
||||
schemaRepo: schemaRepo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s ConfigSchema) SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error) {
|
||||
schema, err := s.schemaRepo.GetByModuleId(ctx, moduleId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get config schema")
|
||||
}
|
||||
if schema == nil {
|
||||
return nil, entity.ErrSchemaNotFound
|
||||
}
|
||||
|
||||
result := domain.ConfigSchema{
|
||||
Id: schema.Id,
|
||||
Version: schema.ModuleVersion,
|
||||
ModuleId: schema.ModuleId,
|
||||
Schema: schema.Data,
|
||||
CreatedAt: time.Time(schema.CreatedAt),
|
||||
UpdatedAt: time.Time(schema.UpdatedAt),
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import (
|
||||
|
||||
type ModuleRepo interface {
|
||||
All(ctx context.Context) ([]entity.Module, error)
|
||||
Delete(ctx context.Context, idList []string) error
|
||||
Delete(ctx context.Context, id string) error
|
||||
GetByNames(ctx context.Context, names []string) ([]entity.Module, error)
|
||||
}
|
||||
|
||||
type BackendsRepo interface {
|
||||
@@ -23,6 +24,7 @@ type BackendsRepo interface {
|
||||
|
||||
type SchemaRepo interface {
|
||||
All(ctx context.Context) ([]entity.ConfigSchema, error)
|
||||
GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error)
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
@@ -107,8 +109,8 @@ func (s Module) Status(ctx context.Context) ([]domain.ModuleInfo, error) {
|
||||
return moduleInfos, nil
|
||||
}
|
||||
|
||||
func (s Module) Delete(ctx context.Context, idList []string) error {
|
||||
err := s.moduleRepo.Delete(ctx, idList)
|
||||
func (s Module) Delete(ctx context.Context, id string) error {
|
||||
err := s.moduleRepo.Delete(ctx, id)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "delete modules")
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ func (s Service) OnModuleConfigSchema(
|
||||
}
|
||||
|
||||
config, err := s.configRepo.GetActive(ctx, moduleId)
|
||||
if errors.Is(err, entity.ErrNoActiveConfig) {
|
||||
if config == nil {
|
||||
md5Sum := md5.Sum([]byte(moduleId))
|
||||
initialConfigId := hex.EncodeToString(md5Sum[:])
|
||||
initialConfig := entity.Config{
|
||||
|
||||
@@ -118,6 +118,9 @@ func (s Service) notifyBackendsChanged(
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "get module by id")
|
||||
}
|
||||
if module == nil {
|
||||
return errors.Errorf("unknown module: %s", moduleId)
|
||||
}
|
||||
backends, err := s.backendRepo.GetByModuleId(ctx, moduleId)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "get backends by module id")
|
||||
|
||||
Reference in new issue
Block a user