change some code

This commit is contained in:
barnettZQG 2020-09-29 18:46:22 +08:00
parent 5449ee8102
commit 9e20df75ec
4 changed files with 9 additions and 12 deletions

View File

@ -710,7 +710,6 @@ func (t *TenantStruct) UpdateService(w http.ResponseWriter, r *http.Request) {
// schema:
// "$ref": "#/responses/commandResponse"
// description: 统一返回格式
logrus.Debugf("trans update service service")
//目前提供三个元素的修改
rules := validator.MapData{
"container_cmd": []string{},
@ -742,10 +741,8 @@ func (t *TenantStruct) UpdateService(w http.ResponseWriter, r *http.Request) {
httputil.ReturnBcodeError(r, w, err)
return
}
logrus.Debugf("begin to update service")
if err := handler.GetServiceManager().ServiceUpdate(data); err != nil {
httputil.ReturnError(r, w, 500, fmt.Sprintf("update service error, %v", err))
httputil.ReturnBcodeError(r, w, err)
return
}
httputil.ReturnSuccess(r, w, nil)
@ -773,7 +770,6 @@ func (t *TenantStruct) SetLanguage(w http.ResponseWriter, r *http.Request) {
// schema:
// "$ref": "#/responses/commandResponse"
// description: 统一返回格式
logrus.Debugf("trans language set service")
rules := validator.MapData{
"language": []string{"required"},
}

View File

@ -747,14 +747,11 @@ func (s *ServiceAction) ServiceUpdate(sc map[string]interface{}) error {
}
ts.AppID = sc["app_id"].(string)
version, err := db.GetManager().VersionInfoDao().GetVersionByDeployVersion(ts.DeployVersion, ts.ServiceID)
if sc["container_memory"] != nil {
ts.ContainerMemory = sc["container_memory"].(int)
if memory, ok := sc["container_memory"].(int); ok && memory != 0 {
ts.ContainerMemory = memory
}
if sc["container_cmd"] != nil {
version.Cmd = sc["container_cmd"].(string)
}
if sc["service_name"] != nil {
ts.ServiceName = sc["service_name"].(string)
if name, ok := sc["service_name"].(string); ok && name != "" {
ts.ServiceName = name
}
if sc["extend_method"] != nil {
extendMethod := sc["extend_method"].(string)

1
go.mod
View File

@ -85,6 +85,7 @@ require (
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
google.golang.org/grpc v1.29.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.19.0

View File

@ -33,6 +33,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/node_exporter/collector"
"github.com/sirupsen/logrus"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
//Manager Manager
@ -55,6 +56,8 @@ func createNodeExporterRestry() (*prometheus.Registry, error) {
"ipvs", "loadavg", "meminfo", "netdev",
"netclass", "netdev", "netstat",
"uname", "mountstats", "nfs"}
// init kingpin parse
kingpin.CommandLine.Parse([]string{"--collector.mountstats=true"})
nc, err := collector.NewNodeCollector(log.NewNopLogger(), filters...)
if err != nil {
return nil, err