This commit is contained in:
DeniskaRediska committed 2019-07-17 11:14:17 +03:00
1 parent 79e240037f
commit 9078060e65
20 files changed
+1152

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
package service
import (
"fmt"
"github.com/tidwall/pretty"
)
var ColorService colorService
type colorService struct {
Enable bool
}
func (c colorService) Print(json []byte) {
if c.Enable {
result := pretty.Color(json, nil)
fmt.Println(string(result))
} else {
fmt.Println(string(json))
}
}
+7
View File
@@ -0,0 +1,7 @@
package service
var configPath string
func SetConfigurationPath(path string) {
configPath = path
}
+16
View File
@@ -0,0 +1,16 @@
package service
import (
"github.com/integration-system/isp-lib/http"
"isp-ctl/cfg"
)
var ConfigClient = cfg.NewConfigClient(http.NewJsonRestClient())
var ConfigService configService
type configService struct{}
func (configService) ReceiveConfiguration(host, uuid string) {
ConfigClient.ReceiveConfig(host, uuid)
}
+22
View File
@@ -0,0 +1,22 @@
package service
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"isp-ctl/conf"
)
var YamlService yamlService
type yamlService struct{}
func (yamlService) Parse() (*conf.Configuration, error) {
resp := new(conf.Configuration)
reader, err := ioutil.ReadFile(configPath)
if err != nil {
return nil, err
} else {
err := yaml.Unmarshal(reader, resp)
return resp, err
}
}