Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ee7b6749f | ||
|
|
065c96042d | ||
|
|
964ead61f7 | ||
|
|
c36b4cdc1c | ||
|
|
261dfbd3cd | ||
|
|
f32c1bef30 | ||
|
|
5e248d85fe | ||
|
|
7ec4962301 | ||
|
|
6b7ddafa32 | ||
|
|
7ba1f0a5e8 | ||
|
|
18205b2e66 | ||
|
|
22baffabfb | ||
|
|
4a95b4b578 | ||
|
|
0fbe723485 | ||
|
|
e81f8c64cf | ||
|
|
802ce18a5e | ||
|
|
77244d4997 | ||
|
|
12b71a1777 | ||
|
|
1badb6b931 | ||
|
|
14221f778c | ||
|
|
a5ca7b230a | ||
|
|
3427a92d08 | ||
|
|
ef7c017e4c |
No files matched your search
@@ -1,41 +0,0 @@
|
||||
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
|
||||
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.24 git
|
||||
WORKDIR /build
|
||||
ARG version
|
||||
ENV version_env=$version
|
||||
ARG app_name
|
||||
ENV app_name_env=$app_name
|
||||
COPY . .
|
||||
ENV GOPROXY=https://repo-mirror.mos.ru/repository/go-public
|
||||
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
||||
|
||||
FROM dockerhub.mos.ru/mosos/arbat:15.5
|
||||
|
||||
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||
RUN echo "Europe/Moscow" > /etc/timezone
|
||||
|
||||
ARG UID=10001
|
||||
RUN useradd \
|
||||
--home "/nonexistent" \
|
||||
--shell "/sbin/nologin" \
|
||||
--no-create-home \
|
||||
--uid "${UID}" \
|
||||
--user-group \
|
||||
appuser
|
||||
|
||||
RUN mkdir -p /app/data
|
||||
RUN chown appuser:appuser /app/data
|
||||
VOLUME /app/data
|
||||
|
||||
USER appuser
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ARG app_name
|
||||
ENV app_name_env=$app_name
|
||||
COPY --from=builder main /app/$app_name_env
|
||||
COPY /conf/config.yml /app/config.yml
|
||||
COPY /conf/default_remote_config.json* /app/default_remote_config.json
|
||||
COPY /migrations /app/migrations
|
||||
|
||||
ENTRYPOINT /app/$app_name_env
|
||||
+1
-1
@@ -156,7 +156,7 @@ func (l Locator) Config() *Config {
|
||||
)
|
||||
configApiController := api.NewConfig(configApiService)
|
||||
|
||||
configSchemaApiService := apisvs.NewConfigSchema(configSchemaRepo, moduleRepo)
|
||||
configSchemaApiService := apisvs.NewConfigSchema(configSchemaRepo)
|
||||
configSchemaController := api.NewConfigSchema(configSchemaApiService)
|
||||
|
||||
controllers := routes.Controllers{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
### v3.8.0
|
||||
* Добавлен новый endpoint `config/schema/update_by_module_name` для обновления схемы модуля по его названию
|
||||
## v3.7.0
|
||||
* добавлены rqlite-автобэкапы и прокси-эндпоинт `/backup` для создания резервных копий
|
||||
* изменен таймаут ожидания лидера с 30 до 180 секунд
|
||||
|
||||
@@ -3,16 +3,14 @@ package api
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-config-service/domain"
|
||||
"isp-config-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||
"isp-config-service/domain"
|
||||
"isp-config-service/entity"
|
||||
)
|
||||
|
||||
type ConfigSchemaService interface {
|
||||
SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error)
|
||||
UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error
|
||||
}
|
||||
|
||||
type ConfigSchema struct {
|
||||
@@ -51,30 +49,3 @@ func (c ConfigSchema) SchemaByModuleId(ctx context.Context, request domain.GetBy
|
||||
return schema, nil
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateSchemaByModuleName
|
||||
// @Summary Метод обновления схемы конфигурации модуля
|
||||
// @Description Меняет схему конфигурации модуля на переданную
|
||||
// @Tags Схема
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body domain.UpdateSchemaRequest true "название модуля и схема конфига"
|
||||
// @Success 200 {object} any
|
||||
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден"
|
||||
// @Failure 500 {object} apierrors.Error
|
||||
// @Router /schema/update_by_module_name [POST]
|
||||
func (c ConfigSchema) UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error {
|
||||
err := c.service.UpdateSchemaByModuleName(ctx, request)
|
||||
switch {
|
||||
case errors.Is(err, entity.ErrModuleNotFound):
|
||||
return apierrors.NewBusinessError(
|
||||
domain.ErrorCodeModuleNotFound,
|
||||
"module not found",
|
||||
err,
|
||||
)
|
||||
case err != nil:
|
||||
return apierrors.NewInternalServiceError(err)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -235,16 +235,6 @@ definitions:
|
||||
- id
|
||||
- newConfigName
|
||||
type: object
|
||||
domain.UpdateSchemaRequest:
|
||||
properties:
|
||||
moduleName:
|
||||
type: string
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- moduleName
|
||||
- schema
|
||||
type: object
|
||||
domain.UpdateVariableRequest:
|
||||
properties:
|
||||
description:
|
||||
@@ -794,35 +784,6 @@ paths:
|
||||
summary: Метод получения схемы конфигурации модуля
|
||||
tags:
|
||||
- Схема
|
||||
/schema/update_by_module_name:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Меняет схему конфигурации модуля на переданную
|
||||
parameters:
|
||||
- description: название модуля и схема конфига
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.UpdateSchemaRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema: {}
|
||||
"400":
|
||||
description: '`errorCode: 2001` - модуль не найден'
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||
summary: Метод обновления схемы конфигурации модуля
|
||||
tags:
|
||||
- Схема
|
||||
/variable/all:
|
||||
post:
|
||||
consumes:
|
||||
|
||||
@@ -21,11 +21,6 @@ type GetByModuleNameRequest struct {
|
||||
ModuleName string `validate:"required"`
|
||||
}
|
||||
|
||||
type UpdateSchemaRequest struct {
|
||||
ModuleName string `validate:"required"`
|
||||
Schema json.RawMessage `validate:"required" swaggertype:"object"`
|
||||
}
|
||||
|
||||
type CreateUpdateConfigRequest struct {
|
||||
Id string
|
||||
Name string `validate:"required"`
|
||||
|
||||
@@ -69,24 +69,6 @@ func (r ConfigSchema) GetByModuleId(ctx context.Context, moduleId string) (*enti
|
||||
return selectRow[entity.ConfigSchema](ctx, r.db, query, args...)
|
||||
}
|
||||
|
||||
func (r ConfigSchema) UpdateByModuleId(ctx context.Context, moduleId string, data []byte) error {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.UpdateByModuleId")
|
||||
query, args, err := squirrel.Update(Table("config_schema")).
|
||||
Set("data", data).
|
||||
Set("updated_at", squirrel.Expr("unixepoch()")).
|
||||
Where(squirrel.Eq{"module_id": moduleId}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
_, err = r.db.Exec(ctx, query, args...)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "exec: %s", query)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//nolint:nilnil
|
||||
func selectRow[T any](ctx context.Context, db db.DB, query string, args ...interface{}) (*T, error) {
|
||||
var result T
|
||||
|
||||
@@ -133,10 +133,6 @@ func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
||||
Path: "config/schema/get_by_module_id",
|
||||
Inner: true,
|
||||
Handler: c.ConfigSchemaApi.SchemaByModuleId,
|
||||
}, {
|
||||
Path: "config/schema/update_by_module_name",
|
||||
Inner: true,
|
||||
Handler: c.ConfigSchemaApi.UpdateSchemaByModuleName,
|
||||
},
|
||||
// variables
|
||||
{
|
||||
|
||||
@@ -4,21 +4,18 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-config-service/domain"
|
||||
"isp-config-service/entity"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type ConfigSchema struct {
|
||||
schemaRepo SchemaRepo
|
||||
moduleRepo ModuleRepo
|
||||
}
|
||||
|
||||
func NewConfigSchema(schemaRepo SchemaRepo, moduleRepo ModuleRepo) ConfigSchema {
|
||||
func NewConfigSchema(schemaRepo SchemaRepo) ConfigSchema {
|
||||
return ConfigSchema{
|
||||
schemaRepo: schemaRepo,
|
||||
moduleRepo: moduleRepo,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,20 +39,3 @@ func (s ConfigSchema) SchemaByModuleId(ctx context.Context, moduleId string) (*d
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (s ConfigSchema) UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error {
|
||||
modules, err := s.moduleRepo.GetByNames(ctx, []string{request.ModuleName})
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "get modules by name")
|
||||
}
|
||||
if len(modules) == 0 {
|
||||
return entity.ErrModuleNotFound
|
||||
}
|
||||
|
||||
err = s.schemaRepo.UpdateByModuleId(ctx, modules[0].Id, request.Schema)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "update schema by module id")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -27,7 +27,6 @@ type BackendsRepo interface {
|
||||
type SchemaRepo interface {
|
||||
All(ctx context.Context) ([]entity.ConfigSchema, error)
|
||||
GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error)
|
||||
UpdateByModuleId(ctx context.Context, moduleId string, data []byte) error
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
|
||||
Reference in new issue
Block a user