本文整理匯總了Golang中models/k8sModel.ServiceModel.UpdateService方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceModel.UpdateService方法的具體用法?Golang ServiceModel.UpdateService怎麽用?Golang ServiceModel.UpdateService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models/k8sModel.ServiceModel
的用法示例。
在下文中一共展示了ServiceModel.UpdateService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Post
func (this *LineService) Post(data []byte) line {
fmt.Println("[Post] LineService")
var _data_format data_format
json.Unmarshal(data, &_data_format)
service_model := k8sModel.ServiceModel{}
_get_service_data := service_model.GetService(_data_format.Service_name)
replication_controller_model := k8sModel.ReplicationControllerModel{}
_get_replication_controller_data := replication_controller_model.GetReplicationController(_data_format.Cluster_name)
var _line line
if _get_service_data.Spec.Selector == nil {
_line.Status = "fail"
_line.Errmsg = "service no selector"
return _line
}
_get_service_data.Spec.Selector = _get_replication_controller_data.Spec.Selector
service_model.UpdateService(_data_format.Service_name, _get_service_data)
// _put_service_data := service_model.UpdateService(_data_format.Service_name, _get_service_data)
// if _put_service_data.Status_code == "200" {
// Status = "ok"
// } else {
// Status = "fail"
// }
_line.Status = "ok"
return _line
}
示例2: Delete
func (this *LineService) Delete(data []byte) line {
fmt.Println("[Delete] LineService")
var _data_format data_format
json.Unmarshal(data, &_data_format)
service_model := k8sModel.ServiceModel{}
_get_service_data := service_model.GetService(_data_format.Service_name)
replication_controller_model := k8sModel.ReplicationControllerModel{}
_get_replication_controller_data := replication_controller_model.GetReplicationController(_data_format.Cluster_name)
var _line line
if _get_service_data.Spec.Selector == nil {
_line.Status = "fail"
_line.Errmsg = "service no selector"
return _line
}
if _get_service_data.Spec.Selector["name"] != _get_replication_controller_data.Spec.Selector["name"] {
_line.Status = "fail"
_line.Errmsg = "service and cluster not same"
return _line
}
_get_service_data.Spec.Selector["name"] = _get_service_data.Spec.Selector["name"] + "-giga"
service_model.UpdateService(_data_format.Service_name, _get_service_data)
_line.Status = "ok"
return _line
}
示例3: UpdateService
func (this *ServiceService) UpdateService(name string, data []byte) Service {
type service_format struct {
Service_name string `json:"service_name"`
Port string `json:"port"`
Label map[string]string `json:"label"`
NodePort string `json:"nodePort"`
}
var _service Service
var _service_format service_format
json.Unmarshal(data, &_service_format)
service_model := k8sModel.ServiceModel{}
_k8s_service := service_model.GetService(name)
_k8s_service.Metadata.Labels = _service_format.Label
_k8s_service.Spec.Ports[0].Port, _ = strconv.Atoi(_service_format.Port)
_k8s_service.Spec.Ports[0].TargetPort, _ = strconv.Atoi(_service_format.Port)
// _k8s_service.Spec.Selector["name"] = name
service_model.UpdateService(name, _k8s_service)
_service.Status = "ok"
// _service.Metadata.Label = _service_format.Label
return _service
}