本文整理汇总了Golang中github.com/cloudawan/cloudone/utility/configuration.GetAvailablekubeApiServerEndPoint函数的典型用法代码示例。如果您正苦于以下问题:Golang GetAvailablekubeApiServerEndPoint函数的具体用法?Golang GetAvailablekubeApiServerEndPoint怎么用?Golang GetAvailablekubeApiServerEndPoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetAvailablekubeApiServerEndPoint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getNodeTopology
func getNodeTopology(request *restful.Request, response *restful.Response) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
regionSlice, err := control.GetNodeTopology(kubeApiServerEndPoint, kubeApiServerToken)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get node topology failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
response.WriteJson(regionSlice, "[]Region")
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:27,代码来源:node.go
示例2: CreateCommand
func CreateCommand() (*slb.Command, error) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
log.Error(err)
return nil, err
}
command := &slb.Command{
time.Now(),
nil,
nil,
}
err = addCommandFromAllDeployInformation(command, kubeApiServerEndPoint, kubeApiServerToken)
if err != nil {
log.Error(err)
return nil, err
}
err = addCommandFromAllBlueGreenDeployment(command, kubeApiServerEndPoint, kubeApiServerToken)
if err != nil {
log.Error(err)
return nil, err
}
return command, nil
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:27,代码来源:command.go
示例3: deleteReplicationController
func deleteReplicationController(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
replicationController := request.PathParameter("replicationcontroller")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["replicationController"] = replicationController
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
err = control.DeleteReplicationControllerAndRelatedPod(kubeApiServerEndPoint, kubeApiServerToken, namespace, replicationController)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Delete replication controller failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["replicationController"] = replicationController
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:31,代码来源:replication_controller.go
示例4: getReplicationControllerMetric
func getReplicationControllerMetric(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
replicationControllerName := request.PathParameter("replicationcontroller")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["replicationControllerName"] = replicationControllerName
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
replicationControllerMetric, err := monitor.MonitorReplicationController(kubeApiServerEndPoint, kubeApiServerToken, namespace, replicationControllerName)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get replication controller metric failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["replicationControllerName"] = replicationControllerName
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
response.WriteJson(replicationControllerMetric, "ReplicationControllerMetric")
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:33,代码来源:replication_controller_metric.go
示例5: deleteDeployClusterApplication
func deleteDeployClusterApplication(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
clusterApplication := request.PathParameter("clusterapplication")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["clusterApplication"] = clusterApplication
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
err = deploy.DeleteDeployClusterApplication(kubeApiServerEndPoint, kubeApiServerToken, namespace, clusterApplication)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Delete cluster application deployment failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["clusterApplication"] = clusterApplication
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:31,代码来源:deploy_cluster_application.go
示例6: getAllKubernetesService
func getAllKubernetesService(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
serviceSlice, err := control.GetAllService(kubeApiServerEndPoint, kubeApiServerToken, namespace)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get all service failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
response.WriteJson(serviceSlice, "[]Service")
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:30,代码来源:service.go
示例7: getPodLog
func getPodLog(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
pod := request.PathParameter("pod")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["pod"] = pod
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
logJsonMap, err := control.GetPodLog(kubeApiServerEndPoint, kubeApiServerToken, namespace, pod)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get pod log failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["pod"] = pod
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
response.WriteJson(logJsonMap, "{}")
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:33,代码来源:pod.go
示例8: postLaunchStatelessApplication
func postLaunchStatelessApplication(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
name := request.PathParameter("statelessapplication")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["name"] = name
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
environmentSlice := make([]interface{}, 0)
err = request.ReadEntity(&environmentSlice)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["name"] = name
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
exist, err := monitor.ExistReplicationController(kubeApiServerEndPoint, kubeApiServerToken, namespace, name)
if exist {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "The replication controller to use already exists"
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["name"] = name
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(409, string(errorMessageByteSlice))
return
}
err = application.LaunchStatelessApplication(kubeApiServerEndPoint, kubeApiServerToken, namespace, name, environmentSlice)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Launch stateless application failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["name"] = name
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:59,代码来源:application_stateless.go
示例9: GetKubernetesAllNodeIP
func (hostControl *HostControl) GetKubernetesAllNodeIP() ([]string, error) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
log.Error(err)
return nil, err
}
return control.GetAllNodeIP(kubeApiServerEndPoint, kubeApiServerToken)
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:9,代码来源:host.go
示例10: putDeployResize
func putDeployResize(request *restful.Request, response *restful.Response) {
sizeText := request.QueryParameter("size")
namespace := request.PathParameter("namespace")
imageinformation := request.PathParameter("imageinformation")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["imageinformation"] = imageinformation
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
if sizeText == "" {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Input is incorrect. The fields sizeText is required."
jsonMap["sizeText"] = sizeText
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
size, err := strconv.Atoi(sizeText)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Could not parse sizeText"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["sizeText"] = sizeText
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = deploy.DeployResize(kubeApiServerEndPoint, kubeApiServerToken, namespace, imageinformation, size)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Resize deployment failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["imageinformation"] = imageinformation
jsonMap["size"] = size
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:54,代码来源:deploy.go
示例11: postKubernetesService
func postKubernetesService(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
service := new(control.Service)
err = request.ReadEntity(&service)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
if service.Namespace != namespace {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Path parameter namespace is different from namespace in the body"
jsonMap["path"] = namespace
jsonMap["body"] = service.Namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = control.CreateService(kubeApiServerEndPoint, kubeApiServerToken, namespace, *service)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Create service failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["service"] = service
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:54,代码来源:service.go
示例12: putDeployUpdate
func putDeployUpdate(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
deployUpdateInput := new(DeployUpdateInput)
err = request.ReadEntity(&deployUpdateInput)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = deploy.DeployUpdate(
kubeApiServerEndPoint,
kubeApiServerToken,
namespace,
deployUpdateInput.ImageInformationName,
deployUpdateInput.Version,
deployUpdateInput.Description,
deployUpdateInput.EnvironmentSlice,
)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Update deployment failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["deployUpdateInput"] = deployUpdateInput
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:52,代码来源:deploy.go
示例13: deleteDeployBlueGreen
func deleteDeployBlueGreen(request *restful.Request, response *restful.Response) {
imageInformation := request.PathParameter("imageinformation")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
err = deploy.GetStorage().DeleteDeployBlueGreen(imageInformation)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Delete blue green deployment failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["imageInformation"] = imageInformation
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
err = deploy.CleanAllServiceUnderBlueGreenDeployment(kubeApiServerEndPoint, kubeApiServerToken, imageInformation)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Delete all services under blue green deployment failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["imageInformation"] = imageInformation
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
err = slb.SendCommandToAllSLBDaemon()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Configure SLB failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:51,代码来源:deploy_blue_green.go
示例14: putDeployBlueGreen
func putDeployBlueGreen(request *restful.Request, response *restful.Response) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
deployBlueGreen := new(deploy.DeployBlueGreen)
err = request.ReadEntity(&deployBlueGreen)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = deploy.UpdateDeployBlueGreen(kubeApiServerEndPoint, kubeApiServerToken, deployBlueGreen)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Update blue green deployment failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["deployBlueGreen"] = deployBlueGreen
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
err = slb.SendCommandToAllSLBDaemon()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Configure SLB failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:49,代码来源:deploy_blue_green.go
示例15: putReplicationControllerSize
func putReplicationControllerSize(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
replicationController := request.PathParameter("replicationcontroller")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["replicationController"] = replicationController
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
sizeInput := SizeInput{}
err = request.ReadEntity(&sizeInput)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["replicationController"] = replicationController
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = control.UpdateReplicationControllerSize(kubeApiServerEndPoint, kubeApiServerToken, namespace, replicationController, sizeInput.Size)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Resize replication controller failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["replicationController"] = replicationController
jsonMap["size"] = sizeInput.Size
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:47,代码来源:replication_controller.go
示例16: putKubernetesServiceFromJson
func putKubernetesServiceFromJson(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
serviceName := request.PathParameter("service")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
jsonMap["serviceName"] = serviceName
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
service := make(map[string]interface{})
err = request.ReadEntity(&service)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = control.UpdateServiceWithJson(kubeApiServerEndPoint, kubeApiServerToken, namespace, serviceName, service)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Update service failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
jsonMap["service"] = service
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:45,代码来源:service.go
示例17: getAllReplicationControllerMetric
func getAllReplicationControllerMetric(request *restful.Request, response *restful.Response) {
namespace := request.PathParameter("namespace")
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
nameSlice, err := control.GetAllReplicationControllerName(kubeApiServerEndPoint, kubeApiServerToken, namespace)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get all replication controller name failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
replicationControllerMetricSlice := make([]monitor.ReplicationControllerMetric, 0)
errorSlice := make([]error, 0)
for _, name := range nameSlice {
replicationControllerMetric, err := monitor.MonitorReplicationController(kubeApiServerEndPoint, kubeApiServerToken, namespace, name)
if replicationControllerMetric != nil {
replicationControllerMetricSlice = append(replicationControllerMetricSlice, *replicationControllerMetric)
}
errorSlice = append(errorSlice, err)
}
returnedJsonMap := make(map[string]interface{})
returnedJsonMap["ReplicationControllerMetricSlice"] = replicationControllerMetricSlice
returnedJsonMap["ErrorSlice"] = errorSlice
response.WriteJson(returnedJsonMap, "ReplicationControllerMetricSlice/ErrorSlice")
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:43,代码来源:replication_controller_metric.go
示例18: postKubernetesNamespace
func postKubernetesNamespace(request *restful.Request, response *restful.Response) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
namespace := new(Namesapce)
err = request.ReadEntity(&namespace)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = control.CreateNamespace(kubeApiServerEndPoint, kubeApiServerToken, namespace.Name)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Create namespace failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
jsonMap["namespace"] = namespace
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:39,代码来源:namespace.go
示例19: postGithub
func postGithub(request *restful.Request, response *restful.Response) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
githubPost := GithubPost{}
err = request.ReadEntity(&githubPost)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
err = webhook.Notify(githubPost.User, githubPost.ImageInformation, githubPost.Signature, githubPost.Payload, kubeApiServerEndPoint, kubeApiServerToken)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Notify webhook failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["kubeApiServerEndPoint"] = kubeApiServerEndPoint
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
}
开发者ID:cloudawan,项目名称:cloudone,代码行数:36,代码来源:webhook.go
示例20: putImageInformationUpgrade
func putImageInformationUpgrade(request *restful.Request, response *restful.Response) {
kubeApiServerEndPoint, kubeApiServerToken, err := configuration.GetAvailablekubeApiServerEndPoint()
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Get kube apiserver endpoint and token failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(404, string(errorMessageByteSlice))
return
}
imageInformationUpgradeInput := new(ImageInformationUpgradeInput)
err = request.ReadEntity(&imageInformationUpgradeInput)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Read body failure"
jsonMap["ErrorMessage"] = err.Error()
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(400, string(errorMessageByteSlice))
return
}
if lock.LockAvailable(image.LockKind, imageInformationUpgradeInput.ImageInformationName) == false {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Duplicated command failure"
jsonMap["ErrorMessage"] = "Image is under construction"
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(403, string(errorMessageByteSlice))
return
}
// Initialize the output file for websocket
image.TouchOutMessageFile(imageInformationUpgradeInput.ImageInformationName)
go func() {
_, err := image.BuildUpgrade(
imageInformationUpgradeInput.ImageInformationName,
imageInformationUpgradeInput.Description)
if err == nil {
// Build sccessfully
// Auto rolling update the deployment if configured
imageInformation, err := image.GetStorage().LoadImageInformation(imageInformationUpgradeInput.ImageInformationName)
if err != nil {
log.Error(err)
} else {
deployInformationSlice, err := deploy.GetDeployInformationWithAutoUpdateForNewBuild(imageInformationUpgradeInput.ImageInformationName)
if err != nil {
log.Error(err)
} else {
for _, deployInformation := range deployInformationSlice {
description := "Trigged by version " + imageInformation.CurrentVersion
err := deploy.DeployUpdate(
kubeApiServerEndPoint,
kubeApiServerToken,
deployInformation.Namespace,
imageInformation.Name,
imageInformation.CurrentVersion,
description,
deployInformation.EnvironmentSlice)
if err != nil {
log.Error(err)
}
}
}
}
}
}()
/*
outputMessage, err := image.BuildUpgrade(
imageInformationUpgradeInput.ImageInformationName,
imageInformationUpgradeInput.Description)
resultJsonMap := make(map[string]interface{})
resultJsonMap["OutputMessage"] = outputMessage
statusCode := 200
if err != nil {
statusCode = 422
resultJsonMap["Error"] = "Upgrade build failure"
resultJsonMap["ErrorMessage"] = err.Error()
resultJsonMap["imageInformationUpgradeInput"] = imageInformationUpgradeInput
log.Error(resultJsonMap)
}
result, err := json.Marshal(resultJsonMap)
if err != nil {
jsonMap := make(map[string]interface{})
jsonMap["Error"] = "Marshal output message failure"
jsonMap["ErrorMessage"] = err.Error()
jsonMap["resultJsonMap"] = resultJsonMap
errorMessageByteSlice, _ := json.Marshal(jsonMap)
log.Error(jsonMap)
response.WriteErrorString(422, string(errorMessageByteSlice))
return
}
response.WriteErrorString(statusCode, string(result))
return
*/
//.........这里部分代码省略.........
开发者ID:cloudawan,项目名称:cloudone,代码行数:101,代码来源:image_information.go
注:本文中的github.com/cloudawan/cloudone/utility/configuration.GetAvailablekubeApiServerEndPoint函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论