Compare commits
15
Commits
main
...
txix-release
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
048ac60d83 | ||
|
|
aff6aefec6 | ||
|
|
b7b9a303ba | ||
|
|
791c9c4b95 | ||
|
|
0ebfca905d | ||
|
|
922641647a | ||
|
|
dbf061213d | ||
|
|
01a9efc965 | ||
|
|
84c24a31be | ||
|
|
2c77dc0b2b | ||
|
|
09f3c76f20 | ||
|
|
74f3ea35cc | ||
|
|
2e09ff7b95 | ||
|
|
63ad9bb620 | ||
|
|
13803ab804 |
No files matched your search
+62
@@ -1,3 +1,59 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff:
|
||||||
|
/.idea/
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
*.iml
|
||||||
|
convert_service
|
||||||
|
convert-service
|
||||||
|
|
||||||
|
# Sensitive or high-churn files:
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
|
||||||
|
# Gradle:
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-debug/
|
||||||
|
cmake-build-release/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin:
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
## File-based project format:
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
### Go template
|
||||||
# Binaries for programs and plugins
|
# Binaries for programs and plugins
|
||||||
*.exe
|
*.exe
|
||||||
*.exe~
|
*.exe~
|
||||||
@@ -10,3 +66,9 @@
|
|||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
|
/node_modules/
|
||||||
|
/vendor/
|
||||||
|
google/
|
||||||
|
package.json
|
||||||
|
yarn.lock
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
include:
|
||||||
|
- project: '$CI_PROJECT_PATH'
|
||||||
|
file: '/ci-isp-utils.yml'
|
||||||
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
### 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.0
|
||||||
|
* добавлена поддержка тегов для `gitget`
|
||||||
|
### v3.1.1
|
||||||
|
* добавлена совместимость isp-config-service 3.x.x
|
||||||
|
### v2.2.3
|
||||||
|
* updated dependencies
|
||||||
|
### v2.2.2
|
||||||
|
* updated isp-lib
|
||||||
|
### v2.2.1
|
||||||
|
* updated isp-lib
|
||||||
|
* updated isp-event-lib
|
||||||
|
## v2.2.0
|
||||||
|
* fix json output
|
||||||
|
* migrate to go mod
|
||||||
|
* update libs
|
||||||
|
## v2.1.2
|
||||||
|
* fix output '\u0026' instead '&'
|
||||||
|
## v2.1.0
|
||||||
|
* add output format for `status`
|
||||||
|
## v2.0.1
|
||||||
|
* print module version in `status` command
|
||||||
|
## v2.0.0
|
||||||
|
* add integration with isp-config-service 2.0
|
||||||
|
## v1.2.4
|
||||||
|
* migrate invoke to config service
|
||||||
|
## v1.2.3
|
||||||
|
* read configuration from `stdin` till `EOF`
|
||||||
|
## v1.2.2
|
||||||
|
* fix stack overflow
|
||||||
|
## v1.2.1
|
||||||
|
* fix bash complete with flag
|
||||||
|
* fix schema display to html
|
||||||
|
## v1.2.0
|
||||||
|
* add new command `schema`
|
||||||
|
* add bash complete
|
||||||
|
## v1.1.0
|
||||||
|
* fix status response
|
||||||
|
* add checking schema to set configuration
|
||||||
|
* add unsafe flag
|
||||||
|
* update readme
|
||||||
|
## v1.0.1
|
||||||
|
* fix spaces in strings
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
FROM golang:1.24-alpine3.21 as builder
|
||||||
|
WORKDIR /build
|
||||||
|
ARG version
|
||||||
|
ENV version_env=$version
|
||||||
|
ARG app_name
|
||||||
|
ENV app_name_env=$app_name
|
||||||
|
COPY . .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||||
|
--mount=type=bind,source=go.sum,target=go.sum \
|
||||||
|
--mount=type=bind,source=go.mod,target=go.mod \
|
||||||
|
go mod download -x
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
||||||
|
--mount=type=bind,target=. \
|
||||||
|
go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
||||||
|
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
RUN apk add --no-cache tzdata bash-completion jq
|
||||||
|
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||||
|
RUN echo "Europe/Moscow" > /etc/timezone
|
||||||
|
|
||||||
|
ARG app_name
|
||||||
|
ENV app_name_env=$app_name
|
||||||
|
COPY --from=builder main /usr/bin/$app_name_env
|
||||||
|
COPY /conf/config.yml /etc/$app_name_env/config.yml
|
||||||
|
COPY /static/autocomplete /etc/bash_completion.d/$app_name_env
|
||||||
|
|
||||||
|
CMD ["exec $app_name_env"]
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
|
||||||
|
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.24 git
|
||||||
|
WORKDIR /build
|
||||||
|
ARG version
|
||||||
|
ENV version_env=$version
|
||||||
|
ARG app_name
|
||||||
|
ENV app_name_env=$app_name
|
||||||
|
COPY . .
|
||||||
|
ENV GOPROXY=https://repo-mirror.mos.ru/repository/go-public
|
||||||
|
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
||||||
|
|
||||||
|
|
||||||
|
FROM dockerhub.mos.ru/mosos/arbat:15.5
|
||||||
|
|
||||||
|
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||||
|
RUN echo "Europe/Moscow" > /etc/timezone
|
||||||
|
|
||||||
|
ARG UID=10001
|
||||||
|
RUN useradd \
|
||||||
|
--home "/nonexistent" \
|
||||||
|
--shell "/sbin/nologin" \
|
||||||
|
--no-create-home \
|
||||||
|
--uid "${UID}" \
|
||||||
|
--user-group \
|
||||||
|
appuser
|
||||||
|
|
||||||
|
RUN mkdir -p /app/data
|
||||||
|
RUN chown appuser:appuser /app/data
|
||||||
|
VOLUME /app/data
|
||||||
|
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ARG app_name
|
||||||
|
ENV app_name_env=$app_name
|
||||||
|
COPY --from=builder main /app/$app_name_env
|
||||||
|
COPY /conf/config.yml /etc/$app_name_env/config.yml
|
||||||
|
COPY /static/autocomplete /etc/bash_completion.d/$app_name_env
|
||||||
|
|
||||||
|
CMD ["exec $app_name_env"]
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
||||||
@@ -0,0 +1,509 @@
|
|||||||
|
# ispctl
|
||||||
|
|
||||||
|
Консольная утилита для получения и переопределения конфигруации модулей isp
|
||||||
|
|
||||||
|
* [Требования](#Требования)
|
||||||
|
* [Установка](#Установка)
|
||||||
|
* [Конфигурация](#Конфигурация)
|
||||||
|
* [Использование](#Использование)
|
||||||
|
* [Описание](#Описание)
|
||||||
|
* [Примеры](#Пример)
|
||||||
|
- [ispctl status](#ispctl-status)
|
||||||
|
- [ispctl get](#ispctl-get)
|
||||||
|
- [ispctl set](#ispctl-set)
|
||||||
|
- [ispctl delete](#ispctl-delete)
|
||||||
|
- [ispctl schema](#ispctl-schema)
|
||||||
|
- [ispctl merge](#ispctl-merge)
|
||||||
|
- [ispctl gitget](#ispctl-gitget)
|
||||||
|
- [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
|
||||||
|
|
||||||
|
## Установка
|
||||||
|
```bash
|
||||||
|
yum install ispctl
|
||||||
|
```
|
||||||
|
|
||||||
|
## Использование
|
||||||
|
```bash
|
||||||
|
ispctl [flag...] status [local_flag]
|
||||||
|
ispctl [flag...] get module_name property_path [local_flag]
|
||||||
|
ispctl [flag...] set module_name property_path [new_object]
|
||||||
|
ispctl [flag...] delete module_name property_path
|
||||||
|
ispctl [flag...] schema module_name [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` | возвращает доступные конфигурации модулей, их состояния и подключения |
|
||||||
|
| `get` | возвращает объект конфигурации указанного модуля |
|
||||||
|
| `set` | изменяет объект конфигурации указанного модуля |
|
||||||
|
| `delete` | удаляет объект конфигурации указанного модуля |
|
||||||
|
| `merge` | поблочно производит слияние конфигурации модуля с json конфигом через stdin |
|
||||||
|
| `gitget` | скачивает из репозитория указанный файлы с указанного комита |
|
||||||
|
| `schema` | возвращает схему конфигурации указанного модуля |
|
||||||
|
| `vars get` | выводит информацию о переменной в json формате |
|
||||||
|
| `vars list` | выводит список переменных в виде ASCII-таблицы |
|
||||||
|
| `vars set` | изменяет значение переменной |
|
||||||
|
| `vars delete` | удаляет переменную по имени |
|
||||||
|
| `vars upload` | загружает переменные из csv файла |
|
||||||
|
| | |
|
||||||
|
|
||||||
|
| Флаги | Параметры | Описание |
|
||||||
|
| --------- | --------- | ------------------------------------------------------ |
|
||||||
|
| `-g` | string | адрес isp-config-service |
|
||||||
|
| `-unsafe` | | отключает проверку схемы перед изменением конфигурации |
|
||||||
|
| | | |
|
||||||
|
|
||||||
|
| Аргументы | Описание |
|
||||||
|
| ----------------- | ------------------------------------------------------------------------------------------------------ |
|
||||||
|
| `module_name` | Название модуля с которым происходит взаимодействие |
|
||||||
|
| `property_path` | Путь к объекту конфигурации, при значении `.` работа происходит со всей конфигурацией модуля |
|
||||||
|
| `new_object` | Новый объект, значение должно быть экранировано с помощью `' '`, при отсутсвии ожидается ввод из stdin |
|
||||||
|
| `variable_name` | Название переменной с которой происходит взаимодействие |
|
||||||
|
| `variable_value` | Значение переменной |
|
||||||
|
| `csv_filepath` | Путь к csv файлу с переменными для загрузки |
|
||||||
|
| | |
|
||||||
|
|
||||||
|
| Локальные флаги | Параметры | Команды | Описание |
|
||||||
|
| --------------- | --------- | -------- |------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `-o` | string | schema | определяет формат вывода схемы в stdout; по умолчанию `json`; возможные значения `json`, `html` |
|
||||||
|
| `-full` | bool | get | осуществляет взаимодействие с объектами конфигурации модуля с учетом объектом общих конфигураций, которые имеют связь с модулем |
|
||||||
|
| `-secret` | bool | vars set | устанавливает тип переменной в SECRET |
|
||||||
|
| | | | |
|
||||||
|
|
||||||
|
## Пример
|
||||||
|
|
||||||
|
### ispctl status
|
||||||
|
`ispctl [flag...] status [local_flag]`
|
||||||
|
|
||||||
|
`[local_flag]` - локальный флаг `-o` определяет формат вывода доступных конфигураций и состояний модулей. Доступные значения: `json`.
|
||||||
|
По умолчанию вывод осуществляется в виде таблицы.
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl status
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
MODULE NAME | STATUS | ADDRESSES
|
||||||
|
+------------------------+---------------+-------------------------+
|
||||||
|
admin | CONNECTED | 127.0.0.1
|
||||||
|
auth | NOT_CONNECTED |
|
||||||
|
config | CONNECTED | 127.0.0.1
|
||||||
|
converter | CONNECTED | 127.0.0.1
|
||||||
|
journal | NOT_CONNECTED |
|
||||||
|
```
|
||||||
|
|
||||||
|
### ispctl get
|
||||||
|
`ispctl [flag...] get module_name property_path`
|
||||||
|
* Получение полной конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl get example .
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"journal": {
|
||||||
|
"bufferSize": 4092,
|
||||||
|
"compress": true,
|
||||||
|
"enable": false,
|
||||||
|
"enableRemoteTransfer": true,
|
||||||
|
"filename": "/var/log/example-service/runtime.log",
|
||||||
|
"maxSizeMb": 512,
|
||||||
|
"rotateTimeoutMs": 86400000
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"path": "/metrics",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 2,
|
||||||
|
"memory": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* Получение конкретного объекта конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl get example .metrics.address
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"path": "/metrics",
|
||||||
|
"port": 1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### ispctl set
|
||||||
|
`ispctl [flag...] set module_name property_path [new_object]`
|
||||||
|
|
||||||
|
При указании `new_object` необходимо его экранировать. При его отсутсвии ожидается ввод из `stdin` до `EOF`
|
||||||
|
|
||||||
|
* Вставка нового поля в объект конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl set example .metrics.newField '"1000"'
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"journal": {
|
||||||
|
"bufferSize": 4092,
|
||||||
|
"compress": true,
|
||||||
|
"enable": false,
|
||||||
|
"enableRemoteTransfer": true,
|
||||||
|
"filename": "/var/log/example-service/runtime.log",
|
||||||
|
"maxSizeMb": 512,
|
||||||
|
"rotateTimeoutMs": 86400000
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"path": "/metrics",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 2,
|
||||||
|
"memory": true,
|
||||||
|
"newField": "1000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* Изменение объекта конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl set example .metrics '{"address":{"ip":"198.0.0.1","newField":"100","port":1},"gc":1,"memory":false}'
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"journal": {
|
||||||
|
"bufferSize": 4092,
|
||||||
|
"compress": true,
|
||||||
|
"enable": false,
|
||||||
|
"enableRemoteTransfer": true,
|
||||||
|
"filename": "/var/log/example-service/runtime.log",
|
||||||
|
"maxSizeMb": 512,
|
||||||
|
"rotateTimeoutMs": 86400000
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"ip": "198.0.0.1",
|
||||||
|
"newField": "100",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* Полное обновление конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl set example . '{"journal":{"bufferSize":1111,"compress":false,"enable":true,"filename":"/var/log/example-service/runtime.log","newField":"1000"},"metrics":{"address":{"ip":"198.0.0.1","newField":"100","port":1},"gc":1,"memory":false}}'
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"journal": {
|
||||||
|
"bufferSize": 1111,
|
||||||
|
"compress": false,
|
||||||
|
"enable": true,
|
||||||
|
"filename": "/var/log/example-service/runtime.log",
|
||||||
|
"newField": "1000"
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"ip": "198.0.0.1",
|
||||||
|
"newField": "100",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### ispctl delete
|
||||||
|
`ispctl [flag...] delete module_name property_path`
|
||||||
|
* Удаление объекта конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl delete example .journal
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"ip": "198.0.0.1",
|
||||||
|
"newField": "100",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* Удаление поля из конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl delete example .metrics.address.ip
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"newField": "100",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* Удаление конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl delete example .
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
### ispctl schema
|
||||||
|
`ispctl [flag...] schema module_name [local_flag]`
|
||||||
|
* Получение схемы конфигурации
|
||||||
|
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl schema example
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"title": "example"
|
||||||
|
"schema": {
|
||||||
|
"title": "Remote config",
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"journal",
|
||||||
|
],
|
||||||
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Запрос
|
||||||
|
```bash
|
||||||
|
ispctl schema example -o html
|
||||||
|
```
|
||||||
|
Ответ
|
||||||
|
```bash
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
<body>
|
||||||
|
<div class="results"></div>
|
||||||
|
<script>
|
||||||
|
var schema = [
|
||||||
|
{"schema":{"required":["journal"]...
|
||||||
|
...
|
||||||
|
...
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### ispctl merge
|
||||||
|
Содержание файла `example.json`
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"metrics": {
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
},
|
||||||
|
"property": "replaced"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Конфигурация модуля `example`
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"database": {
|
||||||
|
"host": "127.0.0.1"
|
||||||
|
},
|
||||||
|
"property": "original"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ispctl merge example < example.json
|
||||||
|
```
|
||||||
|
Результат в конфигурации модуля
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"metrics": {
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
},
|
||||||
|
"property": "replaced",
|
||||||
|
"database": {
|
||||||
|
"host": "127.0.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### ispctl gitget
|
||||||
|
```bash
|
||||||
|
ispctl gitget git@github.com:integration-system/ispctl.git main.go d4d7c679aad47ae204c2b3a4587b032a723fe315
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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
|
||||||
|
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
|
||||||
|
{
|
||||||
|
"metrics": {
|
||||||
|
"address": {
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"newField": "100",
|
||||||
|
"port": 1
|
||||||
|
},
|
||||||
|
"gc": 1,
|
||||||
|
"memory": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
1
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
mkdir -p configs
|
||||||
|
if [ -n "$*" ]; then
|
||||||
|
statusResponse=$(ispctl $* status)
|
||||||
|
else
|
||||||
|
statusResponse=$(ispctl status)
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=0
|
||||||
|
IFS=$'\n'
|
||||||
|
for status in $statusResponse; do
|
||||||
|
if [ $i -ne 2 ]; then
|
||||||
|
i=$((i + 1))
|
||||||
|
else
|
||||||
|
IFS=$' '
|
||||||
|
read -ra ADDR <<<"$status"
|
||||||
|
for module_name in "${ADDR[0]}"; do
|
||||||
|
if [ -n "$*" ]; then
|
||||||
|
ispctl $* get $module_name . > configs/$module_name.json
|
||||||
|
else
|
||||||
|
ispctl get $module_name . > configs/$module_name.json
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
mkdir -p schemas
|
||||||
|
if [ -n "$*" ]; then
|
||||||
|
statusResponse=$(ispctl $* status)
|
||||||
|
else
|
||||||
|
statusResponse=$(ispctl status)
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=0
|
||||||
|
IFS=$'\n'
|
||||||
|
for status in $statusResponse; do
|
||||||
|
if [ $i -ne 2 ]; then
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
else
|
||||||
|
IFS=$' '
|
||||||
|
read -ra ADDR <<<"$status"
|
||||||
|
for module_name in "${ADDR[0]}"; do
|
||||||
|
if [ -n "$*" ]; then
|
||||||
|
ispctl $* schema -o html $module_name > schemas/$module_name.html
|
||||||
|
else
|
||||||
|
ispctl schema -o html $module_name > schemas/$module_name.html
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package bash
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"ispctl/model"
|
||||||
|
"ispctl/service"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"github.com/txix-open/bellows"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CommonConfigName = "config_name"
|
||||||
|
ModuleName = "module_name"
|
||||||
|
ModuleData = "module_data"
|
||||||
|
|
||||||
|
VariableName = "variable_name"
|
||||||
|
Empty = "empty"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BashService interface {
|
||||||
|
GetAllVariables() ([]model.Variable, error)
|
||||||
|
GetAvailableConfigs() ([]model.ModuleInfo, error)
|
||||||
|
GetConfigurationByModuleName(moduleName string) (*model.Config, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type BeforeComplete func(ctx *cli.Context) (service.Config, error)
|
||||||
|
|
||||||
|
type Autocomplete struct {
|
||||||
|
beforeComplete BeforeComplete
|
||||||
|
service BashService
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAutocomplete(beforeComplete BeforeComplete) Autocomplete {
|
||||||
|
return Autocomplete{
|
||||||
|
beforeComplete: beforeComplete,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Autocomplete) Complete(first string, second string) cli.BashCompleteFunc {
|
||||||
|
return func(ctx *cli.Context) {
|
||||||
|
cfgService, err := c.beforeComplete(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.service = cfgService
|
||||||
|
c.complete(ctx, first, second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Autocomplete) complete(ctx *cli.Context, first string, second string) {
|
||||||
|
switch ctx.NArg() {
|
||||||
|
case 0:
|
||||||
|
c.completeFirstArg(ctx, first)
|
||||||
|
case 1:
|
||||||
|
c.completeSecondArg(ctx, second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Autocomplete) completeFirstArg(ctx *cli.Context, first string) {
|
||||||
|
switch first {
|
||||||
|
case ModuleName:
|
||||||
|
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
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Autocomplete) printModuleData(moduleName string) {
|
||||||
|
config, err := c.service.GetConfigurationByModuleName(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for key := range bellows.Flatten(config.Data) {
|
||||||
|
fmt.Printf(".%v\n", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
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 {
|
||||||
|
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)
|
||||||
|
return []*cli.Command{
|
||||||
|
status.Command(),
|
||||||
|
get.Command(),
|
||||||
|
set.Command(),
|
||||||
|
delete.Command(),
|
||||||
|
schema.Command(),
|
||||||
|
merge.Command(),
|
||||||
|
gitGet.Command(),
|
||||||
|
variables.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
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"ispctl/bash"
|
||||||
|
"ispctl/command/utils"
|
||||||
|
"ispctl/model"
|
||||||
|
|
||||||
|
"github.com/tidwall/sjson"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "delete",
|
||||||
|
Usage: "delete configuration by module_name",
|
||||||
|
Action: c.action,
|
||||||
|
BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.ModuleData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Delete) action(ctx *cli.Context) error {
|
||||||
|
moduleName := ctx.Args().First()
|
||||||
|
pathObject := ctx.Args().Get(1)
|
||||||
|
|
||||||
|
moduleConfiguration, err := c.service.GetConfigurationByModuleName(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pathObject, err = utils.CheckPath(pathObject)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if pathObject == "" {
|
||||||
|
return CreateUpdateConfig("", moduleConfiguration, c.service)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObject, err := json.Marshal(moduleConfiguration.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
stringToChange, err := sjson.Delete(string(jsonObject), pathObject)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return CreateUpdateConfig(stringToChange, moduleConfiguration, c.service)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
)
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"ispctl/bash"
|
||||||
|
"ispctl/command/utils"
|
||||||
|
"ispctl/model"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "get",
|
||||||
|
Usage: "get configuration by module_name",
|
||||||
|
Action: c.action,
|
||||||
|
BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.ModuleData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Get) action(ctx *cli.Context) error {
|
||||||
|
moduleName := ctx.Args().First()
|
||||||
|
pathObject := ctx.Args().Get(1)
|
||||||
|
|
||||||
|
config, err := c.service.GetConfigurationByModuleName(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
data := config.Data
|
||||||
|
|
||||||
|
pathObject, err = utils.CheckPath(pathObject)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if pathObject == "" {
|
||||||
|
return utils.PrintAnswer(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObject, err := json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return utils.CheckObject(jsonObject, pathObject)
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/go-git/go-billy/v5/memfs"
|
||||||
|
"github.com/go-git/go-git/v5"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
|
"github.com/go-git/go-git/v5/storage/memory"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GitGet struct {
|
||||||
|
semverRegexp *regexp.Regexp
|
||||||
|
}
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "gitget",
|
||||||
|
Usage: "gitget [repository] [file] (commit|tag)",
|
||||||
|
Description: "clone and print specified file from specified repository and specified commit hash or tag",
|
||||||
|
Action: c.action,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c GitGet) action(ctx *cli.Context) error {
|
||||||
|
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{
|
||||||
|
URL: repo,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "clone %s", repo)
|
||||||
|
}
|
||||||
|
tree, err := repository.Worktree()
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get worktree")
|
||||||
|
}
|
||||||
|
|
||||||
|
if commit != "" {
|
||||||
|
checkoutOpts := git.CheckoutOptions{}
|
||||||
|
if c.semverRegexp.MatchString(commit) {
|
||||||
|
checkoutOpts.Branch = plumbing.NewTagReferenceName(commit)
|
||||||
|
} else {
|
||||||
|
checkoutOpts.Hash = plumbing.NewHash(commit)
|
||||||
|
}
|
||||||
|
err = tree.Checkout(&checkoutOpts)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "checkout: %s", commit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := tree.Filesystem.Open(file)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "open %s", file)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.Copy(os.Stdout, f)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"ispctl/bash"
|
||||||
|
"ispctl/command/utils"
|
||||||
|
"ispctl/model"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "merge",
|
||||||
|
Usage: "merge actual config with config from stdin",
|
||||||
|
BashComplete: c.autoComplete.Complete(bash.CommonConfigName, bash.Empty),
|
||||||
|
Action: c.action,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Merge) action(ctx *cli.Context) error {
|
||||||
|
moduleName := ctx.Args().First()
|
||||||
|
config, err := c.service.GetConfigurationByModuleName(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "get module config '%s'", moduleName)
|
||||||
|
}
|
||||||
|
|
||||||
|
inputConfig := make(map[string]any)
|
||||||
|
err = json.NewDecoder(os.Stdin).Decode(&inputConfig)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "json unmarshal input config")
|
||||||
|
}
|
||||||
|
for key, value := range inputConfig {
|
||||||
|
config.Data[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := c.service.CreateUpdateConfigV2(config)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "update module config '%s'", moduleName)
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.PrintAnswer(result)
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"ispctl/bash"
|
||||||
|
"ispctl/command/utils"
|
||||||
|
"ispctl/model"
|
||||||
|
"ispctl/tmpl"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/txix-open/isp-kit/rc/schema"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "schema",
|
||||||
|
Usage: "get schema configuration by module_name",
|
||||||
|
Action: c.action,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: OutPrintFlagName, Usage: outPrintSchemaUsage, Value: OutPrintJsonValue},
|
||||||
|
},
|
||||||
|
BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.Empty),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Schema) action(ctx *cli.Context) error {
|
||||||
|
moduleName := ctx.Args().First()
|
||||||
|
schemaConfig, err := c.getSchemaConfig(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
schema := make(map[string]any)
|
||||||
|
schema["title"] = moduleName
|
||||||
|
schema["schema"] = schemaConfig
|
||||||
|
switch ctx.String(OutPrintFlagName) {
|
||||||
|
case OutPrintJsonValue:
|
||||||
|
return utils.PrintAnswer(schema)
|
||||||
|
case OutPrintHtmlValue:
|
||||||
|
return c.printHtml(schema)
|
||||||
|
default:
|
||||||
|
return errors.Errorf("invalid flag value, expected [%s] or [%s]", OutPrintJsonValue, OutPrintHtmlValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Schema) getSchemaConfig(moduleName string) (schema.Schema, error) {
|
||||||
|
configuration, err := c.service.GetConfigurationByModuleName(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"ispctl/bash"
|
||||||
|
"ispctl/command/utils"
|
||||||
|
"ispctl/model"
|
||||||
|
|
||||||
|
"github.com/tidwall/sjson"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "set",
|
||||||
|
Usage: "set configuration by module_name",
|
||||||
|
Action: c.action,
|
||||||
|
BashComplete: c.autoComplete.Complete(bash.ModuleName, bash.ModuleData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Set) action(ctx *cli.Context) error {
|
||||||
|
moduleName := ctx.Args().First()
|
||||||
|
pathObject := ctx.Args().Get(1)
|
||||||
|
changeObject := ctx.Args().Get(2)
|
||||||
|
|
||||||
|
config, err := c.service.GetConfigurationByModuleName(moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pathObject, err = utils.CheckPath(pathObject)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
changeObject, err = utils.CheckChangeObject(changeObject)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if pathObject == "" {
|
||||||
|
return CreateUpdateConfig(changeObject, config, c.service)
|
||||||
|
}
|
||||||
|
jsonObject, err := json.Marshal(config.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
changeArgument := utils.ParseSetObject(changeObject)
|
||||||
|
stringToChange, err := sjson.Set(string(jsonObject), pathObject, changeArgument)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return CreateUpdateConfig(stringToChange, config, c.service)
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"ispctl/command/utils"
|
||||||
|
"ispctl/model"
|
||||||
|
|
||||||
|
"github.com/olekukonko/tablewriter"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
tableHeaderModuleName = "MODULE_NAME"
|
||||||
|
tableHeaderStatus = "STATUS"
|
||||||
|
tableHeaderAddresses = "ADDRESSES"
|
||||||
|
|
||||||
|
tableNotConnectedStatus = "NOT_CONNECTED"
|
||||||
|
tableConnectedStatus = "CONNECTED"
|
||||||
|
)
|
||||||
|
|
||||||
|
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{
|
||||||
|
Name: "status",
|
||||||
|
Usage: "get available configs",
|
||||||
|
Action: c.action,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{Name: OutPrintFlagName, Usage: outPrintStatusUsage},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Status) action(ctx *cli.Context) error {
|
||||||
|
arrayOfModules, err := c.service.GetAvailableConfigs()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch ctx.String(OutPrintFlagName) {
|
||||||
|
case OutPrintJsonValue:
|
||||||
|
return utils.PrintAnswer(arrayOfModules)
|
||||||
|
default:
|
||||||
|
table := tablewriter.NewWriter(os.Stdout)
|
||||||
|
table.SetBorders(tablewriter.Border{Left: false, Top: false, Right: false, Bottom: false})
|
||||||
|
table.SetHeader([]string{tableHeaderModuleName, tableHeaderStatus, tableHeaderAddresses})
|
||||||
|
for _, module := range arrayOfModules {
|
||||||
|
addresses := ""
|
||||||
|
connection := tableNotConnectedStatus
|
||||||
|
instanceList := make([]string, 0, len(module.Status))
|
||||||
|
for _, value := range module.Status {
|
||||||
|
instanceList = append(instanceList, fmt.Sprintf("%s:%s %s", value.Address.IP, value.Address.Port, value.Version))
|
||||||
|
}
|
||||||
|
addresses = strings.Join(instanceList, "\n")
|
||||||
|
if addresses != "" {
|
||||||
|
connection = tableConnectedStatus
|
||||||
|
}
|
||||||
|
table.Append([]string{module.Name, connection, addresses})
|
||||||
|
}
|
||||||
|
table.Render()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CheckPath(pathObject string) (string, error) {
|
||||||
|
str := strings.Split(pathObject, ".")
|
||||||
|
pathObject = ""
|
||||||
|
if len(str) == 1 || str[0] != "" {
|
||||||
|
return pathObject, errors.New("path must start with '.'")
|
||||||
|
}
|
||||||
|
for key, value := range str {
|
||||||
|
if key == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if key == 1 {
|
||||||
|
pathObject = value
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pathObject = fmt.Sprintf("%s.%s", pathObject, value)
|
||||||
|
}
|
||||||
|
return pathObject, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckChangeObject(changeObject string) (string, error) {
|
||||||
|
if changeObject == "" {
|
||||||
|
bytes, err := io.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
changeObject = string(bytes)
|
||||||
|
}
|
||||||
|
if changeObject == "" {
|
||||||
|
return "", errors.New("expected argument")
|
||||||
|
}
|
||||||
|
return changeObject, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PrintAnswer(data any) error {
|
||||||
|
encoder := json.NewEncoder(os.Stdout)
|
||||||
|
encoder.SetEscapeHTML(false)
|
||||||
|
encoder.SetIndent("", " ")
|
||||||
|
return encoder.Encode(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseSetObject(argument string) any {
|
||||||
|
tryParse := []byte(argument)
|
||||||
|
if tryParse[0] == '"' && tryParse[len(tryParse)-1] == '"' {
|
||||||
|
tryParse = tryParse[1 : len(tryParse)-1]
|
||||||
|
return string(tryParse)
|
||||||
|
}
|
||||||
|
|
||||||
|
if argument == "null" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
mapStringInterface := make(map[string]any)
|
||||||
|
if err := json.Unmarshal(tryParse, &mapStringInterface); err == nil {
|
||||||
|
return mapStringInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
arrayOfObject := make([]any, 0)
|
||||||
|
if err := json.Unmarshal(tryParse, &arrayOfObject); err == nil {
|
||||||
|
return arrayOfObject
|
||||||
|
}
|
||||||
|
|
||||||
|
var integer int64
|
||||||
|
if err := json.Unmarshal(tryParse, &integer); err == nil {
|
||||||
|
return integer
|
||||||
|
}
|
||||||
|
|
||||||
|
var float float64
|
||||||
|
if err := json.Unmarshal(tryParse, &float); err == nil {
|
||||||
|
return float
|
||||||
|
}
|
||||||
|
|
||||||
|
var flag bool
|
||||||
|
if err := json.Unmarshal(tryParse, &flag); err == nil {
|
||||||
|
return flag
|
||||||
|
}
|
||||||
|
|
||||||
|
return argument
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckObject(jsonObject []byte, depth string) error {
|
||||||
|
jsonString := gjson.GetBytes(jsonObject, depth)
|
||||||
|
if jsonString.Raw == "" {
|
||||||
|
return errors.Errorf("path '%s' not found\n", depth)
|
||||||
|
}
|
||||||
|
var data any
|
||||||
|
err := json.Unmarshal([]byte(jsonString.Raw), &data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return PrintAnswer(data)
|
||||||
|
}
|
||||||
+172
@@ -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
|
||||||
|
}
|
||||||
Whitespace-only changes.
@@ -0,0 +1,85 @@
|
|||||||
|
module ispctl
|
||||||
|
|
||||||
|
go 1.24
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/go-git/go-billy/v5 v5.6.0
|
||||||
|
github.com/go-git/go-git/v5 v5.12.0
|
||||||
|
github.com/olekukonko/tablewriter v0.0.5
|
||||||
|
github.com/pkg/errors v0.9.1
|
||||||
|
github.com/tidwall/gjson v1.17.3
|
||||||
|
github.com/tidwall/sjson v1.2.5
|
||||||
|
github.com/txix-open/bellows v1.2.0
|
||||||
|
github.com/txix-open/isp-kit v1.44.0
|
||||||
|
github.com/urfave/cli/v2 v2.27.5
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422
|
||||||
|
google.golang.org/grpc v1.69.4
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
dario.cat/mergo v1.0.0 // indirect
|
||||||
|
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||||
|
github.com/ProtonMail/go-crypto v1.0.0 // indirect
|
||||||
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
|
github.com/cloudflare/circl v1.3.7 // indirect
|
||||||
|
github.com/coder/websocket v1.8.12 // indirect
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
||||||
|
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
|
||||||
|
github.com/emirpasic/gods v1.18.1 // 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/stdr v1.2.2 // indirect
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
|
||||||
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||||
|
github.com/klauspost/compress v1.17.11 // indirect
|
||||||
|
github.com/mailru/easyjson v0.9.0 // 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/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
|
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||||
|
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||||
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
|
github.com/prometheus/common v0.60.1 // indirect
|
||||||
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
||||||
|
github.com/skeema/knownhosts v1.2.2 // indirect
|
||||||
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
|
github.com/txix-open/etp/v4 v4.0.1 // indirect
|
||||||
|
github.com/txix-open/jsonschema v1.2.0 // indirect
|
||||||
|
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||||
|
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||||
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||||
|
go.opentelemetry.io/otel v1.33.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/metric v1.33.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/sdk v1.33.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/trace v1.33.0 // indirect
|
||||||
|
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
||||||
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
|
golang.org/x/crypto v0.32.0 // indirect
|
||||||
|
golang.org/x/mod v0.17.0 // indirect
|
||||||
|
golang.org/x/net v0.34.0 // indirect
|
||||||
|
golang.org/x/sync v0.10.0 // indirect
|
||||||
|
golang.org/x/sys v0.29.0 // indirect
|
||||||
|
golang.org/x/text v0.21.0 // indirect
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
|
||||||
|
google.golang.org/protobuf v1.36.2 // indirect
|
||||||
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
|
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
||||||
|
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||||
|
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||||
|
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||||
|
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||||
|
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
|
||||||
|
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||||
|
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||||
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||||
|
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||||
|
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||||
|
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/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
|
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||||
|
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
|
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/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
|
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/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/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
||||||
|
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
||||||
|
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
||||||
|
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/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo=
|
||||||
|
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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
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/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
|
||||||
|
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||||
|
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||||
|
github.com/getsentry/sentry-go v0.31.1 h1:ELVc0h7gwyhnXHDouXkhqTFSO5oslsRDk0++eyE0KJ4=
|
||||||
|
github.com/getsentry/sentry-go v0.31.1/go.mod h1:CYNcMMz73YigoHljQRG+qPF+eMq8gG72XcGN/p71BAY=
|
||||||
|
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/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/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8=
|
||||||
|
github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM=
|
||||||
|
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
|
||||||
|
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
|
||||||
|
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-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.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
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-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
|
github.com/go-playground/locales v0.14.1/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.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
|
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/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
|
||||||
|
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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
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/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||||
|
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||||
|
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/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
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/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.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
|
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
||||||
|
github.com/mailru/easyjson v0.9.0/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/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
|
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/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
|
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||||
|
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/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
|
||||||
|
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
|
||||||
|
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/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/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
||||||
|
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||||
|
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||||
|
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||||
|
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
||||||
|
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||||
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||||
|
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/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
|
||||||
|
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||||
|
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
|
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
|
||||||
|
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
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.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
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/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
|
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||||
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
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/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/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
||||||
|
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
||||||
|
github.com/txix-open/isp-kit v1.44.0 h1:ao16vgZ/cdbO4sZWYXD4VcJQ+984IQvb/A80mEjU504=
|
||||||
|
github.com/txix-open/isp-kit v1.44.0/go.mod h1:BHRF3AYRcQtEtNvoQZXxTVj/CYOVMKhOcCD3n8CdsxE=
|
||||||
|
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s=
|
||||||
|
github.com/txix-open/jsonschema v1.2.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-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
||||||
|
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/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
|
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||||
|
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
||||||
|
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
|
||||||
|
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/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||||
|
go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw=
|
||||||
|
go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 h1:wpMfgF8E1rkrT1Z6meFh1NDtownE9Ii3n3X2GJYjsaU=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0/go.mod h1:wAy0T/dUbs468uOlkT31xjvqQgEVXv58BRFWEgn5v/0=
|
||||||
|
go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ=
|
||||||
|
go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.33.0 h1:iax7M131HuAm9QkZotNHEfstof92xM+N8sr3uHXc2IM=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.33.0/go.mod h1:A1Q5oi7/9XaMlIWzPSxLRWOI8nG3FnzHJNbiENQuihM=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
|
||||||
|
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s=
|
||||||
|
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
|
||||||
|
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/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
|
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.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||||
|
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-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.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||||
|
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||||
|
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||||
|
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||||
|
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||||
|
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.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||||
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
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-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
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.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||||
|
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||||
|
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||||
|
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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||||
|
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
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-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
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.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||||
|
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.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||||
|
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||||
|
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.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
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.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.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
|
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.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.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24=
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422 h1:3UsHvIr4Wc2aW4brOaSCmcxh9ksica6fHEr8P1XhkYw=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4=
|
||||||
|
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
|
||||||
|
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
|
||||||
|
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
|
||||||
|
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
|
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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||||
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||||
|
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||||
|
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"ispctl/bash"
|
||||||
|
"ispctl/command"
|
||||||
|
"ispctl/repository"
|
||||||
|
"ispctl/service"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var version = "1.1.0"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
initCommands()
|
||||||
|
}
|
||||||
|
|
||||||
|
func initCommands() {
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Usage = "isp configurations updater"
|
||||||
|
|
||||||
|
app.Version = version
|
||||||
|
app.Flags = []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
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
|
||||||
|
|
||||||
|
var configService service.Config
|
||||||
|
var autoComplete bash.Autocomplete
|
||||||
|
app.Before = func(ctx *cli.Context) error {
|
||||||
|
service, err := configServiceFromGlobalFlags(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
configService = service
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
autoComplete = bash.NewAutocomplete(configServiceFromGlobalFlags)
|
||||||
|
app.Commands = command.AllCommands(&configService, autoComplete)
|
||||||
|
|
||||||
|
app.BashComplete = func(context *cli.Context) {
|
||||||
|
for _, appCommand := range app.Commands {
|
||||||
|
fmt.Println(appCommand.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := app.Run(os.Args)
|
||||||
|
if err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/rc/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetModuleByUuidAndNameRequest struct {
|
||||||
|
ModuleName string
|
||||||
|
Uuid string
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetSchemaByModuleIdRequest struct {
|
||||||
|
ModuleId string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Id string
|
||||||
|
Name string
|
||||||
|
CommonConfigs []string
|
||||||
|
Description string
|
||||||
|
ModuleId string
|
||||||
|
Version int32
|
||||||
|
Active bool
|
||||||
|
Data map[string]any
|
||||||
|
Unsafe bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type CommonConfig struct {
|
||||||
|
Id string
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
Data map[string]any
|
||||||
|
}
|
||||||
|
|
||||||
|
type Connection struct {
|
||||||
|
LibVersion string
|
||||||
|
Version string
|
||||||
|
Address cluster.AddressConfiguration
|
||||||
|
Endpoints []cluster.EndpointDescriptor `json:",omitempty"`
|
||||||
|
EstablishedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModuleInfo struct {
|
||||||
|
Id string
|
||||||
|
Name string
|
||||||
|
Active bool
|
||||||
|
CreatedAt time.Time
|
||||||
|
ConfigSchema *schema.Schema `json:",omitempty"`
|
||||||
|
Status []Connection `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigSchema struct {
|
||||||
|
Id string
|
||||||
|
Version string
|
||||||
|
ModuleId string
|
||||||
|
Schema schema.Schema
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
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"
|
||||||
|
|
||||||
|
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"`
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
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) 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)
|
||||||
|
switch {
|
||||||
|
case status.Code(err) == codes.NotFound:
|
||||||
|
return nil, model.ErrModuleNotFound
|
||||||
|
case err != nil:
|
||||||
|
return nil, errors.WithMessagef(err, "call %s", getConfigByModuleName)
|
||||||
|
default:
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
stringBuilder.WriteString(fmt.Sprintf("%s | %s\n", field, desc))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, detail := range errorStatus.Details() {
|
||||||
|
switch d := detail.(type) {
|
||||||
|
case *epb.BadRequest:
|
||||||
|
for _, violation := range d.FieldViolations {
|
||||||
|
stringBuilder.WriteString(fmt.Sprintf("%s | %s\n", violation.Field, violation.Description))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
stringBuilder.WriteString(fmt.Sprint(d))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New(stringBuilder.String())
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"ispctl/model"
|
||||||
|
"ispctl/repository"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/txix-open/isp-kit/rc/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
enableUnsafe bool
|
||||||
|
configRepo repository.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConfig(enableUnsafe bool, configRepo repository.Config) Config {
|
||||||
|
return Config{
|
||||||
|
enableUnsafe: enableUnsafe,
|
||||||
|
configRepo: configRepo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) GetAvailableConfigs() ([]model.ModuleInfo, error) {
|
||||||
|
return c.configRepo.GetAvailableConfigs()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) GetConfigurationByModuleName(moduleName string) (*model.Config, error) {
|
||||||
|
if moduleName == "" {
|
||||||
|
return nil, errors.New("need module name")
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleConfiguration, err := c.configRepo.GetConfigByModuleName(moduleName)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, model.ErrModuleNotFound):
|
||||||
|
return nil, errors.Errorf("module [%s] not found", moduleName)
|
||||||
|
default:
|
||||||
|
return moduleConfiguration, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) GetSchemaByModuleId(moduleId string) (schema.Schema, error) {
|
||||||
|
configSchema, err := c.configRepo.GetSchemaByModuleId(moduleId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return configSchema.Schema, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) CreateUpdateConfig(stringToChange string, configuration *model.Config) (map[string]any, error) {
|
||||||
|
newData := make(map[string]any)
|
||||||
|
if stringToChange != "" {
|
||||||
|
err := json.Unmarshal([]byte(stringToChange), &newData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration.Data = newData
|
||||||
|
return c.CreateUpdateConfigV2(configuration)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) CreateUpdateConfigV2(configuration *model.Config) (map[string]any, error) {
|
||||||
|
configuration.Unsafe = c.enableUnsafe
|
||||||
|
resp, err := c.configRepo.CreateUpdateConfig(*configuration)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp.Data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) GetAllVariables() ([]model.Variable, error) {
|
||||||
|
return c.configRepo.GetAllVariables()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) GetVariableByName(variableName string) (*model.Variable, error) {
|
||||||
|
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
|
||||||
|
default:
|
||||||
|
return variable, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) DeleteVariable(variableName string) error {
|
||||||
|
if variableName == "" {
|
||||||
|
return errors.New("need variable name")
|
||||||
|
}
|
||||||
|
|
||||||
|
err := c.configRepo.DeleteVariable(variableName)
|
||||||
|
switch {
|
||||||
|
case errors.Is(err, model.ErrVariableNotFound):
|
||||||
|
return errors.Errorf("variable [%s] not found", variableName)
|
||||||
|
default:
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) UpsertVariables(vars []model.UpsertVariableRequest) error {
|
||||||
|
return c.configRepo.UpsertVariables(vars)
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||||
|
|
||||||
|
# Macs have bash3 for which the bash-completion package doesn't include
|
||||||
|
# _init_completion. This is a minimal version of that function.
|
||||||
|
_cli_init_completion() {
|
||||||
|
COMPREPLY=()
|
||||||
|
_get_comp_words_by_ref "$@" cur prev words cword
|
||||||
|
}
|
||||||
|
|
||||||
|
_cli_bash_autocomplete() {
|
||||||
|
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||||
|
local cur opts base words
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
if declare -F _init_completion >/dev/null 2>&1; then
|
||||||
|
_init_completion -n "=:" || return
|
||||||
|
else
|
||||||
|
_cli_init_completion -n "=:" || return
|
||||||
|
fi
|
||||||
|
words=("${words[@]:0:$cword}")
|
||||||
|
if [[ "$cur" == "-"* ]]; then
|
||||||
|
requestComp="${words[*]} ${cur} --generate-bash-completion"
|
||||||
|
else
|
||||||
|
requestComp="${words[*]} --generate-bash-completion"
|
||||||
|
fi
|
||||||
|
opts=$(eval "${requestComp}" 2>/dev/null)
|
||||||
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
|
||||||
|
unset PROG
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package tmpl
|
||||||
|
|
||||||
|
const HtmlFile = `<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/json-schema-view-js@2.0.1/dist/bundle.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/json-schema-view-js@2.0.1/dist/style.min.css">
|
||||||
|
<style>
|
||||||
|
.json-schema-view-dark {
|
||||||
|
background: #222;
|
||||||
|
}
|
||||||
|
h3 + div > div {
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
background: #333;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 1.2em;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Page layout
|
||||||
|
*/
|
||||||
|
body {
|
||||||
|
max-width: 80vw;
|
||||||
|
margin: 30px auto;
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
header h1 {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
header > div {
|
||||||
|
text-align: right;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
header > div * {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.code-in-gh {
|
||||||
|
background: steelblue;
|
||||||
|
color: white;
|
||||||
|
padding: .5em;
|
||||||
|
border-radius: 5px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="results"></div>
|
||||||
|
<script>
|
||||||
|
var schema = [
|
||||||
|
{{ . }}
|
||||||
|
];
|
||||||
|
var results = document.querySelector('.results');
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
schema.forEach(function (example) {
|
||||||
|
var title = document.createElement('h3');
|
||||||
|
var formatter = new JSONSchemaView(example.schema, 1, { theme: example.theme });
|
||||||
|
title.innerText = example.title;
|
||||||
|
results.appendChild(title)
|
||||||
|
results.appendChild(formatter.render());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`
|
||||||
Reference in new issue
Block a user