当前位置: 首页>>代码示例>>Golang>>正文


Golang ServiceModel.GetService方法代码示例

本文整理汇总了Golang中models/k8sModel.ServiceModel.GetService方法的典型用法代码示例。如果您正苦于以下问题:Golang ServiceModel.GetService方法的具体用法?Golang ServiceModel.GetService怎么用?Golang ServiceModel.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models/k8sModel.ServiceModel的用法示例。


在下文中一共展示了ServiceModel.GetService方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:32,代码来源:lineService.go

示例2: 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
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:32,代码来源:lineService.go

示例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
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:25,代码来源:serviceService.go

示例4: GetServiceList

func (this *ServiceService) GetServiceList() ServiceList {
	service_model := k8sModel.ServiceModel{}
	data := service_model.GetServiceList()
	var _service_list ServiceList
	_service_list.Status = "ok"
	for _, data_items := range data.Items {
		metadata_name := data_items.Metadata.Name
		if metadata_name == "kube-dns" || metadata_name == "kubernetes" {
			continue
		}

		data := service_model.GetService(metadata_name)
		_service := this.ServiceByName(metadata_name, data)
		_service_list.Data = append(_service_list.Data, _service)
	}
	return _service_list

	// response, _ := ioutil.ReadAll(_service_list)

	// response, _ := ioutil.ReadAll(js)

	// fmt.Println(data.Items[0].Status.Replicas)

	// fmt.Println(data.ApiVersion)
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:25,代码来源:serviceService.go

示例5: GetService

func (this *ServiceService) GetService(name string) Service {
	service_model := k8sModel.ServiceModel{}
	data := service_model.GetService(name)
	// Test(data)
	var _service Service

	_service.Data = this.ServiceByName(name, data)
	_service.Status = "ok"

	return _service
}
开发者ID:w19900227,项目名称:go-k8s,代码行数:11,代码来源:serviceService.go


注:本文中的models/k8sModel.ServiceModel.GetService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。