MSP-5014 Refactor utils

This commit is contained in:
Синельник Тимур Романович committed 2025-03-24 11:30:39 +03:00
1 parent 7c01299e53
commit 8c49ae85ed
10 files changed
+44 -60

No files matched your search

+16
View File
@@ -1,6 +1,7 @@
package command
import (
"ispctl/command/utils"
"ispctl/model"
"github.com/txix-open/isp-kit/rc/schema"
@@ -23,6 +24,10 @@ type ConfigService interface {
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)
@@ -43,3 +48,14 @@ func AllCommands(configService ConfigService, autoComplete AutoComplete) []*cli.
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
}