94 Commits
Author SHA1 Message Date
ziminis d241c0356e MSP-8299 - move test 2026-11-27 19:14:59 +07:00
ziminis a2e6e48c46 MSP-8299 - up dependencies 2026-11-27 18:51:09 +07:00
ziminis a5b4f13300 MSP-8299 - linter fix 2026-11-27 18:51:03 +07:00
ziminis 16462eeace MSP-8299 - up dependencies and Go to v1.27 2026-11-27 17:15:14 +07:00
ziminis e7e7f05e66 MSP-8299 - up version to v3.4.0 2026-11-27 17:13:23 +07:00
ziminis af75a06f9e MSP-8299 - add new command - config audit 2026-11-27 17:07:39 +07:00
komissarovyv 7670e2bfe8 Increase timeout 2026-01-27 18:09:42 +03:00
komissarovyv a42a15d6d6 Fix -o flag 2025-11-01 13:35:00 +03:00
komissarovyv 915faf6210 Edit Dockerfile.dit 2025-06-23 16:38:35 +03:00
Кузьмин Игорь Александрович 3193de8d17 Edit README.md 2025-04-25 12:56:58 +00:00
Кузьмин Игорь Александрович b08dc73390 Replace .gitlab-ci.yml 2025-04-25 11:56:51 +00:00
komissarovyv f6e45d7212 Merge branch 'MSP-5014' into 'main'
Resolve MSP-5014

Closes MSP-5014

See merge request isp/ispctl!1
2025-03-24 11:59:50 +00:00
Синельник Тимур Романович 945e9f99f3 MSP-5014 Bump version to 3.3.0 2025-03-24 14:41:21 +03:00
Синельник Тимур Романович c5394b9793 MSP-5014 Up alpine version to 3.21 2025-03-24 14:41:21 +03:00
Синельник Тимур Романович 7138f0c855 MSP-5014 Bump go version to 1.24 2025-03-24 11:31:56 +03:00
Синельник Тимур Романович 8c49ae85ed MSP-5014 Refactor utils 2025-03-24 11:30:39 +03:00
Синельник Тимур Романович 7c01299e53 MSP-5014 Update errors in readVariablesFromCsv 2025-03-24 11:30:39 +03:00
Синельник Тимур Романович 533f2da29a MSP-5014 Remove flag package 2025-03-24 11:30:39 +03:00
Синельник Тимур Романович c267b1ae6e MSP-5014 Try get rid of global service and autocomplete 2025-03-24 11:30:39 +03:00
Синельник Тимур Романович 84f639a9d3 MSP-5014 Add handling apierrors in handleCreateUpdateConfigError 2025-03-24 11:30:38 +03:00
Синельник Тимур Романович 12f420400f MSP-5014 Update readme 2025-03-21 10:08:25 +03:00
Синельник Тимур Романович 043ecd7672 MSP-5014 Remove unnecessary fmt.Sprintf call 2025-03-21 10:08:25 +03:00
Синельник Тимур Романович befbd51522 MSP-5014 Use raw string for regex 2025-03-21 10:08:25 +03:00
Синельник Тимур Романович 418c4e757f MSP-5014 Rename entity to model 2025-03-21 10:08:25 +03:00
Синельник Тимур Романович 69319f0d2b MSP-5014 Update error handling in config repo 2025-03-21 10:08:25 +03:00
Синельник Тимур Романович 0005f1ac0c MSP-5014 CheckGlobal to ApplyGlobalFlags 2025-03-20 18:21:56 +03:00
Синельник Тимур Романович ff2922cf1e MSP-5014 Replace call flag.CheckGlobal(ctx) by calling Before 2025-03-20 18:17:59 +03:00
Синельник Тимур Романович 5dbd07dc03 MSP-5014 Refactor service and repository 2025-03-20 18:12:55 +03:00
Синельник Тимур Романович 599fa22429 MSP-5014 Move flag package to command 2025-03-20 18:12:19 +03:00
Синельник Тимур Романович 24a6522d57 MSP-5014 interface{} -> any 2025-03-20 17:35:46 +03:00
Синельник Тимур Романович da38973037 MSP-5014 Refactor config service 2025-03-20 13:06:52 +03:00
Синельник Тимур Романович 8f74edd7c8 MSP-5014 Add vars commands 2025-03-19 19:43:11 +03:00
komissarovyv e264da7a9f MSP-5014 bump dependencies 2025-03-12 10:32:38 +03:00
komissarovyv 8889dce37c MSP-5014 remove common configs api 2025-03-12 10:31:13 +03:00
Кузьмин Игорь Александрович 2cb3a54d2c Update Dockerfile.dit 2024-12-28 11:08:34 +00:00
Кузьмин Игорь Александрович d80ff0f277 Upload New File 2024-12-28 09:14:58 +00:00
Кузьмин Игорь Александрович 7672655c5d Upload New File 2024-12-28 09:14:24 +00:00
komissarovyv 4bd6226cc5 Add jq 2024-10-30 14:39:32 +03:00
komissarovyv ed11390873 Fix Dockerfile 2024-10-30 14:20:46 +03:00
komissarovyv 0a23b8ef0f Add dockerfile 2024-10-30 14:06:52 +03:00
komissarovyv 61f240317a Bump dependencies 2024-09-02 17:20:01 +03:00
d1slike f30d60adb1 Change help text 2024-05-31 20:29:47 +03:00
d1slike bc5555706d Add tag support 2024-05-31 20:14:06 +03:00
d1slike 7e9513f98b Remove unused fields 2024-05-16 17:11:46 +03:00
d1slike 091ad54010 Upgrade dependencies 2023-10-27 19:46:05 +03:00
d1slike 9bd5050ca8 Update readme 2023-06-13 11:15:43 +03:00
d1slike eea70f22e6 Update readme 2023-06-13 11:10:53 +03:00
d1slike 852b1813d9 Add config 2023-06-09 17:28:41 +03:00
d1slike df259e3f78 Reimplement 2023-06-09 17:25:12 +03:00
Мержанов Максим Владимирович d4d7c679aa Merge branch '__deps' into 'master'
Update dependencies

See merge request integration-system/isp-ctl!5
2021-05-17 15:36:56 +00:00
Egor Kiryushchenko c10d83d24a Update dependencies 2021-05-17 16:11:37 +03:00
Maxim Merzhanov f8859d17d0 update gateHost flag description and fix doc typos 2021-03-31 14:57:05 +03:00
Мержанов Максим Владимирович 4f0254ac1d Merge branch '__deps' into 'master'
Update dependencies

See merge request integration-system/isp-ctl!4
2021-01-27 18:15:44 +03:00
Egor Kiryushchenko baf495e62a Update dependencies 2021-01-27 18:13:47 +03:00
Максим Мержанов e469ba1bc7 Merge branch '__deps' into 'master'
Update dependencies

See merge request integration-system/isp-ctl!3
2020-11-24 14:22:37 +03:00
Егор Кирющенко 501123df34 Update dependencies 2020-11-24 14:22:37 +03:00
d1slike 3eeb933231 fix json output 2020-06-03 13:27:40 +03:00
DeniskaRediska b65cda4099 fix output '\u0026' instead '&' 2020-02-21 18:01:28 +03:00
Jenkins Automation Server 4e6477f213 Update dependencies 2020-01-09 19:25:11 +03:00
yan komissarov 690e9d6f44 Merge branch 'update_status' into 'master'
Update status

See merge request integration-system/isp-ctl!1
2019-12-27 17:34:43 +03:00
DeniskaRediska 01bed4d730 update readme 2019-12-27 17:12:15 +03:00
DeniskaRediska 51f6ed4c70 add output format for status 2019-12-27 16:38:55 +03:00
ykomissarov 63735cde1d change default port 2019-12-18 13:52:36 +03:00
ykomissarov 7949886c25 init 2019-12-18 13:04:47 +03:00
ykomissarov 19dac734af change default default config 2019-12-18 12:48:41 +03:00
ykomissarov 9f76de2a11 print module version in status command 2019-12-18 12:45:06 +03:00
ykomissarov 838c576e99 read configuration from stdin till EOF 2019-11-21 12:00:12 +03:00
ykomissarov 71435c1d67 Merge remote-tracking branch 'origin/common_configs' 2019-11-21 11:59:19 +03:00
DeniskaRediska 5f219e9f0d change validation schema 2019-10-31 16:58:34 +03:00
DeniskaRediska cf23b95af1 ref 2019-10-30 19:06:32 +03:00
DeniskaRediska 8b8815d2f2 add 'contain' command for common configs
add flag 'full' for 'get' command
update bash complete
2019-10-30 14:58:50 +03:00
DeniskaRediska 1a3458ebdd update(ref bash complete) 2019-10-29 18:06:41 +03:00
DeniskaRediska 93071eef5b add(commands for common configs) 2019-10-29 16:47:21 +03:00
Yan 887f166f30 Merge pull request #1 from integration-system/common_configs
migrate invoke from convert to config
2019-10-28 15:58:21 +03:00
DeniskaRediska 19c02ef270 migrate invoke to config service 2019-10-28 15:49:09 +03:00
ykomissarov b0c9d73755 read configuration from stdin till EOF 2019-10-25 12:13:46 +03:00
ykomissarov ec6e1f5f43 read configuration from stdin till EOF 2019-10-25 12:12:17 +03:00
ykomissarov 2893166bde fix 2019-09-09 14:28:28 +03:00
DeniskaRediska 6186eb2786 update(script schema response to html) 2019-09-06 18:31:00 +03:00
DeniskaRediska 245686ec71 add(scripts) 2019-09-06 18:02:42 +03:00
DeniskaRediska 91fed9c763 fix(stack overflow) 2019-08-27 15:24:41 +03:00
DeniskaRediska e5587f043a update lib 2019-08-23 16:46:31 +03:00
DeniskaRediska d1558438cf fix(bash complete) 2019-08-23 16:00:00 +03:00
DeniskaRediska 6155ebf062 add(bash script) 2019-08-22 11:16:41 +03:00
DeniskaRediska 1f794377e5 add(bash complete) 2019-08-21 19:10:24 +03:00
DeniskaRediska f32d9a80b0 add(new command schema) 2019-08-21 14:32:58 +03:00
DeniskaRediska fcafab05d1 change(rename unsafe flag) 2019-07-26 15:40:35 +03:00
DeniskaRediska c8d028fcd4 add(checking schema to set configuration and unsafe flag) 2019-07-26 15:31:33 +03:00
d1slike 3543ded23e fix spaces in strings 2019-07-24 20:55:50 +03:00
d1slike c9751c9d51 fix spaces in strings 2019-07-24 20:53:56 +03:00
DeniskaRediska 8e205bb9fd update lib 2019-07-17 14:45:58 +03:00
DeniskaRediska 4a779eef9f update(readme) 2019-07-17 14:43:23 +03:00
DeniskaRediska a54239f971 add(readme) 2019-07-17 14:01:02 +03:00
DeniskaRediska 9078060e65 Init 2019-07-17 11:14:17 +03:00
46 changed files with 1824 additions and 1355 deletions

No files matched your search

+3 -22
View File
@@ -1,23 +1,4 @@
docker-build: include:
image: docker:latest - project: '$CI_PROJECT_PATH'
stage: build file: '/ci-isp-utils.yml'
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- export VERSION=`cat .version `
- echo $VERSION
- echo $CI_DOCKER_FILE
- echo $CI_REGISTRY
script:
- set
- mkdir -p migrations
- docker build -f "$CI_DOCKER_FILE" --force-rm --build-arg="version=$VERSION" --build-arg="app_name=$CI_PROJECT_NAME" --pull -t "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" .
- |
docker tag "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION" "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
docker push "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:$VERSION"
docker rmi -f "$CI_REGISTRY/$CI_PROJECT_NAME:latest"
- docker logout $CI_REGISTRY
+1 -1
View File
@@ -1 +1 @@
3.2.1 3.4.0
+8
View File
@@ -1,3 +1,11 @@
### v3.4.0
* Добавлена команда `config audit` — отчёт по legacy: SECRET-переменные, referenced в UI-экспонируемых полях активных конфигураций (тег `x-ui-exposed` в схеме); код выхода `1` при нарушениях
### v3.3.1
* увеличены таймауты обращения к `isp-config-service`
### v3.3.0
* Добавлены команды `vars get`, `vars list`, `vars set`, `vars delete`, `vars upload`
* Обновлены зависимости
* Обновлена версия Go до `1.24`
### v3.2.1 ### v3.2.1
* обновлены зависимости * обновлены зависимости
### v3.2.0 ### v3.2.0
+2 -2
View File
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine3.20 as builder FROM golang:1.24-alpine3.21 as builder
WORKDIR /build WORKDIR /build
ARG version ARG version
ENV version_env=$version ENV version_env=$version
@@ -13,7 +13,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,target=. \ --mount=type=bind,target=. \
go build -ldflags="-X 'main.version=$version_env'" -o /main . go build -ldflags="-X 'main.version=$version_env'" -o /main .
FROM alpine:3.20 FROM alpine:3.21
RUN apk add --no-cache tzdata bash-completion jq RUN apk add --no-cache tzdata bash-completion jq
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
+1 -1
View File
@@ -1,5 +1,5 @@
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.23 git RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.24 git
WORKDIR /build WORKDIR /build
ARG version ARG version
ENV version_env=$version ENV version_env=$version
+175 -6
View File
@@ -15,7 +15,13 @@
- [ispctl schema](#ispctl-schema) - [ispctl schema](#ispctl-schema)
- [ispctl merge](#ispctl-merge) - [ispctl merge](#ispctl-merge)
- [ispctl gitget](#ispctl-gitget) - [ispctl gitget](#ispctl-gitget)
- [ispctl config audit](#ispctl-config-audit)
- [ispctl vars](#ispctl-vars)
- [ispctl vars get](#ispctl-vars-get)
- [ispctl vars list](#ispctl-vars-list)
- [ispctl vars set](#ispctl-vars-set)
- [ispctl vars delete](#ispctl-vars-delete)
- [ispctl vars upload](#ispctl-vars-upload)
## Требования ## Требования
* Linux * Linux
@@ -32,12 +38,18 @@ ispctl [flag...] get module_name property_path [local_flag]
ispctl [flag...] set module_name property_path [new_object] ispctl [flag...] set module_name property_path [new_object]
ispctl [flag...] delete module_name property_path ispctl [flag...] delete module_name property_path
ispctl [flag...] schema module_name [local_flag] ispctl [flag...] schema module_name [local_flag]
ispctl [flag...] config audit [local_flag]
ispctl [flag...] vars get variable_name
ispctl [flag...] vars list
ispctl [flag...] vars set [local_flag] variable_name variable_value
ispctl [flag...] vars delete variable_name
ispctl [flag...] vars upload csv_filepath
``` ```
## Описание ## Описание
| Команды | Описание | | Команды | Описание |
|----------|-----------------------------------------------------------------------------| | ------------- | --------------------------------------------------------------------------- |
| `status` | возвращает доступные конфигурации модулей, их состояния и подключения | | `status` | возвращает доступные конфигурации модулей, их состояния и подключения |
| `get` | возвращает объект конфигурации указанного модуля | | `get` | возвращает объект конфигурации указанного модуля |
| `set` | изменяет объект конфигурации указанного модуля | | `set` | изменяет объект конфигурации указанного модуля |
@@ -45,28 +57,40 @@ ispctl [flag...] schema module_name [local_flag]
| `merge` | поблочно производит слияние конфигурации модуля с json конфигом через stdin | | `merge` | поблочно производит слияние конфигурации модуля с json конфигом через stdin |
| `gitget` | скачивает из репозитория указанный файлы с указанного комита | | `gitget` | скачивает из репозитория указанный файлы с указанного комита |
| `schema` | возвращает схему конфигурации указанного модуля | | `schema` | возвращает схему конфигурации указанного модуля |
| `config audit` | находит в активных конфигурациях SECRET-переменные, referenced в UI-экспонируемых полях (теги `x-ui-exposed` в схеме); код выхода `1`, если нарушения найдены |
| `vars get` | выводит информацию о переменной в json формате |
| `vars list` | выводит список переменных в виде ASCII-таблицы |
| `vars set` | изменяет значение переменной |
| `vars delete` | удаляет переменную по имени |
| `vars upload` | загружает переменные из csv файла |
| | | | | |
| Флаги | Параметры | Описание | | Флаги | Параметры | Описание |
|-------------|-----------|--------------------------------------------------------| | --------- | --------- | ------------------------------------------------------ |
| `-g` | string | адрес isp-config-service | | `-g` | string | адрес isp-config-service |
| `-unsafe` | | отключает проверку схемы перед изменением конфигурации | | `-unsafe` | | отключает проверку схемы перед изменением конфигурации |
| | | | | | | |
| Аргументы | Описание | | Аргументы | Описание |
|-----------------|-------------------------------------------------------------------------------------------------------------| | ----------------- | ------------------------------------------------------------------------------------------------------ |
| `module_name` | Название модуля с которым происходит взаимодействие | | `module_name` | Название модуля с которым происходит взаимодействие |
| `property_path` | Путь к объекту конфигурации, при значении `.` работа происходит со всей конфигурацией модуля | | `property_path` | Путь к объекту конфигурации, при значении `.` работа происходит со всей конфигурацией модуля |
| `new_object` | Новый объект, значение должно быть экранировано с помощью `' '`, при отсутсвии ожидается ввод из stdin | | `new_object` | Новый объект, значение должно быть экранировано с помощью `' '`, при отсутсвии ожидается ввод из stdin |
| `variable_name` | Название переменной с которой происходит взаимодействие |
| `variable_value` | Значение переменной |
| `csv_filepath` | Путь к csv файлу с переменными для загрузки |
| | | | | |
| Локальные флаги | Параметры | Команды | Описание | | Локальные флаги | Параметры | Команды | Описание |
|-----------------|-----------|---------|---------------------------------------------------------------------------------------------------------------------------------| | --------------- | --------- | -------- |------------------------------------------------------------------------------------------------------------------------------- |
| `-o` | string | schema | определяет формат вывода схемы в stdout; по умолчанию `json`; возможные значения `json`, `html` | | `-o` | string | schema | определяет формат вывода схемы в stdout; по умолчанию `json`; возможные значения `json`, `html` |
| `-o` | string | config audit | определяет формат вывода аудита в stdout; возможные значения `json` |
| `-full` | bool | get | осуществляет взаимодействие с объектами конфигурации модуля с учетом объектом общих конфигураций, которые имеют связь с модулем | | `-full` | bool | get | осуществляет взаимодействие с объектами конфигурации модуля с учетом объектом общих конфигураций, которые имеют связь с модулем |
| `-secret` | bool | vars set | устанавливает тип переменной в SECRET |
| | | | | | | | | |
## Пример ## Пример
### ispctl status ### ispctl status
`ispctl [flag...] status [local_flag]` `ispctl [flag...] status [local_flag]`
@@ -369,12 +393,156 @@ ispctl merge example < example.json
ispctl gitget git@github.com:integration-system/ispctl.git main.go d4d7c679aad47ae204c2b3a4587b032a723fe315 ispctl gitget git@github.com:integration-system/ispctl.git main.go d4d7c679aad47ae204c2b3a4587b032a723fe315
``` ```
### Запрос с флагами ### ispctl config audit
`ispctl [flag...] config audit [local_flag]`
Проверяет активные конфигурации всех модулей: находит UI-экспонируемые поля (тег `x-ui-exposed` в схеме модуля), в которых активная конфигурация ссылается на SECRET-переменные. Такие значения уже рендерились в браузеры модулей, поэтому найденные переменные нужно ротировать.
`[local_flag]` - локальный флаг `-o` определяет формат вывода. Доступные значения: `json`.
По умолчанию вывод осуществляется в виде таблицы.
Если нарушения найдены, код выхода `1`, иначе `0`.
Запрос Запрос
```bash
ispctl config audit
```
Ответ
```bash
MODULE | PATH | VARIABLES
isp-admin-service | $.oauth.clients[].clientSecret | oauth_secret
isp-admin-service | $.secrets | legacy_token
found 2 violation(s); affected values were already rendered into module browsers, rotate the variables
```
Запрос
```bash
ispctl config audit -o json
```
Ответ
```json
[
{
"Module": "isp-admin-service",
"Path": "$.oauth.clients[].clientSecret",
"Variables": [
"oauth_secret"
]
},
{
"Module": "isp-admin-service",
"Path": "$.secrets",
"Variables": [
"legacy_token"
]
}
]
```
### ispctl vars
#### ispctl vars get
`ispctl [flag...] vars get variable_name`
Запрос
```bash
ispctl vars get example_variable
```
Ответ
```json
{
"name": "example_variable",
"description": "example description text",
"type": "TEXT",
"value": "some variable value",
"containsInConfigs": []
}
```
#### ispctl vars list
`ispctl [flag...] vars list`
Запрос
```bash
ispctl vars list
```
Ответ
```bash
+--------+-------------+--------+-----------------+---------+
| NAME | DESCRIPTION | TYPE | VALUE | CONFIGS |
+--------+-------------+--------+-----------------+---------+
| var-99 | описание | SECRET | | |
+--------+-------------+--------+-----------------+---------+
| var-6 | описание | SECRET | | |
+--------+-------------+--------+-----------------+---------+
| var-2 | описание | TEXT | 1131231-2131231 | |
+--------+-------------+--------+-----------------+---------+
| var-1 | описание | SECRET | | |
+--------+-------------+--------+-----------------+---------+
```
#### ispctl vars set
`ispctl [flag...] vars set variable_name variable_value`
Запрос на изменение значения переменной и установку типа TEXT
```bash
ispctl vars set example_variable value
```
Запрос на изменение значения переменной и установку типа SECRET
```bash
ispctl vars set -secret example_variable value
```
#### ispctl vars delete
`ispctl [flag...] vars delete variable_name`
Запрос
```bash
ispctl vars delete example_variable
```
#### ispctl vars upload
`ispctl [flag...] vars upload csv_filepath`
Запрос
```bash
ispctl vars upload example.csv
```
CSV должен иметь поля `name`, `type`, `value`, `description`
пример CSV файла:
```csv
name,type,value,description
variable-1,SECRET,var 1 value,Описание 1 переменной
variable-2,TEXT,plaintext value,Описание 2 переменной
```
### Запрос с флагами
Запрос
```bash ```bash
ispctl -g '127.0.0.1:9002' set example . '{"metrics":{"address":{"ip":"127.0.0.1","newField":"100","port":1},"gc":1,"memory":false}}' ispctl -g '127.0.0.1:9002' set example . '{"metrics":{"address":{"ip":"127.0.0.1","newField":"100","port":1},"gc":1,"memory":false}}'
``` ```
Ответ Ответ
```json ```json
{ {
"metrics": { "metrics": {
@@ -388,3 +556,4 @@ ispctl -g '127.0.0.1:9002' set example . '{"metrics":{"address":{"ip":"127.0.0.1
} }
} }
``` ```
1
+2 -2
View File
@@ -16,9 +16,9 @@ for status in $statusResponse; do
read -ra ADDR <<<"$status" read -ra ADDR <<<"$status"
for module_name in "${ADDR[0]}"; do for module_name in "${ADDR[0]}"; do
if [ -n "$*" ]; then if [ -n "$*" ]; then
ispctl $* schema $module_name -o html > schemas/$module_name.html ispctl $* schema -o html $module_name > schemas/$module_name.html
else else
ispctl schema $module_name -o html > schemas/$module_name.html ispctl schema -o html $module_name > schemas/$module_name.html
fi fi
break break
done done
+73 -50
View File
@@ -2,83 +2,106 @@ package bash
import ( import (
"fmt" "fmt"
"ispctl/model"
"ispctl/service"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"github.com/txix-open/bellows" "github.com/txix-open/bellows"
"ispctl/flag"
"ispctl/service"
) )
const ( const (
CommonConfigName bashArg = "config_name" CommonConfigName = "config_name"
CommonConfigData bashArg = "config_data" ModuleName = "module_name"
ModuleName bashArg = "module_name" ModuleData = "module_data"
ModuleData bashArg = "module_data"
Empty bashArg = "empty" VariableName = "variable_name"
Empty = "empty"
) )
type bashArg string type BashService interface {
GetAllVariables() ([]model.Variable, error)
type bashCommand struct { GetAvailableConfigs() ([]model.ModuleInfo, error)
first bashArg GetConfigurationByModuleName(moduleName string) (*model.Config, error)
second bashArg
} }
func Get(first bashArg, second bashArg) *bashCommand { type BeforeComplete func(ctx *cli.Context) (service.Config, error)
return &bashCommand{
first: first, type Autocomplete struct {
second: second, beforeComplete BeforeComplete
service BashService
}
func NewAutocomplete(beforeComplete BeforeComplete) Autocomplete {
return Autocomplete{
beforeComplete: beforeComplete,
} }
} }
func (c bashCommand) Complete(ctx *cli.Context) { func (c Autocomplete) Complete(first string, second string) cli.BashCompleteFunc {
if err := flag.CheckGlobal(ctx); err != nil { return func(ctx *cli.Context) {
return cfgService, err := c.beforeComplete(ctx)
}
commonConfigs, err := service.Config.GetMapNameCommonConfig()
if err != nil { if err != nil {
return return
} }
c.service = cfgService
c.complete(ctx, first, second)
}
}
func (c Autocomplete) complete(ctx *cli.Context, first string, second string) {
switch ctx.NArg() { switch ctx.NArg() {
case 0: case 0:
switch c.first { c.completeFirstArg(ctx, first)
case ModuleName:
if arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil {
return
} else {
for _, module := range arrayOfModules {
fmt.Println(module.Name)
}
}
case CommonConfigName:
for _, config := range commonConfigs {
fmt.Println(config.Name)
}
}
case 1: case 1:
switch c.second { c.completeSecondArg(ctx, second)
case CommonConfigData:
if config, ok := commonConfigs[ctx.Args().First()]; ok {
for key, _ := range bellows.Flatten(config.Data) {
fmt.Printf(".%v\n", key)
} }
} }
func (c Autocomplete) completeFirstArg(ctx *cli.Context, first string) {
switch first {
case ModuleName: case ModuleName:
if arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil { c.printAvailableModules()
case VariableName:
c.printAvailableVariables()
}
}
func (c Autocomplete) completeSecondArg(ctx *cli.Context, second string) {
switch second {
case ModuleName:
c.printAvailableModules()
case ModuleData:
c.printModuleData(ctx.Args().First())
}
}
func (c Autocomplete) printAvailableVariables() {
vars, err := c.service.GetAllVariables()
if err != nil {
return return
} else { }
for _, module := range arrayOfModules { for _, v := range vars {
fmt.Println(v.Name)
}
}
func (c Autocomplete) printAvailableModules() {
modules, err := c.service.GetAvailableConfigs()
if err != nil {
return
}
for _, module := range modules {
fmt.Println(module.Name) fmt.Println(module.Name)
} }
} }
case ModuleData:
if moduleConfiguration, err := service.Config.GetConfigurationByModuleName(ctx.Args().First()); err != nil { func (c Autocomplete) printModuleData(moduleName string) {
config, err := c.service.GetConfigurationByModuleName(moduleName)
if err != nil {
return return
} else { }
for key, _ := range bellows.Flatten(moduleConfiguration.Data) { for key := range bellows.Flatten(config.Data) {
fmt.Printf(".%v\n", key) fmt.Printf(".%v\n", key)
} }
} }
}
}
}
-13
View File
@@ -1,13 +0,0 @@
package cfg
const (
getAvailableConfigs = "config/module/get_modules_info"
getConfigByModuleName = "config/config/get_active_config_by_module_name"
createUpdateConfig = "config/config/create_update_config"
getSchemaByModuleId = "config/schema/get_by_module_id"
getCommonConfigs = "config/common_config/get_configs"
createUpdateCommonConfig = "config/common_config/create_update_config"
deleteCommonConfig = "config/common_config/delete_config"
getLinksCommonConfig = "config/common_config/get_links"
compileCommonConfigs = "config/common_config/compile"
)
-163
View File
@@ -1,163 +0,0 @@
package cfg
import (
"context"
"time"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/client"
)
type ConfigClient struct {
cli *client.Client
address string
}
func NewConfigClient() *ConfigClient {
return &ConfigClient{}
}
func (c *ConfigClient) ReceiveConfig(address string) error {
cli, err := client.Default()
if err != nil {
return err
}
c.cli = cli
cli.Upgrade([]string{address})
c.address = address
return nil
}
func (c *ConfigClient) GetAvailableConfigs() ([]ModuleInfo, error) {
response := make([]ModuleInfo, 0)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(getAvailableConfigs).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getAvailableConfigs)
}
return response, nil
}
func (c *ConfigClient) GetConfigByModuleName(name string) (*Config, error) {
request := &getModuleByUuidAndNameRequest{ModuleName: name}
response := new(Config)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(getConfigByModuleName).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getConfigByModuleName)
}
return response, nil
}
func (c *ConfigClient) CreateUpdateConfig(request Config) (*Config, error) {
response := new(Config)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(createUpdateConfig).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", createUpdateConfig)
}
return response, nil
}
func (c *ConfigClient) GetSchemaByModuleId(moduleId string) (*ConfigSchema, error) {
request := getSchemaByModuleIdRequest{ModuleId: moduleId}
response := new(ConfigSchema)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(getSchemaByModuleId).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getSchemaByModuleId)
}
return response, nil
}
func (c *ConfigClient) GetCommonConfigs(req []string) ([]CommonConfig, error) {
response := make([]CommonConfig, 0)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(getCommonConfigs).
JsonRequestBody(req).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getCommonConfigs)
}
return response, nil
}
func (c *ConfigClient) CreateUpdateCommonConfig(req CommonConfig) (*CommonConfig, error) {
response := new(CommonConfig)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(createUpdateCommonConfig).
JsonRequestBody(req).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", createUpdateCommonConfig)
}
return response, nil
}
func (c *ConfigClient) DeleteCommonConfig(id string) (*Deleted, error) {
request := identityRequest{Id: id}
response := new(Deleted)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(deleteCommonConfig).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", deleteCommonConfig)
}
return response, nil
}
func (c *ConfigClient) GetLinksCommonConfig(id string) (*Links, error) {
request := identityRequest{Id: id}
response := new(Links)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(getLinksCommonConfig).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getLinksCommonConfig)
}
return response, nil
}
func (c *ConfigClient) CompileCommonConfigs(request CompileConfigs) (map[string]interface{}, error) {
response := make(map[string]interface{})
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := c.cli.Invoke(compileCommonConfigs).
JsonRequestBody(request).
JsonResponseBody(response).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", compileCommonConfigs)
}
return response, nil
}
func (c *ConfigClient) errorHandler(err error) error {
return errors.WithMessagef(err, "isp-config-service: %s", c.address)
}
+81
View File
@@ -0,0 +1,81 @@
package command
import (
"fmt"
"os"
"strings"
"ispctl/command/utils"
"ispctl/model"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
)
const (
tableHeaderAuditModule = "MODULE"
tableHeaderAuditPath = "PATH"
tableHeaderAuditVariables = "VARIABLES"
tableHeaderAuditReason = "REASON"
auditExitCode = 1
)
var outPrintAuditUsage = fmt.Sprintf("out print for audit; %s", OutPrintJsonValue)
type AuditService interface {
Audit() ([]model.AuditViolation, error)
}
type Audit struct {
service AuditService
}
func NewAudit(service AuditService) Audit {
return Audit{service: service}
}
func (c Audit) Command() *cli.Command {
return &cli.Command{
Name: "config",
Usage: "config commands",
Subcommands: []*cli.Command{
{
Name: "audit",
Usage: "report secret policy violations in active configs: SECRET references in ui-exposed fields and plain or non-SECRET values in sensitive fields",
Flags: []cli.Flag{
&cli.StringFlag{Name: OutPrintFlagName, Usage: outPrintAuditUsage},
},
Action: c.audit,
},
},
}
}
func (c Audit) audit(ctx *cli.Context) error {
violations, err := c.service.Audit()
if err != nil {
return err
}
switch ctx.String(OutPrintFlagName) {
case OutPrintJsonValue:
err = utils.PrintAnswer(violations)
default:
table := tablewriter.NewWriter(os.Stdout)
table.SetBorders(tablewriter.Border{Left: false, Top: false, Right: false, Bottom: false})
table.SetHeader([]string{tableHeaderAuditModule, tableHeaderAuditPath, tableHeaderAuditVariables, tableHeaderAuditReason})
for _, violation := range violations {
table.Append([]string{violation.Module, violation.Path, strings.Join(violation.Variables, ", "), violation.Reason})
}
table.Render()
fmt.Printf("found %d violation(s); rotate the affected SECRET variables and move sensitive values to SECRET variable references\n", len(violations))
}
if err != nil {
return err
}
if len(violations) > 0 {
return cli.Exit("secret policy violations found in active configs", auditExitCode)
}
return nil
}
+64
View File
@@ -0,0 +1,64 @@
package command
import (
"ispctl/command/utils"
"ispctl/model"
"github.com/txix-open/isp-kit/rc/schema"
"github.com/urfave/cli/v2"
)
type AutoComplete interface {
Complete(first string, second string) cli.BashCompleteFunc
}
type ConfigService interface {
Audit() ([]model.AuditViolation, error)
CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error)
CreateUpdateConfigV2(configuration *model.Config) (map[string]any, error)
DeleteVariable(variableName string) error
GetAllVariables() ([]model.Variable, error)
GetAvailableConfigs() ([]model.ModuleInfo, error)
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
GetSchemaByModuleId(moduleId string) (schema.Schema, error)
GetVariableByName(variableName string) (*model.Variable, error)
UpsertVariables(vars []model.UpsertVariableRequest) error
}
type UpdateConfigService interface {
CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error)
}
func AllCommands(configService ConfigService, autoComplete AutoComplete) []*cli.Command {
status := NewStatus(configService)
get := NewGet(configService, autoComplete)
set := NewSet(configService, autoComplete)
delete := NewDelete(configService, autoComplete)
schema := NewSchema(configService, autoComplete)
merge := NewMerge(configService, autoComplete)
gitGet := NewGitGet()
variables := NewVariables(configService, autoComplete)
audit := NewAudit(configService)
return []*cli.Command{
status.Command(),
get.Command(),
set.Command(),
delete.Command(),
schema.Command(),
merge.Command(),
gitGet.Command(),
variables.Command(),
audit.Command(),
}
}
func CreateUpdateConfig(stringToChange string, configuration *model.Config, service UpdateConfigService) error {
answer, err := service.CreateUpdateConfig(stringToChange, configuration)
if err != nil {
return err
}
if answer != nil {
return utils.PrintAnswer(answer)
}
return nil
}
-47
View File
@@ -1,47 +0,0 @@
package command
import (
"fmt"
"github.com/urfave/cli/v2"
"ispctl/command/common_config"
)
func CommonConfig() *cli.Command {
return &cli.Command{
Name: "common",
Usage: "access to common configs commands",
Action: cc.action,
BashComplete: cc.bachComplete,
Subcommands: []*cli.Command{
common_config.Get(),
common_config.Set(),
common_config.Delete(),
common_config.Remove(),
common_config.Link(),
common_config.UnLink(),
common_config.Contain(),
},
}
}
var cc commonConfigCommand
type commonConfigCommand struct{}
func (g commonConfigCommand) action(ctx *cli.Context) error {
if ctx.Args().First() == "" {
fmt.Print("need use command: ")
for _, comm := range CommonConfig().Subcommands {
fmt.Printf("[%s] ", comm.Name)
}
fmt.Printf("\n")
}
return nil
}
func (g commonConfigCommand) bachComplete(ctx *cli.Context) {
for _, command := range CommonConfig().Subcommands {
fmt.Println(command.Name)
}
}
-53
View File
@@ -1,53 +0,0 @@
package common_config
import (
"fmt"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/flag"
"ispctl/service"
)
func Contain() *cli.Command {
return &cli.Command{
Name: "contain",
Usage: "availability common configuration in module",
Action: contain.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.Empty).Complete,
}
}
var contain containCommand
type containCommand struct{}
func (g containCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
if configName == "" {
return errors.New("empty common config name")
}
config, err := service.Config.GetCommonConfigByName(configName)
if err != nil {
return err
}
links, err := service.Config.GetLinksCommonConfig(config.Id)
if err != nil {
return err
} else {
fmt.Printf("config [%s] linked with next modules:\n", configName)
for _, link := range links {
fmt.Printf("[%s] ", link)
}
fmt.Printf("\n")
}
return nil
}
-63
View File
@@ -1,63 +0,0 @@
package common_config
import (
"encoding/json"
"github.com/pkg/errors"
"github.com/tidwall/sjson"
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/command/utils"
"ispctl/flag"
"ispctl/service"
)
func Delete() *cli.Command {
return &cli.Command{
Name: "delete",
Usage: "set common configurations",
Action: deleteComm.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.CommonConfigData).Complete,
}
}
var deleteComm deleteCommand
type deleteCommand struct{}
func (g deleteCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
pathObject := ctx.Args().Get(1)
if configName == "" {
return errors.New("empty config name")
}
pathObject, err := utils.CheckPath(pathObject)
if err != nil {
return err
}
config, err := service.Config.GetCommonConfigByName(configName)
if err != nil {
return err
}
if pathObject == "" {
return utils.CreateUpdateCommonConfig("", config)
} else {
jsonObject, err := json.Marshal(config.Data)
if err != nil {
return err
}
if stringToChange, err := sjson.Delete(string(jsonObject), pathObject); err != nil {
return err
} else {
return utils.CreateUpdateCommonConfig(stringToChange, config)
}
}
}
-68
View File
@@ -1,68 +0,0 @@
package common_config
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/command/utils"
"ispctl/flag"
"ispctl/service"
)
func Get() *cli.Command {
return &cli.Command{
Name: "get",
Usage: "get common configurations",
Action: get.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.CommonConfigData).Complete,
}
}
var get getCommand
type getCommand struct{}
func (g getCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
pathObject := ctx.Args().Get(1)
commonConfigs, err := service.Config.GetMapNameCommonConfig()
if err != nil {
return err
}
if configName == "" {
fmt.Printf("available next common configs:\n")
for name := range commonConfigs {
fmt.Printf("[%s] ", name)
}
fmt.Println()
return nil
}
pathObject, err = utils.CheckPath(pathObject)
if err != nil {
return err
}
config, ok := commonConfigs[configName]
if !ok {
return errors.Errorf("common config [%s] not found", configName)
}
if pathObject == "" {
utils.PrintAnswer(config.Data)
} else if jsonObject, err := json.Marshal(config.Data); err != nil {
return err
} else {
utils.CheckObject(jsonObject, pathObject)
}
return nil
}
-35
View File
@@ -1,35 +0,0 @@
package common_config
import (
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/flag"
"ispctl/service"
)
func Link() *cli.Command {
return &cli.Command{
Name: "link",
Usage: "link common configurations to module configuration",
Action: link.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.ModuleName).Complete,
}
}
var link linkCommand
type linkCommand struct{}
func (g linkCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
moduleName := ctx.Args().Get(1)
if err := service.Config.LinkCommonConfigToModule(configName, moduleName); err != nil {
return err
}
return nil
}
-53
View File
@@ -1,53 +0,0 @@
package common_config
import (
"fmt"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/flag"
"ispctl/service"
)
func Remove() *cli.Command {
return &cli.Command{
Name: "remove",
Usage: "remove common configurations",
Action: remove.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.Empty).Complete,
}
}
var remove removeCommand
type removeCommand struct{}
func (g removeCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
if configName == "" {
return errors.New("empty common config name")
}
config, err := service.Config.GetCommonConfigByName(configName)
if err != nil {
return err
}
links, deleted, err := service.Config.DeleteCommonConfig(config.Id)
if err != nil {
return err
}
if deleted {
fmt.Printf("config [%s] deleted\n", config.Name)
} else {
fmt.Printf("config [%s] not deleted, need unlink in next modules:\n%v\n", config.Name, links)
}
return nil
}
-78
View File
@@ -1,78 +0,0 @@
package common_config
import (
"encoding/json"
"github.com/pkg/errors"
"github.com/tidwall/sjson"
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/cfg"
"ispctl/command/utils"
"ispctl/flag"
"ispctl/service"
)
func Set() *cli.Command {
return &cli.Command{
Name: "set",
Usage: "set common configurations",
Action: set.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.CommonConfigData).Complete,
}
}
var set setCommand
type setCommand struct{}
func (g setCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
pathObject := ctx.Args().Get(1)
changeObject := ctx.Args().Get(2)
if configName == "" {
return errors.New("empty config name")
}
mapConfigByName, err := service.Config.GetMapNameCommonConfig()
if err != nil {
return err
}
config, ok := mapConfigByName[configName]
if !ok {
config = cfg.CommonConfig{
Name: configName,
}
}
pathObject, err = utils.CheckPath(pathObject)
if err != nil {
return err
}
changeObject, err = utils.CheckChangeObject(changeObject)
if err != nil {
return err
}
if pathObject == "" {
return utils.CreateUpdateCommonConfig(changeObject, config)
} else {
jsonObject, err := json.Marshal(config.Data)
if err != nil {
return err
}
changeArgument := utils.ParseSetObject(changeObject)
if stringToChange, err := sjson.Set(string(jsonObject), pathObject, changeArgument); err != nil {
return err
} else {
return utils.CreateUpdateCommonConfig(stringToChange, config)
}
}
}
-35
View File
@@ -1,35 +0,0 @@
package common_config
import (
"github.com/urfave/cli/v2"
"ispctl/bash"
"ispctl/flag"
"ispctl/service"
)
func UnLink() *cli.Command {
return &cli.Command{
Name: "unlink",
Usage: "unlink common configurations from module configuration",
Action: unlink.action,
BashComplete: bash.Get(bash.CommonConfigName, bash.ModuleName).Complete,
}
}
var unlink unlinkCommand
type unlinkCommand struct{}
func (g unlinkCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
configName := ctx.Args().First()
moduleName := ctx.Args().Get(1)
if err := service.Config.UnlinkCommonConfigFromModule(configName, moduleName); err != nil {
return err
}
return nil
}
+33 -24
View File
@@ -3,35 +3,45 @@ package command
import ( import (
"encoding/json" "encoding/json"
"github.com/tidwall/sjson"
"github.com/urfave/cli/v2"
"ispctl/bash" "ispctl/bash"
"ispctl/command/utils" "ispctl/command/utils"
"ispctl/flag" "ispctl/model"
"ispctl/service"
"github.com/tidwall/sjson"
"github.com/urfave/cli/v2"
) )
func Delete() *cli.Command { type DeleteService interface {
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error)
}
type Delete struct {
service DeleteService
autoComplete AutoComplete
}
func NewDelete(service DeleteService, autoComplete AutoComplete) Delete {
return Delete{
service: service,
autoComplete: autoComplete,
}
}
func (c Delete) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "delete", Name: "delete",
Usage: "delete configuration by module_name", Usage: "delete configuration by module_name",
Action: deleteComm.action, Action: c.action,
BashComplete: bash.Get(bash.ModuleName, bash.ModuleData).Complete, BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.ModuleData),
} }
} }
var deleteComm deleteCommand func (c Delete) action(ctx *cli.Context) error {
type deleteCommand struct{}
func (d deleteCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
moduleName := ctx.Args().First() moduleName := ctx.Args().First()
pathObject := ctx.Args().Get(1) pathObject := ctx.Args().Get(1)
moduleConfiguration, err := service.Config.GetConfigurationByModuleName(moduleName) moduleConfiguration, err := c.service.GetConfigurationByModuleName(moduleName)
if err != nil { if err != nil {
return err return err
} }
@@ -40,19 +50,18 @@ func (d deleteCommand) action(ctx *cli.Context) error {
if err != nil { if err != nil {
return err return err
} }
if pathObject == "" { if pathObject == "" {
return utils.CreateUpdateConfig("", moduleConfiguration) return CreateUpdateConfig("", moduleConfiguration, c.service)
} else { }
jsonObject, err := json.Marshal(moduleConfiguration.Data) jsonObject, err := json.Marshal(moduleConfiguration.Data)
if err != nil { if err != nil {
return err return err
} }
stringToChange, err := sjson.Delete(string(jsonObject), pathObject)
if stringToChange, err := sjson.Delete(string(jsonObject), pathObject); err != nil { if err != nil {
return err return err
} else {
return utils.CreateUpdateConfig(stringToChange, moduleConfiguration)
}
} }
return CreateUpdateConfig(stringToChange, moduleConfiguration, c.service)
} }
+23
View File
@@ -0,0 +1,23 @@
package command
import "fmt"
const (
HostFlagName = "gateHost"
HostFlagUsage = "isp-config-service address"
UnsafeFlagName = "unsafe"
UnsafeFlagUsage = "disable checking schema for set configuration"
OutPrintFlagName = "o"
OutPrintJsonValue = "json"
OutPrintHtmlValue = "html"
SecretFlagName = "secret"
secretVariableFlagUsage = "set variable as secret"
)
var (
outPrintStatusUsage = fmt.Sprintf("out print for status; %s", OutPrintJsonValue)
outPrintSchemaUsage = fmt.Sprintf("out print for schema; %s or %s", OutPrintJsonValue, OutPrintHtmlValue)
)
+28 -28
View File
@@ -3,47 +3,48 @@ package command
import ( import (
"encoding/json" "encoding/json"
"github.com/urfave/cli/v2"
"ispctl/bash" "ispctl/bash"
"ispctl/command/utils" "ispctl/command/utils"
"ispctl/flag" "ispctl/model"
"ispctl/service"
"github.com/urfave/cli/v2"
) )
func Get() *cli.Command { type GetService interface {
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
}
type Get struct {
service SetService
autoComplete AutoComplete
}
func NewGet(service SetService, autoComplete AutoComplete) Get {
return Get{
service: service,
autoComplete: autoComplete,
}
}
func (c Get) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "get", Name: "get",
Usage: "get configuration by module_name", Usage: "get configuration by module_name",
Action: get.action, Action: c.action,
BashComplete: bash.Get(bash.ModuleName, bash.ModuleData).Complete, BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.ModuleData),
Flags: []cli.Flag{
flag.WithCommonConfig,
},
} }
} }
var get getCommand func (c Get) action(ctx *cli.Context) error {
type getCommand struct{}
func (g getCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
moduleName := ctx.Args().First() moduleName := ctx.Args().First()
pathObject := ctx.Args().Get(1) pathObject := ctx.Args().Get(1)
config, err := service.Config.GetConfigurationByModuleName(moduleName) config, err := c.service.GetConfigurationByModuleName(moduleName)
if err != nil { if err != nil {
return err return err
} }
data := config.Data data := config.Data
if ctx.Bool(flag.WithCommonConfig.Name) {
if data, err = service.Config.CompileDataWithCommonConfigs(data, config.CommonConfigs); err != nil {
return err
}
}
pathObject, err = utils.CheckPath(pathObject) pathObject, err = utils.CheckPath(pathObject)
if err != nil { if err != nil {
@@ -51,13 +52,12 @@ func (g getCommand) action(ctx *cli.Context) error {
} }
if pathObject == "" { if pathObject == "" {
utils.PrintAnswer(data) return utils.PrintAnswer(data)
} else { }
jsonObject, err := json.Marshal(data) jsonObject, err := json.Marshal(data)
if err != nil { if err != nil {
return err return err
} }
utils.CheckObject(jsonObject, pathObject) return utils.CheckObject(jsonObject, pathObject)
}
return nil
} }
+20 -12
View File
@@ -13,21 +13,31 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
var ( type GitGet struct {
semverRegexp = regexp.MustCompile("v([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$") semverRegexp *regexp.Regexp
) }
func GitGet() *cli.Command { func NewGitGet() GitGet {
return GitGet{
semverRegexp: regexp.MustCompile(`v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$`),
}
}
func (c GitGet) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "gitget", Name: "gitget",
Usage: "gitget [repository] [file] (commit|tag)", Usage: "gitget [repository] [file] (commit|tag)",
Description: "clone and print specified file from specified repository and specified commit hash or tag", Description: "clone and print specified file from specified repository and specified commit hash or tag",
Action: func(context *cli.Context) error { Action: c.action,
storage := memory.NewStorage() }
repo := context.Args().Get(0) }
file := context.Args().Get(1) func (c GitGet) action(ctx *cli.Context) error {
commit := context.Args().Get(2) storage := memory.NewStorage()
repo := ctx.Args().Get(0)
file := ctx.Args().Get(1)
commit := ctx.Args().Get(2)
repository, err := git.Clone(storage, memfs.New(), &git.CloneOptions{ repository, err := git.Clone(storage, memfs.New(), &git.CloneOptions{
URL: repo, URL: repo,
@@ -42,7 +52,7 @@ func GitGet() *cli.Command {
if commit != "" { if commit != "" {
checkoutOpts := git.CheckoutOptions{} checkoutOpts := git.CheckoutOptions{}
if semverRegexp.MatchString(commit) { if c.semverRegexp.MatchString(commit) {
checkoutOpts.Branch = plumbing.NewTagReferenceName(commit) checkoutOpts.Branch = plumbing.NewTagReferenceName(commit)
} else { } else {
checkoutOpts.Hash = plumbing.NewHash(commit) checkoutOpts.Hash = plumbing.NewHash(commit)
@@ -64,6 +74,4 @@ func GitGet() *cli.Command {
} }
return nil return nil
},
}
} }
+31 -17
View File
@@ -4,26 +4,43 @@ import (
"encoding/json" "encoding/json"
"os" "os"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"ispctl/bash" "ispctl/bash"
"ispctl/command/utils" "ispctl/command/utils"
"ispctl/flag" "ispctl/model"
"ispctl/service"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
) )
func Merge() *cli.Command { type MergeService interface {
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
CreateUpdateConfigV2(configuration *model.Config) (map[string]any, error)
}
type Merge struct {
service MergeService
autoComplete AutoComplete
}
func NewMerge(service MergeService, autoComplete AutoComplete) Merge {
return Merge{
service: service,
autoComplete: autoComplete,
}
}
func (c Merge) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "merge", Name: "merge",
Usage: "merge actual config with config from stdin", Usage: "merge actual config with config from stdin",
BashComplete: bash.Get(bash.CommonConfigName, bash.Empty).Complete, BashComplete: c.autoComplete.Complete(bash.CommonConfigName, bash.Empty),
Action: func(context *cli.Context) error { Action: c.action,
err := flag.CheckGlobal(context)
if err != nil {
return err
} }
moduleName := context.Args().First() }
config, err := service.Config.GetConfigurationByModuleName(moduleName)
func (c Merge) action(ctx *cli.Context) error {
moduleName := ctx.Args().First()
config, err := c.service.GetConfigurationByModuleName(moduleName)
if err != nil { if err != nil {
return errors.WithMessagef(err, "get module config '%s'", moduleName) return errors.WithMessagef(err, "get module config '%s'", moduleName)
} }
@@ -37,13 +54,10 @@ func Merge() *cli.Command {
config.Data[key] = value config.Data[key] = value
} }
result, err := service.Config.CreateUpdateConfigV2(config) result, err := c.service.CreateUpdateConfigV2(config)
if err != nil { if err != nil {
return errors.WithMessagef(err, "update module config '%s'", moduleName) return errors.WithMessagef(err, "update module config '%s'", moduleName)
} }
utils.PrintAnswer(result)
return nil return utils.PrintAnswer(result)
},
}
} }
+53 -45
View File
@@ -4,73 +4,81 @@ import (
"html/template" "html/template"
"os" "os"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"ispctl/bash" "ispctl/bash"
"ispctl/command/utils" "ispctl/command/utils"
"ispctl/flag" "ispctl/model"
"ispctl/service"
"ispctl/tmpl" "ispctl/tmpl"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/rc/schema"
"github.com/urfave/cli/v2"
) )
func Schema() *cli.Command { type SchemaService interface {
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
GetSchemaByModuleId(moduleId string) (schema.Schema, error)
}
type Schema struct {
service SchemaService
autoComplete AutoComplete
}
func NewSchema(service SchemaService, autoComplete AutoComplete) Schema {
return Schema{
service: service,
autoComplete: autoComplete,
}
}
func (c Schema) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "schema", Name: "schema",
Usage: "get schema configuration by module_name", Usage: "get schema configuration by module_name",
Action: schema.action, Action: c.action,
Flags: []cli.Flag{ Flags: []cli.Flag{
flag.OutPrintSchema, &cli.StringFlag{Name: OutPrintFlagName, Usage: outPrintSchemaUsage, Value: OutPrintJsonValue},
}, },
BashComplete: bash.Get(bash.ModuleName, bash.Empty).Complete, BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.Empty),
} }
} }
var schema schemaCommand func (c Schema) action(ctx *cli.Context) error {
moduleName := ctx.Args().First()
type schemaCommand struct{} schemaConfig, err := c.getSchemaConfig(moduleName)
if err != nil {
func (s schemaCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err return err
} }
moduleName := ctx.Args().First()
if schemaConfig := s.getSchemaConfig(moduleName); schemaConfig != nil { schema := make(map[string]any)
schema := make(map[string]interface{})
schema["title"] = moduleName schema["title"] = moduleName
schema["schema"] = schemaConfig schema["schema"] = schemaConfig
switch ctx.String(flag.OutPrintSchema.Name) { switch ctx.String(OutPrintFlagName) {
case flag.OutPrintJsonValue: case OutPrintJsonValue:
utils.PrintAnswer(schema) return utils.PrintAnswer(schema)
case flag.OutPrintHtmlValue: case OutPrintHtmlValue:
s.printHtml(schema) return c.printHtml(schema)
default: default:
return errors.Errorf("invalid flag value, expected [%s] or [%s]", flag.OutPrintJsonValue, flag.OutPrintHtmlValue) return errors.Errorf("invalid flag value, expected [%s] or [%s]", OutPrintJsonValue, OutPrintHtmlValue)
}
}
return nil
}
func (s schemaCommand) getSchemaConfig(moduleName string) interface{} {
if configuration, err := service.Config.GetConfigurationByModuleName(moduleName); err != nil {
utils.PrintError(err)
return nil
} else if schema, err := service.Config.GetSchemaByModuleId(configuration.ModuleId); err != nil {
utils.PrintError(err)
return nil
} else {
return schema
} }
} }
func (s schemaCommand) printHtml(schema map[string]interface{}) { func (c Schema) getSchemaConfig(moduleName string) (schema.Schema, error) {
if temp, err := template.New("template").Parse(tmpl.HtmlFile); err != nil { configuration, err := c.service.GetConfigurationByModuleName(moduleName)
utils.PrintError(err) if err != nil {
return return nil, err
} else {
if err := temp.ExecuteTemplate(os.Stdout, "template", schema); err != nil {
utils.PrintError(err)
return
} }
schema, err := c.service.GetSchemaByModuleId(configuration.ModuleId)
if err != nil {
return nil, err
} }
return schema, nil
}
func (c Schema) printHtml(schema map[string]any) error {
temp, err := template.New("template").Parse(tmpl.HtmlFile)
if err != nil {
return err
}
return temp.ExecuteTemplate(os.Stdout, "template", schema)
} }
+31 -23
View File
@@ -3,37 +3,46 @@ package command
import ( import (
"encoding/json" "encoding/json"
"github.com/tidwall/sjson"
"github.com/urfave/cli/v2"
"ispctl/bash" "ispctl/bash"
"ispctl/command/utils" "ispctl/command/utils"
"ispctl/flag" "ispctl/model"
"ispctl/service"
"github.com/tidwall/sjson"
"github.com/urfave/cli/v2"
) )
func Set() *cli.Command { type SetService interface {
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error)
}
type Set struct {
service SetService
autoComplete AutoComplete
}
func NewSet(service SetService, autoComplete AutoComplete) Set {
return Set{
service: service,
autoComplete: autoComplete,
}
}
func (c Set) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "set", Name: "set",
Usage: "set configuration by module_name", Usage: "set configuration by module_name",
Action: set.action, Action: c.action,
BashComplete: bash.Get(bash.ModuleName, bash.ModuleData).Complete, BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.ModuleData),
} }
} }
var set setCommand func (c Set) action(ctx *cli.Context) error {
type setCommand struct{}
func (s setCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err
}
moduleName := ctx.Args().First() moduleName := ctx.Args().First()
pathObject := ctx.Args().Get(1) pathObject := ctx.Args().Get(1)
changeObject := ctx.Args().Get(2) changeObject := ctx.Args().Get(2)
config, err := service.Config.GetConfigurationByModuleName(moduleName) config, err := c.service.GetConfigurationByModuleName(moduleName)
if err != nil { if err != nil {
return err return err
} }
@@ -49,18 +58,17 @@ func (s setCommand) action(ctx *cli.Context) error {
} }
if pathObject == "" { if pathObject == "" {
return utils.CreateUpdateConfig(changeObject, config) return CreateUpdateConfig(changeObject, config, c.service)
} else { }
jsonObject, err := json.Marshal(config.Data) jsonObject, err := json.Marshal(config.Data)
if err != nil { if err != nil {
return err return err
} }
changeArgument := utils.ParseSetObject(changeObject) changeArgument := utils.ParseSetObject(changeObject)
if stringToChange, err := sjson.Set(string(jsonObject), pathObject, changeArgument); err != nil { stringToChange, err := sjson.Set(string(jsonObject), pathObject, changeArgument)
if err != nil {
return err return err
} else {
return utils.CreateUpdateConfig(stringToChange, config)
}
} }
return CreateUpdateConfig(stringToChange, config, c.service)
} }
+24 -19
View File
@@ -5,11 +5,11 @@ import (
"os" "os"
"strings" "strings"
"ispctl/command/utils"
"ispctl/model"
"github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"ispctl/command/utils"
"ispctl/flag"
"ispctl/service"
) )
const ( const (
@@ -21,31 +21,37 @@ const (
tableConnectedStatus = "CONNECTED" tableConnectedStatus = "CONNECTED"
) )
func Status() *cli.Command { type StatusService interface {
GetAvailableConfigs() ([]model.ModuleInfo, error)
}
type Status struct {
service StatusService
}
func NewStatus(service StatusService) Status {
return Status{service: service}
}
func (c Status) Command() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "status", Name: "status",
Usage: "get available configs", Usage: "get available configs",
Action: status.action, Action: c.action,
Flags: []cli.Flag{ Flags: []cli.Flag{
flag.OutPrintStatus, &cli.StringFlag{Name: OutPrintFlagName, Usage: outPrintStatusUsage},
}, },
} }
} }
var status statusCommand func (c Status) action(ctx *cli.Context) error {
arrayOfModules, err := c.service.GetAvailableConfigs()
type statusCommand struct{} if err != nil {
func (statusCommand) action(ctx *cli.Context) error {
if err := flag.CheckGlobal(ctx); err != nil {
return err return err
} }
if arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil { switch ctx.String(OutPrintFlagName) {
return err case OutPrintJsonValue:
} else { return utils.PrintAnswer(arrayOfModules)
switch ctx.String(flag.OutPrintStatus.Name) {
case flag.OutPrintJsonValue:
utils.PrintAnswer(arrayOfModules)
default: default:
table := tablewriter.NewWriter(os.Stdout) table := tablewriter.NewWriter(os.Stdout)
table.SetBorders(tablewriter.Border{Left: false, Top: false, Right: false, Bottom: false}) table.SetBorders(tablewriter.Border{Left: false, Top: false, Right: false, Bottom: false})
@@ -65,6 +71,5 @@ func (statusCommand) action(ctx *cli.Context) error {
} }
table.Render() table.Render()
} }
}
return nil return nil
} }
+16 -25
View File
@@ -2,7 +2,7 @@ package utils
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"strings" "strings"
@@ -22,7 +22,7 @@ func CheckPath(pathObject string) (string, error) {
continue continue
} }
if key == 1 { if key == 1 {
pathObject = fmt.Sprintf("%s", value) pathObject = value
continue continue
} }
pathObject = fmt.Sprintf("%s.%s", pathObject, value) pathObject = fmt.Sprintf("%s.%s", pathObject, value)
@@ -32,7 +32,7 @@ func CheckPath(pathObject string) (string, error) {
func CheckChangeObject(changeObject string) (string, error) { func CheckChangeObject(changeObject string) (string, error) {
if changeObject == "" { if changeObject == "" {
bytes, err := ioutil.ReadAll(os.Stdin) bytes, err := io.ReadAll(os.Stdin)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -40,26 +40,18 @@ func CheckChangeObject(changeObject string) (string, error) {
} }
if changeObject == "" { if changeObject == "" {
return "", errors.New("expected argument") return "", errors.New("expected argument")
} else { }
return changeObject, nil return changeObject, nil
} }
}
func PrintAnswer(data interface{}) { func PrintAnswer(data any) error {
encoder := json.NewEncoder(os.Stdout) encoder := json.NewEncoder(os.Stdout)
encoder.SetEscapeHTML(false) encoder.SetEscapeHTML(false)
encoder.SetIndent("", " ") encoder.SetIndent("", " ")
if err := encoder.Encode(data); err != nil { return encoder.Encode(data)
PrintError(err)
}
} }
func PrintError(err error) { func ParseSetObject(argument string) any {
fmt.Println("ERROR:", err)
os.Exit(-1)
}
func ParseSetObject(argument string) interface{} {
tryParse := []byte(argument) tryParse := []byte(argument)
if tryParse[0] == '"' && tryParse[len(tryParse)-1] == '"' { if tryParse[0] == '"' && tryParse[len(tryParse)-1] == '"' {
tryParse = tryParse[1 : len(tryParse)-1] tryParse = tryParse[1 : len(tryParse)-1]
@@ -70,12 +62,12 @@ func ParseSetObject(argument string) interface{} {
return nil return nil
} }
mapStringInterface := make(map[string]interface{}) mapStringInterface := make(map[string]any)
if err := json.Unmarshal(tryParse, &mapStringInterface); err == nil { if err := json.Unmarshal(tryParse, &mapStringInterface); err == nil {
return mapStringInterface return mapStringInterface
} }
arrayOfObject := make([]interface{}, 0) arrayOfObject := make([]any, 0)
if err := json.Unmarshal(tryParse, &arrayOfObject); err == nil { if err := json.Unmarshal(tryParse, &arrayOfObject); err == nil {
return arrayOfObject return arrayOfObject
} }
@@ -98,16 +90,15 @@ func ParseSetObject(argument string) interface{} {
return argument return argument
} }
func CheckObject(jsonObject []byte, depth string) { func CheckObject(jsonObject []byte, depth string) error {
jsonString := gjson.GetBytes(jsonObject, depth) jsonString := gjson.GetBytes(jsonObject, depth)
if jsonString.Raw == "" { if jsonString.Raw == "" {
PrintError(errors.Errorf("path '%s' not found\n", depth)) return errors.Errorf("path '%s' not found\n", depth)
} else {
var data interface{}
if err := json.Unmarshal([]byte(jsonString.Raw), &data); err != nil {
PrintError(err)
} else {
PrintAnswer(data)
} }
var data any
err := json.Unmarshal([]byte(jsonString.Raw), &data)
if err != nil {
return err
} }
return PrintAnswer(data)
} }
-15
View File
@@ -1,15 +0,0 @@
package utils
import (
"ispctl/cfg"
"ispctl/service"
)
func CreateUpdateCommonConfig(stringToChange string, configuration cfg.CommonConfig) error {
if answer, err := service.Config.CreateUpdateCommonConfig(stringToChange, configuration); err != nil {
return err
} else if answer != nil {
PrintAnswer(answer)
}
return nil
}
-15
View File
@@ -1,15 +0,0 @@
package utils
import (
"ispctl/cfg"
"ispctl/service"
)
func CreateUpdateConfig(stringToChange string, configuration *cfg.Config) error {
if answer, err := service.Config.CreateUpdateConfig(stringToChange, configuration); err != nil {
return err
} else if answer != nil {
PrintAnswer(answer)
}
return nil
}
+172
View File
@@ -0,0 +1,172 @@
package command
import (
"encoding/csv"
"ispctl/bash"
"ispctl/command/utils"
"ispctl/model"
"os"
"strings"
"github.com/olekukonko/tablewriter"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
)
type VariablesService interface {
GetAllVariables() ([]model.Variable, error)
GetVariableByName(variableName string) (*model.Variable, error)
DeleteVariable(variableName string) error
UpsertVariables(vars []model.UpsertVariableRequest) error
}
type Variables struct {
service VariablesService
autoComplete AutoComplete
}
func NewVariables(service VariablesService, autoComplete AutoComplete) Variables {
return Variables{
service: service,
autoComplete: autoComplete,
}
}
func (c Variables) Command() *cli.Command {
return &cli.Command{
Name: "vars",
Usage: "manage variables",
Subcommands: []*cli.Command{
{
Name: "get",
Usage: "vars get <name>",
Action: c.getByName,
BashComplete: c.autoComplete.Complete(bash.VariableName, bash.Empty),
},
{
Name: "list",
Usage: "list all variables",
Action: c.list,
},
{
Name: "set",
Usage: "vars set <name> <value>",
Action: c.set,
Flags: []cli.Flag{
&cli.BoolFlag{Name: SecretFlagName, Usage: secretVariableFlagUsage},
},
BashComplete: c.autoComplete.Complete(bash.VariableName, bash.Empty),
},
{
Name: "delete",
Usage: "vars delete <name>",
Action: c.delete,
BashComplete: c.autoComplete.Complete(bash.VariableName, bash.Empty),
},
{
Name: "upload",
Usage: "vars upload <filepath>",
Action: c.upload,
},
},
}
}
func (c Variables) list(ctx *cli.Context) error {
vars, err := c.service.GetAllVariables()
if err != nil {
return err
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Name", "Description", "Type", "Value", "Configs"})
for _, v := range vars {
configs := make([]string, 0, len(v.ContainsInConfigs))
for _, c := range v.ContainsInConfigs {
configs = append(configs, c.Name)
}
table.Append([]string{v.Name, v.Description, v.Type, v.Value, strings.Join(configs, ",")})
}
table.SetBorder(true)
table.SetRowLine(true)
table.Render()
return nil
}
func (c Variables) getByName(ctx *cli.Context) error {
variableName := ctx.Args().Get(0)
variable, err := c.service.GetVariableByName(variableName)
if err != nil {
return err
}
return utils.PrintAnswer(variable)
}
func (c Variables) set(ctx *cli.Context) error {
variableName := ctx.Args().Get(0)
variableValue := ctx.Args().Get(1)
variableType := model.TextVariableType
if ctx.Bool(SecretFlagName) {
variableType = model.SecretVariableType
}
return c.service.UpsertVariables([]model.UpsertVariableRequest{{
Name: variableName,
Value: variableValue,
Type: variableType,
}})
}
func (c Variables) delete(ctx *cli.Context) error {
return c.service.DeleteVariable(ctx.Args().Get(0))
}
func (c Variables) upload(ctx *cli.Context) error {
variables, err := c.readVariablesFromCsv(ctx.Args().First())
if err != nil {
return err
}
return c.service.UpsertVariables(variables)
}
func (c Variables) readVariablesFromCsv(filepath string) ([]model.UpsertVariableRequest, error) {
file, err := os.Open(filepath)
if err != nil {
return nil, errors.WithMessagef(err, "failed to open file %s", filepath)
}
defer func() {
_ = file.Close()
}()
reader := csv.NewReader(file)
reader.TrimLeadingSpace = true
records, err := reader.ReadAll()
if err != nil {
return nil, errors.WithMessage(err, "failed to read CSV file")
}
if len(records) < 2 {
return nil, errors.New("CSV file must have a header and at least one data row")
}
header := records[0]
columnIndexes := map[string]int{}
for i, col := range header {
columnIndexes[strings.ToLower(col)] = i
}
for _, columnName := range []string{"name", "type", "value", "description"} {
_, ok := columnIndexes[columnName]
if !ok {
return nil, errors.Errorf("column '%s' is required", columnName)
}
}
variables := make([]model.UpsertVariableRequest, 0, len(records)-1)
for _, row := range records[1:] {
variables = append(variables, model.UpsertVariableRequest{
Name: row[columnIndexes["name"]],
Type: row[columnIndexes["type"]],
Value: row[columnIndexes["value"]],
Description: row[columnIndexes["description"]],
})
}
return variables, nil
}
-23
View File
@@ -1,23 +0,0 @@
package flag
import "fmt"
const (
hostName = "gateHost"
hostUsage = "isp-config-service address"
unsafeName = "unsafe"
unsafeUsage = "disable checking schema for set configuration"
outPrintName = "o"
OutPrintJsonValue = "json"
OutPrintHtmlValue = "html"
withCommonConfigName = "full"
withCommonConfigUsage = "compile data with common configs"
)
var (
outPrintStatusUsage = fmt.Sprintf("out print for status; %s", OutPrintJsonValue)
outPrintSchemaUsage = fmt.Sprintf("out print for schema; %s or %s", OutPrintJsonValue, OutPrintHtmlValue)
)
-36
View File
@@ -1,36 +0,0 @@
package flag
import (
"strings"
"github.com/urfave/cli/v2"
"ispctl/service"
)
var (
//---global---
Host = &cli.StringFlag{
Name: hostName,
Usage: hostUsage,
Value: "127.0.0.1:9002",
Required: false,
Aliases: []string{"g", "configAddr"},
}
Unsafe = &cli.BoolFlag{Name: unsafeName, Usage: unsafeUsage}
//---local---
OutPrintStatus = &cli.StringFlag{Name: outPrintName, Usage: outPrintStatusUsage}
OutPrintSchema = &cli.StringFlag{Name: outPrintName, Usage: outPrintSchemaUsage, Value: OutPrintJsonValue}
WithCommonConfig = &cli.BoolFlag{Name: withCommonConfigName, Usage: withCommonConfigUsage}
)
func CheckGlobal(c *cli.Context) error {
var (
host string
)
service.Config.UnsafeEnable = c.Bool(Unsafe.Name)
host = c.String(Host.Name)
host = strings.Replace(host, "'", "", -1)
return service.Config.ReceiveConfiguration(host)
}
+37 -34
View File
@@ -1,6 +1,6 @@
module ispctl module ispctl
go 1.23 go 1.27
require ( require (
github.com/go-git/go-billy/v5 v5.6.0 github.com/go-git/go-billy/v5 v5.6.0
@@ -10,10 +10,10 @@ require (
github.com/tidwall/gjson v1.17.3 github.com/tidwall/gjson v1.17.3
github.com/tidwall/sjson v1.2.5 github.com/tidwall/sjson v1.2.5
github.com/txix-open/bellows v1.2.0 github.com/txix-open/bellows v1.2.0
github.com/txix-open/isp-kit v1.39.0 github.com/txix-open/isp-kit v1.31.5-0.20261127095759-c39408f3bd58
github.com/urfave/cli/v2 v2.27.5 github.com/urfave/cli/v2 v2.27.5
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f
google.golang.org/grpc v1.67.1 google.golang.org/grpc v1.85.0
) )
require ( require (
@@ -22,62 +22,65 @@ require (
github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect github.com/buger/jsonparser v1.6.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect github.com/cloudflare/circl v1.3.7 // indirect
github.com/coder/websocket v1.8.12 // indirect github.com/coder/websocket v1.8.15 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/emirpasic/gods v1.18.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/compress v1.20.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.9.2 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pandatix/go-abnf v0.5.5 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_golang v1.25.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.60.1 // indirect github.com/prometheus/common v0.74.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect github.com/prometheus/procfs v0.23.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect github.com/skeema/knownhosts v1.2.2 // indirect
github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect github.com/tidwall/pretty v1.2.0 // indirect
github.com/txix-open/etp/v3 v3.2.0 // indirect github.com/txix-open/etp/v4 v4.1.3 // indirect
github.com/txix-open/jsonschema v1.2.0 // indirect github.com/txix-open/jsonschema v1.3.0 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect go.opentelemetry.io/otel v1.47.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
go.opentelemetry.io/otel/sdk v1.31.0 // indirect go.opentelemetry.io/otel/log v1.47.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/otel/metric v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.opentelemetry.io/otel/sdk v1.47.0 // indirect
go.opentelemetry.io/otel/trace v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.1 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect go.uber.org/zap v1.28.0 // indirect
golang.org/x/crypto v0.28.0 // indirect golang.org/x/crypto v0.59.0 // indirect
golang.org/x/mod v0.17.0 // indirect golang.org/x/mod v0.42.0 // indirect
golang.org/x/net v0.30.0 // indirect golang.org/x/net v0.63.0 // indirect
golang.org/x/sync v0.8.0 // indirect golang.org/x/sync v0.25.0 // indirect
golang.org/x/sys v0.26.0 // indirect golang.org/x/sys v0.50.0 // indirect
golang.org/x/text v0.19.0 // indirect golang.org/x/text v0.44.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect golang.org/x/tools v0.52.1-0.20261106145633-d407941a339a // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
google.golang.org/protobuf v1.35.1 // indirect google.golang.org/protobuf v1.36.12 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
+112 -90
View File
@@ -13,35 +13,36 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo= github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo=
github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc= github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc= github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA= github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0= github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
github.com/go-faker/faker/v4 v4.12.0 h1:yZXxuoQjxN+C2PVgYoDSHGiD9wj6dX1/Ful4p7QQV0k=
github.com/go-faker/faker/v4 v4.12.0/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8=
@@ -51,32 +52,35 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod
github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0/go.mod h1:FHXQZnW5pA0txiMr3jApv9uNJzZ+7mYZd+u+PPenCFU=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -86,12 +90,14 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.9.2/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -103,22 +109,23 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM=
github.com/pandatix/go-abnf v0.5.5/go.mod h1:AE0KD3/VNoCjGzc1gqetRKshbI4SYErXQ/8kPenR5mc=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
@@ -136,8 +143,9 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94= github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
@@ -149,14 +157,14 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY= github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o= github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/etp/v3 v3.2.0 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M= github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0= github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
github.com/txix-open/isp-kit v1.39.0 h1:NBV2oJJefH/qt2pcPrqEmYccJedjPaVCwr6Z955C+pg= github.com/txix-open/isp-kit v1.31.5-0.20261127095759-c39408f3bd58 h1:huhPwzaU5BBwfhXD0vkBNBNv1xhjvAvplEZ/dOK1osQ=
github.com/txix-open/isp-kit v1.39.0/go.mod h1:R4vwujGjMXLQir8MDDCfsDQa0CWGuZBSMakt5qcybgM= github.com/txix-open/isp-kit v1.31.5-0.20261127095759-c39408f3bd58/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s= github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
github.com/txix-open/jsonschema v1.2.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00= github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To= github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 h1:1jE11HLmMHDYYAcE+UmQ5VHgz4stzz0+daJbDWS+sEs=
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c= github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3/go.mod h1:Yf41v210LFyYAj+tGmDh7PHdGsTaZjdBzHG0ptUvihw=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
@@ -166,39 +174,51 @@ github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME= go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 h1:lUsI2TYsQw2r1IASwoROaCnjdj2cvC2+Jbxvk6nHnWU= go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0/go.mod h1:2HpZxxQurfGxJlJDblybejHB6RX6pmExPNe517hREw4= go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0=
go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw=
go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw=
go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM=
go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0=
go.opentelemetry.io/proto/otlp v1.11.1 h1:SCrPqH9NE5CmBrOqpjNCiT0X5mGwMyGERXdogfR7Yjw=
go.opentelemetry.io/proto/otlp v1.11.1/go.mod h1:wq8W4aSf6bOy8RZyESOeQFr9Pu7wydWX/TY4sgvrTPg=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI=
go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20261113113407-e3970619a1a4 h1:lfvjMWyv5q5oJgIhGfBDf7Szvu8POtgSpMy2XbXlEFs=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/exp v0.0.0-20261113113407-e3970619a1a4/go.mod h1:J3U+E8RzytcGvwz+uJuAP4zULJ2TkAQBnmPZMexpdXs=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
@@ -206,13 +226,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -226,15 +246,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= golang.org/x/term v0.48.0 h1:G6UU1eiSB8nl3DzeUGt7Mg+2SctI8tPS6Z5/mBt6cOk=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/term v0.48.0/go.mod h1:BRDLHCZr2SUjIeBHHpRyQeC9xzSAVbzY2rvKgafnHf4=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -242,23 +262,25 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.52.1-0.20261106145633-d407941a339a h1:Yqozs0FNPRoPGS4hNGlrNwRENWr5H5nVG9sN/f+5640=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.52.1-0.20261106145633-d407941a339a/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f/go.mod h1:CPxXEEQ1S9iJmInAF/8MNc8tKWnya8I8Kni9Zh2hV0M=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+44 -13
View File
@@ -4,10 +4,14 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"strings"
"ispctl/bash"
"ispctl/command"
"ispctl/repository"
"ispctl/service"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"ispctl/command"
"ispctl/flag"
) )
var version = "1.1.0" var version = "1.1.0"
@@ -22,20 +26,33 @@ func initCommands() {
app.Version = version app.Version = version
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
flag.Host, &cli.StringFlag{
flag.Unsafe, Name: command.HostFlagName,
Usage: command.HostFlagUsage,
Value: "127.0.0.1:9002",
Required: false,
Aliases: []string{"g", "configAddr"},
},
&cli.BoolFlag{
Name: command.UnsafeFlagName,
Usage: command.UnsafeFlagUsage,
},
} }
app.EnableBashCompletion = true app.EnableBashCompletion = true
app.Commands = []*cli.Command{
command.Status(), var configService service.Config
command.Get(), var autoComplete bash.Autocomplete
command.Set(), app.Before = func(ctx *cli.Context) error {
command.Delete(), service, err := configServiceFromGlobalFlags(ctx)
command.Schema(), if err != nil {
command.CommonConfig(), return err
command.Merge(),
command.GitGet(),
} }
configService = service
return nil
}
autoComplete = bash.NewAutocomplete(configServiceFromGlobalFlags)
app.Commands = command.AllCommands(&configService, autoComplete)
app.BashComplete = func(context *cli.Context) { app.BashComplete = func(context *cli.Context) {
for _, appCommand := range app.Commands { for _, appCommand := range app.Commands {
fmt.Println(appCommand.Name) fmt.Println(appCommand.Name)
@@ -47,3 +64,17 @@ func initCommands() {
log.Fatal(err) log.Fatal(err)
} }
} }
func configServiceFromGlobalFlags(ctx *cli.Context) (service.Config, error) {
enableUnsafe := ctx.Bool(command.UnsafeFlagName)
host := ctx.String(command.HostFlagName)
host = strings.ReplaceAll(host, "'", "")
configCli, err := repository.NewGrpcClientWithHost(host)
if err != nil {
return service.Config{}, err
}
configRepo := repository.NewConfig(configCli)
return service.NewConfig(enableUnsafe, configRepo), nil
}
+21
View File
@@ -0,0 +1,21 @@
package model
import "encoding/json"
// AuditModule is a module with its raw config schema; the raw form keeps the
// x-ui-exposed keyword that a typed unmarshal may drop.
type AuditModule struct {
Id string
Name string
ConfigSchema json.RawMessage
}
// AuditViolation names a config field that violates the secret policy in the
// module's active config: a UI-exposed field referencing a SECRET variable,
// or a sensitive field holding a plain value or a non-SECRET reference.
type AuditViolation struct {
Module string
Path string
Variables []string
Reason string
}
+5 -21
View File
@@ -1,4 +1,4 @@
package cfg package model
import ( import (
"time" "time"
@@ -7,12 +7,12 @@ import (
"github.com/txix-open/isp-kit/rc/schema" "github.com/txix-open/isp-kit/rc/schema"
) )
type getModuleByUuidAndNameRequest struct { type GetModuleByUuidAndNameRequest struct {
ModuleName string ModuleName string
Uuid string Uuid string
} }
type getSchemaByModuleIdRequest struct { type GetSchemaByModuleIdRequest struct {
ModuleId string ModuleId string
} }
@@ -24,7 +24,7 @@ type Config struct {
ModuleId string ModuleId string
Version int32 Version int32
Active bool Active bool
Data map[string]interface{} Data map[string]any
Unsafe bool Unsafe bool
} }
@@ -34,7 +34,7 @@ type CommonConfig struct {
Description string Description string
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
Data map[string]interface{} Data map[string]any
} }
type Connection struct { type Connection struct {
@@ -62,19 +62,3 @@ type ConfigSchema struct {
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
} }
type Deleted struct {
Deleted bool
Links Links
}
type Links map[string][]string
type identityRequest struct {
Id string
}
type CompileConfigs struct {
Data map[string]interface{}
CommonConfigsIdList []string
}
+42
View File
@@ -0,0 +1,42 @@
package model
import "github.com/pkg/errors"
var (
ErrModuleNotFound = errors.New("module not found")
ErrVariableNotFound = errors.New("variable not found")
)
const (
SecretVariableType = "SECRET"
TextVariableType = "TEXT"
ErrCodeModuleNotFound = 2001
ErrCodeConfigNotFound = 2002
ErrCodeVariableNotFound = 2006
)
type Variable struct {
Name string
Description string
Type string
Value string
ContainsInConfigs []LinkedConfig
}
type LinkedConfig struct {
Id string
ModuleId string
Name string
}
type UpsertVariableRequest struct {
Name string `validate:"required"`
Description string
Type string `validate:"required,oneof=SECRET TEXT"`
Value string `validate:"required"`
}
type VariableByNameRequest struct {
Name string `validate:"required"`
}
+14
View File
@@ -0,0 +1,14 @@
package repository
import (
"github.com/txix-open/isp-kit/grpc/client"
)
func NewGrpcClientWithHost(host string) (*client.Client, error) {
cli, err := client.Default()
if err != nil {
return nil, err
}
cli.Upgrade([]string{host})
return cli, nil
}
+193
View File
@@ -0,0 +1,193 @@
package repository
import (
"context"
"fmt"
"ispctl/model"
"strings"
epb "google.golang.org/genproto/googleapis/rpc/errdetails"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/apierrors"
"github.com/txix-open/isp-kit/grpc/client"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
const (
getAvailableConfigs = "config/module/get_modules_info"
getConfigByModuleName = "config/config/get_active_config_by_module_name"
createUpdateConfig = "config/config/create_update_config"
getSchemaByModuleId = "config/schema/get_by_module_id"
getAllVariables = "config/variable/all"
getVariableByName = "config/variable/get_by_name"
upsertVariable = "config/variable/upsert"
deleteVariable = "config/variable/delete"
)
type Config struct {
cli *client.Client
baseCtx context.Context
}
func NewConfig(cli *client.Client) Config {
return Config{
cli: cli,
baseCtx: context.Background(),
}
}
func (c Config) GetAvailableConfigs() ([]model.ModuleInfo, error) {
response := make([]model.ModuleInfo, 0)
err := c.cli.Invoke(getAvailableConfigs).
JsonResponseBody(&response).
Do(c.baseCtx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getAvailableConfigs)
}
return response, nil
}
func (c Config) GetAuditModules() ([]model.AuditModule, error) {
response := make([]model.AuditModule, 0)
err := c.cli.Invoke(getAvailableConfigs).
JsonResponseBody(&response).
Do(c.baseCtx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getAvailableConfigs)
}
return response, nil
}
func (c Config) GetConfigByModuleName(name string) (*model.Config, error) {
request := &model.GetModuleByUuidAndNameRequest{ModuleName: name}
response := new(model.Config)
err := c.cli.Invoke(getConfigByModuleName).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(c.baseCtx)
if err == nil {
return response, nil
}
if apiError := apierrors.FromError(err); apiError != nil {
if apiError.ErrorCode == model.ErrCodeModuleNotFound || apiError.ErrorCode == model.ErrCodeConfigNotFound {
return nil, model.ErrModuleNotFound
}
}
return nil, errors.WithMessagef(err, "call %s", getConfigByModuleName)
}
func (c Config) CreateUpdateConfig(request model.Config) (*model.Config, error) {
response := new(model.Config)
err := c.cli.Invoke(createUpdateConfig).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(c.baseCtx)
if err != nil {
return nil, c.handleCreateUpdateConfigError(err)
}
return response, nil
}
func (c Config) GetSchemaByModuleId(moduleId string) (*model.ConfigSchema, error) {
request := model.GetSchemaByModuleIdRequest{ModuleId: moduleId}
response := new(model.ConfigSchema)
err := c.cli.Invoke(getSchemaByModuleId).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(c.baseCtx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getSchemaByModuleId)
}
return response, nil
}
func (c Config) GetAllVariables() ([]model.Variable, error) {
response := make([]model.Variable, 0)
err := c.cli.Invoke(getAllVariables).
JsonResponseBody(&response).
Do(c.baseCtx)
if err != nil {
return nil, errors.WithMessagef(err, "call %s", getAllVariables)
}
return response, nil
}
func (c Config) GetVariableByName(variableName string) (*model.Variable, error) {
request := model.VariableByNameRequest{Name: variableName}
response := new(model.Variable)
err := c.cli.Invoke(getVariableByName).
JsonRequestBody(request).
JsonResponseBody(&response).
Do(c.baseCtx)
if err != nil {
return nil, c.handleVariableError(err, getVariableByName)
}
return response, nil
}
func (c Config) UpsertVariables(request []model.UpsertVariableRequest) error {
err := c.cli.Invoke(upsertVariable).
JsonRequestBody(request).
Do(c.baseCtx)
if err != nil {
return errors.WithMessagef(err, "call %s", upsertVariable)
}
return nil
}
func (c Config) DeleteVariable(variableName string) error {
request := model.VariableByNameRequest{Name: variableName}
err := c.cli.Invoke(deleteVariable).
JsonRequestBody(request).
Do(c.baseCtx)
if err != nil {
return c.handleVariableError(err, deleteVariable)
}
return nil
}
func (c Config) handleVariableError(err error, endpoint string) error {
apiError := apierrors.FromError(err)
if apiError == nil {
return errors.WithMessagef(err, "call %s", endpoint)
}
switch apiError.ErrorCode {
case model.ErrCodeVariableNotFound:
return model.ErrVariableNotFound
default:
return errors.WithMessagef(err, "call %s", endpoint)
}
}
func (c Config) handleCreateUpdateConfigError(err error) error {
errorStatus, ok := status.FromError(err)
if !ok || errorStatus.Code() != codes.InvalidArgument {
return errors.WithMessagef(err, "call %s", createUpdateConfig)
}
stringBuilder := strings.Builder{}
stringBuilder.WriteString("doesn't match with schema:\n")
apiErr := apierrors.FromError(err)
if apiErr != nil {
for field, desc := range apiErr.Details {
fmt.Fprintf(&stringBuilder, "%s | %s\n", field, desc)
}
} else {
for _, detail := range errorStatus.Details() {
switch d := detail.(type) {
case *epb.BadRequest:
for _, violation := range d.FieldViolations {
fmt.Fprintf(&stringBuilder, "%s | %s\n", violation.Field, violation.Description)
}
default:
fmt.Fprint(&stringBuilder, d)
}
}
}
return errors.New(stringBuilder.String())
}
+167
View File
@@ -0,0 +1,167 @@
package service
import (
"encoding/json"
"fmt"
"sort"
"ispctl/model"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/rc"
"github.com/txix-open/isp-kit/rc/schema"
)
// Audit reports the active configs that reference SECRET variables on
// UI-exposed fields. Those values were already rendered into module browsers,
// so the variables must be rotated.
func (c Config) Audit() ([]model.AuditViolation, error) {
modules, err := c.configRepo.GetAuditModules()
if err != nil {
return nil, err
}
variables, err := c.configRepo.GetAllVariables()
if err != nil {
return nil, err
}
secrets := make(map[string]struct{}, len(variables))
for _, variable := range variables {
if variable.Type == model.SecretVariableType {
secrets[variable.Name] = struct{}{}
}
}
violations := make([]model.AuditViolation, 0)
for _, module := range modules {
configuration, err := c.configRepo.GetConfigByModuleName(module.Name)
if err != nil {
if errors.Is(err, model.ErrModuleNotFound) {
continue // no active config — nothing to audit
}
return nil, err
}
moduleViolations, err := auditModule(module.Name, module.ConfigSchema, configuration.Data, secrets)
if err != nil {
return nil, errors.WithMessagef(err, "module [%s]", module.Name)
}
violations = append(violations, moduleViolations...)
}
sort.Slice(violations, func(i, j int) bool {
if violations[i].Module != violations[j].Module {
return violations[i].Module < violations[j].Module
}
return violations[i].Path < violations[j].Path
})
return violations, nil
}
// auditModule returns the violations of a single module: UI-exposed paths whose
// config references SECRET variables, and sensitive paths whose config value
// is not a single reference to a SECRET variable. The schema and the config
// are read with the shared isp-kit readers, in the same currency as the
// config-service secret policy. The reference report covers every string
// leaf, including composite JSON strings (report-only in stage 1).
func auditModule(moduleName string, schemaData json.RawMessage, configData map[string]any, secrets map[string]struct{}) ([]model.AuditViolation, error) {
var uiPaths, sensitivePaths []string
if len(schemaData) > 0 {
var err error
uiPaths, err = schema.UIExposedPaths(schemaData)
if err != nil {
return nil, err
}
sensitivePaths, err = schema.SensitivePaths(schemaData)
if err != nil {
return nil, err
}
}
uiSet := make(map[string]struct{}, len(uiPaths))
for _, path := range uiPaths {
uiSet[path] = struct{}{}
}
configBytes, err := json.Marshal(configData)
if err != nil {
return nil, errors.WithMessage(err, "marshal config data")
}
refs, err := rc.VariableRefReport(configBytes)
if err != nil {
return nil, err
}
violations := make([]model.AuditViolation, 0)
for path, names := range refs {
if _, isUI := uiSet[path]; !isUI {
continue
}
secretNames := make([]string, 0, len(names))
for _, name := range names {
if _, isSecret := secrets[name]; isSecret {
secretNames = append(secretNames, name)
}
}
if len(secretNames) == 0 {
continue
}
sort.Strings(secretNames)
violations = append(violations, model.AuditViolation{
Module: moduleName,
Path: path,
Variables: secretNames,
Reason: "secret variable in ui-exposed field",
})
}
if len(sensitivePaths) > 0 {
sensitiveSet := make(map[string]struct{}, len(sensitivePaths))
for _, path := range sensitivePaths {
sensitiveSet[path] = struct{}{}
}
values, err := leafValues(configBytes, sensitiveSet)
if err != nil {
return nil, err
}
for _, path := range sensitivePaths {
value, exists := values[path]
if !exists || value == "" {
continue // absent or empty field
}
if name, isRef := rc.SingleVariableRef(value); isRef {
if _, isSecret := secrets[name]; isSecret {
continue // a reference to a SECRET variable is compliant
}
violations = append(violations, model.AuditViolation{
Module: moduleName,
Path: path,
Variables: []string{name},
Reason: fmt.Sprintf("references non-SECRET variable %s", name),
})
continue
}
// A plain value, including composite JSON strings, is reported
// (report-only in stage 1, the write policy does not apply to
// composite strings).
violations = append(violations, model.AuditViolation{
Module: moduleName,
Path: path,
Variables: []string{},
Reason: "plain value in sensitive field",
})
}
}
return violations, nil
}
// leafValues collects the raw values of the config's string leaves located at
// the given canonical paths.
func leafValues(data []byte, paths map[string]struct{}) (map[string]string, error) {
values := make(map[string]string, len(paths))
_, err := rc.TransformStringLeaves(data, func(path, value string) string {
if _, want := paths[path]; want {
values[path] = value
}
return value
})
return values, err
}
-7
View File
@@ -1,7 +0,0 @@
package service
import "ispctl/cfg"
var (
ConfigClient = cfg.NewConfigClient()
)
+71 -216
View File
@@ -2,61 +2,71 @@ package service
import ( import (
"encoding/json" "encoding/json"
"fmt"
"os" "ispctl/model"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/txix-open/isp-kit/rc/schema" "github.com/txix-open/isp-kit/rc/schema"
epb "google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"ispctl/cfg"
) )
var Config configService // configRepo is the config-service API surface consumed by Config. It is an
// interface so tests can substitute a fake; production passes the concrete
type configService struct { // repository.Config, which satisfies it.
UnsafeEnable bool type configRepo interface {
GetAvailableConfigs() ([]model.ModuleInfo, error)
GetAuditModules() ([]model.AuditModule, error)
GetConfigByModuleName(name string) (*model.Config, error)
CreateUpdateConfig(request model.Config) (*model.Config, error)
GetSchemaByModuleId(moduleId string) (*model.ConfigSchema, error)
GetAllVariables() ([]model.Variable, error)
GetVariableByName(variableName string) (*model.Variable, error)
UpsertVariables(request []model.UpsertVariableRequest) error
DeleteVariable(variableName string) error
} }
func (c configService) ReceiveConfiguration(host string) error { type Config struct {
return ConfigClient.ReceiveConfig(host) enableUnsafe bool
configRepo configRepo
} }
func (c configService) GetAvailableConfigs() ([]cfg.ModuleInfo, error) { func NewConfig(enableUnsafe bool, configRepo configRepo) Config {
return ConfigClient.GetAvailableConfigs() return Config{
enableUnsafe: enableUnsafe,
configRepo: configRepo,
}
} }
func (c configService) GetConfigurationByModuleName(moduleName string) (*cfg.Config, error) { func (c Config) GetAvailableConfigs() ([]model.ModuleInfo, error) {
return c.configRepo.GetAvailableConfigs()
}
func (c Config) GetConfigurationByModuleName(moduleName string) (*model.Config, error) {
if moduleName == "" { if moduleName == "" {
return nil, errors.New("need module name") return nil, errors.New("need module name")
} }
if moduleConfiguration, err := ConfigClient.GetConfigByModuleName(moduleName); err != nil { moduleConfiguration, err := c.configRepo.GetConfigByModuleName(moduleName)
if errorStatus, ok := status.FromError(err); ok { switch {
switch errorStatus.Code() { case errors.Is(err, model.ErrModuleNotFound):
case codes.NotFound:
return nil, errors.Errorf("module [%s] not found", moduleName) return nil, errors.Errorf("module [%s] not found", moduleName)
} default:
} return moduleConfiguration, err
return nil, err
} else {
return moduleConfiguration, nil
} }
} }
func (c configService) GetSchemaByModuleId(moduleId string) (schema.Schema, error) { func (c Config) GetSchemaByModuleId(moduleId string) (schema.Schema, error) {
if configSchema, err := ConfigClient.GetSchemaByModuleId(moduleId); err != nil { configSchema, err := c.configRepo.GetSchemaByModuleId(moduleId)
if err != nil {
return nil, err return nil, err
} else { }
return configSchema.Schema, nil return configSchema.Schema, nil
} }
}
func (c configService) CreateUpdateConfig(stringToChange string, configuration *cfg.Config) (map[string]interface{}, error) { func (c Config) CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error) {
newData := make(map[string]interface{}) newData := make(map[string]any)
if stringToChange != "" { if stringToChange != "" {
if err := json.Unmarshal([]byte(stringToChange), &newData); err != nil { err := json.Unmarshal([]byte(stringToChange), &newData)
if err != nil {
return nil, err return nil, err
} }
} }
@@ -65,204 +75,49 @@ func (c configService) CreateUpdateConfig(stringToChange string, configuration *
return c.CreateUpdateConfigV2(configuration) return c.CreateUpdateConfigV2(configuration)
} }
func (c configService) CreateUpdateConfigV2(configuration *cfg.Config) (map[string]interface{}, error) { func (c Config) CreateUpdateConfigV2(configuration *model.Config) (map[string]any, error) {
configuration.Unsafe = c.UnsafeEnable configuration.Unsafe = c.enableUnsafe
if resp, err := ConfigClient.CreateUpdateConfig(*configuration); err != nil { resp, err := c.configRepo.CreateUpdateConfig(*configuration)
if errorStatus, ok := status.FromError(err); ok { if err != nil {
switch errorStatus.Code() {
case codes.InvalidArgument:
fmt.Print("doesn't match with schema:\n")
defer func() {
os.Exit(1)
}()
for _, value := range errorStatus.Details() {
if a, ok := value.(*epb.BadRequest); ok {
for _, value := range a.FieldViolations {
fmt.Printf("%s | %s\n", value.Field, value.Description)
}
} else {
fmt.Println(value)
}
return nil, nil
}
}
}
return nil, err return nil, err
} else { }
return resp.Data, nil return resp.Data, nil
} }
func (c Config) GetAllVariables() ([]model.Variable, error) {
return c.configRepo.GetAllVariables()
} }
func (c configService) UpdateConfigAndGetLinkCommon(configuration cfg.Config) ([]string, error) { func (c Config) GetVariableByName(variableName string) (*model.Variable, error) {
if resp, err := ConfigClient.CreateUpdateConfig(configuration); err != nil { if variableName == "" {
return nil, errors.New("need variable name")
}
variable, err := c.configRepo.GetVariableByName(variableName)
switch {
case errors.Is(err, model.ErrVariableNotFound):
return nil, errors.Errorf("variable [%s] not found", variableName)
case err != nil:
return nil, err return nil, err
} else { default:
return resp.CommonConfigs, nil return variable, nil
} }
} }
func (c configService) GetCommonConfigByName(configName string) (cfg.CommonConfig, error) { func (c Config) DeleteVariable(variableName string) error {
if commonConfigs, err := c.GetMapNameCommonConfig(); err != nil { if variableName == "" {
return cfg.CommonConfig{}, err return errors.New("need variable name")
} else if config, ok := commonConfigs[configName]; !ok {
return cfg.CommonConfig{}, errors.Errorf("common config [%s] not found", configName)
} else {
return config, nil
}
} }
func (c configService) GetMapNameCommonConfig() (map[string]cfg.CommonConfig, error) { err := c.configRepo.DeleteVariable(variableName)
collection, err := ConfigClient.GetCommonConfigs([]string{}) switch {
if err != nil { case errors.Is(err, model.ErrVariableNotFound):
return nil, err return errors.Errorf("variable [%s] not found", variableName)
} default:
response := make(map[string]cfg.CommonConfig)
for _, config := range collection {
response[config.Name] = config
}
return response, nil
}
func (c configService) CreateUpdateCommonConfig(stringToChange string, config cfg.CommonConfig) (map[string]interface{}, error) {
newData := make(map[string]interface{})
if stringToChange != "" {
if err := json.Unmarshal([]byte(stringToChange), &newData); err != nil {
return nil, err
}
}
config.Data = newData
if resp, err := ConfigClient.CreateUpdateCommonConfig(config); err != nil {
return nil, err
} else {
return resp.Data, nil
}
}
func (c configService) DeleteCommonConfig(configId string) ([]string, bool, error) {
deletedInfo, err := ConfigClient.DeleteCommonConfig(configId)
if err != nil {
return nil, false, err
}
arrayOfModuleName := make([]string, 0)
for moduleName := range deletedInfo.Links {
arrayOfModuleName = append(arrayOfModuleName, moduleName)
}
return arrayOfModuleName, deletedInfo.Deleted, nil
}
func (c configService) GetLinksCommonConfig(configId string) ([]string, error) {
link, err := ConfigClient.GetLinksCommonConfig(configId)
if err != nil {
return nil, err
}
arrayOfModuleName := make([]string, 0)
for moduleName := range *link {
arrayOfModuleName = append(arrayOfModuleName, moduleName)
}
return arrayOfModuleName, nil
}
func (c configService) CompileDataWithCommonConfigs(
data map[string]interface{}, commonConfigs []string) (map[string]interface{}, error) {
req := cfg.CompileConfigs{
Data: data,
CommonConfigsIdList: commonConfigs,
}
var err error
data, err = ConfigClient.CompileCommonConfigs(req)
if err != nil {
return nil, err
} else {
return data, nil
}
}
func (c configService) UnlinkCommonConfigFromModule(configName, moduleName string) error {
return c.linked(configName, moduleName,
func(configId string, configIdentities []string) (bool, []string) {
needUnlink := false
for i, id := range configIdentities {
if configId == id {
copy(configIdentities[i:], configIdentities[i+1:])
configIdentities[len(configIdentities)-1] = ""
configIdentities = configIdentities[:len(configIdentities)-1]
needUnlink = true
break
}
}
return needUnlink, configIdentities
})
}
func (c configService) LinkCommonConfigToModule(configName, moduleName string) error {
return c.linked(configName, moduleName,
func(configId string, configIdentities []string) (bool, []string) {
needLink := true
for _, id := range configIdentities {
if configId == id {
needLink = false
break
}
}
if needLink {
configIdentities = append(configIdentities, configId)
}
return needLink, configIdentities
})
}
func (c configService) linked(configName, moduleName string,
linkHandler func(configId string, configIdentities []string) (bool, []string)) error {
if configName == "" {
return errors.New("empty config name")
}
if moduleName == "" {
return errors.New("empty module name")
}
commonConfigs, err := c.GetMapNameCommonConfig()
if err != nil {
return err return err
} }
config, ok := commonConfigs[configName]
if !ok {
return errors.Errorf("common config [%s] not found", configName)
} }
moduleConfig, err := c.GetConfigurationByModuleName(moduleName) func (c Config) UpsertVariables(vars []model.UpsertVariableRequest) error {
if err != nil { return c.configRepo.UpsertVariables(vars)
return err
}
configIdConfigNameMap := make(map[string]string)
for name, value := range commonConfigs {
configIdConfigNameMap[value.Id] = name
}
needUpdate, newCommonConfigs := linkHandler(config.Id, moduleConfig.CommonConfigs)
if needUpdate {
moduleConfig.CommonConfigs = newCommonConfigs
if linked, err := c.UpdateConfigAndGetLinkCommon(*moduleConfig); err != nil {
return err
} else {
fmt.Printf("module [%s] have next link:\n", moduleName)
for _, name := range linked {
fmt.Printf("[%s] ", configIdConfigNameMap[name])
}
fmt.Printf("\n")
}
} else {
fmt.Printf("module [%s] have next link:\n", moduleName)
for _, name := range moduleConfig.CommonConfigs {
fmt.Printf("[%s] ", configIdConfigNameMap[name])
}
fmt.Printf("\n")
}
return nil
} }
+277
View File
@@ -0,0 +1,277 @@
package tests_test
import (
"encoding/json"
"errors"
"reflect"
"testing"
"ispctl/model"
"ispctl/service"
)
// fakeConfigRepo implements the service.configRepo contract with static data;
// only the methods used by Audit are backed by real values.
type fakeConfigRepo struct {
modules []model.AuditModule
configs map[string]*model.Config // keyed by module name
variables []model.Variable
}
func (r *fakeConfigRepo) GetAvailableConfigs() ([]model.ModuleInfo, error) {
return nil, errors.New("not used in tests")
}
func (r *fakeConfigRepo) GetAuditModules() ([]model.AuditModule, error) {
return r.modules, nil
}
func (r *fakeConfigRepo) GetConfigByModuleName(name string) (*model.Config, error) {
config, ok := r.configs[name]
if !ok {
return nil, model.ErrModuleNotFound
}
return config, nil
}
func (r *fakeConfigRepo) CreateUpdateConfig(request model.Config) (*model.Config, error) {
return nil, errors.New("not used in tests")
}
func (r *fakeConfigRepo) GetSchemaByModuleId(moduleId string) (*model.ConfigSchema, error) {
return nil, errors.New("not used in tests")
}
func (r *fakeConfigRepo) GetAllVariables() ([]model.Variable, error) {
return r.variables, nil
}
func (r *fakeConfigRepo) GetVariableByName(variableName string) (*model.Variable, error) {
return nil, model.ErrVariableNotFound
}
func (r *fakeConfigRepo) UpsertVariables(request []model.UpsertVariableRequest) error {
return errors.New("not used in tests")
}
func (r *fakeConfigRepo) DeleteVariable(variableName string) error {
return errors.New("not used in tests")
}
// secretAndTextVariables is the default variable set: s1 is SECRET, t1 is TEXT.
func secretAndTextVariables() []model.Variable {
return []model.Variable{
{Name: "s1", Type: model.SecretVariableType},
{Name: "t1", Type: model.TextVariableType},
}
}
// objectSchema marshals a properties map into a minimal JSON schema.
func objectSchema(t *testing.T, properties map[string]any) json.RawMessage {
t.Helper()
schema, err := json.Marshal(map[string]any{
"type": "object",
"properties": properties,
})
if err != nil {
t.Fatal(err)
}
return schema
}
// auditFixture wires a single module m1 through the public Audit API and
// returns its violations.
func auditFixture(t *testing.T, schemaData json.RawMessage, configData map[string]any) []model.AuditViolation {
t.Helper()
repo := &fakeConfigRepo{
modules: []model.AuditModule{{Id: "id-1", Name: "m1", ConfigSchema: schemaData}},
configs: map[string]*model.Config{"m1": {Name: "m1", Data: configData}},
variables: secretAndTextVariables(),
}
violations, err := service.NewConfig(false, repo).Audit()
if err != nil {
t.Fatalf("Audit: %v", err)
}
return violations
}
func requireAuditViolations(t *testing.T, got, want []model.AuditViolation) {
t.Helper()
if !reflect.DeepEqual(got, want) {
t.Fatalf("violations = %v, want %v", got, want)
}
}
func TestAuditModuleIntersection(t *testing.T) {
t.Parallel()
schema := objectSchema(t, map[string]any{
"ui": map[string]any{"type": "string", "x-ui-exposed": true},
"plain": map[string]any{"type": "string"},
})
configData := map[string]any{
"ui": "_Var(s1) _Var(t1)",
"plain": "_Var(s1)",
}
violations := auditFixture(t, schema, configData)
// Only the UI leaf with the secret reference is reported; the same
// reference in the plain leaf and the TEXT reference in the UI leaf are
// not.
want := []model.AuditViolation{{
Module: "m1",
Path: "$.ui",
Variables: []string{"s1"},
Reason: "secret variable in ui-exposed field",
}}
requireAuditViolations(t, violations, want)
}
func TestAuditModuleSecretOutsideUI(t *testing.T) {
t.Parallel()
schema := objectSchema(t, map[string]any{
"plain": map[string]any{"type": "string"},
})
violations := auditFixture(t, schema, map[string]any{"plain": "_Var(s1)"})
if len(violations) != 0 {
t.Fatalf("violations = %v, want none: a secret outside ui-exposed fields is not a violation", violations)
}
}
func TestAuditModuleArrayPath(t *testing.T) {
t.Parallel()
schema := objectSchema(t, map[string]any{
"clients": map[string]any{
"type": "array",
"items": map[string]any{"type": "string", "x-ui-exposed": true},
},
})
configData := map[string]any{
"clients": []any{"_Var(s1)", "nope"},
}
violations := auditFixture(t, schema, configData)
want := []model.AuditViolation{{Module: "m1", Path: "$.clients[]", Variables: []string{"s1"}, Reason: "secret variable in ui-exposed field"}}
requireAuditViolations(t, violations, want)
}
func TestAuditModuleCompositeReported(t *testing.T) {
// the report covers references hidden inside composite JSON strings
// (report-only in stage 1, the policy itself does not apply to them)
t.Parallel()
schema := objectSchema(t, map[string]any{
"secrets": map[string]any{"type": "string", "x-ui-exposed": true},
})
composite, err := json.Marshal(map[string]any{"a": "_Var(s1)"})
if err != nil {
t.Fatal(err)
}
configData := map[string]any{
"secrets": string(composite),
}
violations := auditFixture(t, schema, configData)
want := []model.AuditViolation{{Module: "m1", Path: "$.secrets", Variables: []string{"s1"}, Reason: "secret variable in ui-exposed field"}}
requireAuditViolations(t, violations, want)
}
func TestAuditModuleEmptySchema(t *testing.T) {
t.Parallel()
violations := auditFixture(t, nil, map[string]any{"a": "_Var(s1)"})
if len(violations) != 0 {
t.Fatalf("violations = %v, want none: an empty schema exposes no fields", violations)
}
}
func sensitiveTestSchema(t *testing.T) json.RawMessage {
t.Helper()
schema, err := json.Marshal(map[string]any{
"type": "object",
"properties": map[string]any{
"token": map[string]any{"type": "string", "x-sensitive": true},
},
})
if err != nil {
t.Fatal(err)
}
return schema
}
func TestAuditModuleSensitiveLiteral(t *testing.T) {
t.Parallel()
violations := auditFixture(t, sensitiveTestSchema(t), map[string]any{"token": "legacy-pass-123"})
want := []model.AuditViolation{{
Module: "m1",
Path: "$.token",
Variables: []string{},
Reason: "plain value in sensitive field",
}}
requireAuditViolations(t, violations, want)
}
func TestAuditModuleSensitiveNonSecretRef(t *testing.T) {
t.Parallel()
violations := auditFixture(t, sensitiveTestSchema(t), map[string]any{"token": "_Var(t1)"})
want := []model.AuditViolation{{
Module: "m1",
Path: "$.token",
Variables: []string{"t1"},
Reason: "references non-SECRET variable t1",
}}
requireAuditViolations(t, violations, want)
}
func TestAuditModuleSensitiveCompliant(t *testing.T) {
for name, config := range map[string]string{
"secret reference": `{"token": "_Var(s1)"}`,
"empty value": `{"token": ""}`,
"absent field": `{}`,
} {
t.Run(name, func(t *testing.T) {
t.Parallel()
var configData map[string]any
if err := json.Unmarshal([]byte(config), &configData); err != nil {
t.Fatal(err)
}
violations := auditFixture(t, sensitiveTestSchema(t), configData)
if len(violations) != 0 {
t.Fatalf("violations = %v, want none", violations)
}
})
}
}
func TestAuditModuleBothClasses(t *testing.T) {
t.Parallel()
schema := objectSchema(t, map[string]any{
"secrets": map[string]any{"type": "string", "x-ui-exposed": true},
"token": map[string]any{"type": "string", "x-sensitive": true},
})
configData := map[string]any{"secrets": "_Var(s1)", "token": "plain-pass"}
violations := auditFixture(t, schema, configData)
want := []model.AuditViolation{
{Module: "m1", Path: "$.secrets", Variables: []string{"s1"}, Reason: "secret variable in ui-exposed field"},
{Module: "m1", Path: "$.token", Variables: []string{}, Reason: "plain value in sensitive field"},
}
requireAuditViolations(t, violations, want)
}
func TestAuditSkipsModuleWithoutActiveConfig(t *testing.T) {
t.Parallel()
repo := &fakeConfigRepo{
modules: []model.AuditModule{{Id: "id-1", Name: "m1", ConfigSchema: sensitiveTestSchema(t)}},
variables: secretAndTextVariables(),
}
// no entry in repo.configs: GetConfigByModuleName reports ErrModuleNotFound
violations, err := service.NewConfig(false, repo).Audit()
if err != nil {
t.Fatalf("Audit: %v", err)
}
if len(violations) != 0 {
t.Fatalf("violations = %v, want none: a module without an active config is skipped", violations)
}
}