예제 #1
0
파일: app.go 프로젝트: asyoume/paas_srv
// 创建服务器
func (this *AppHandler) Post(args *types.App, reply *types.Event) error {
	//c := NewkubeClient()
	args.Id = "default"

	/*if len(args.Pods) == 0 {
		reply.Code = 500
		reply.Content = "Pods lenght 0"
		return errors.New("Pods lenght 0")
	}

	pods := c.Pods(args.Id)
	for _, v := range args.Pods {
		// 转换实例配置文件
		conf := utils.PodToKubeStruct(v)
		_, err := pods.Create(conf)
		if err != nil {
			return err
		}
	}

	sers := c.Services(args.Id)
	for _, v := range args.Services {
		// 转换网络配置文件
		conf := utils.ServiceTokubenetStruct(v)
		_, err := sers.Create(conf)
		if err != nil {
			return err
		}
	}*/

	reply.Code = 200
	reply.Content = "ok"

	return nil
}
예제 #2
0
파일: app.go 프로젝트: asyoume/paas_srv
func appPost(c echo.Context) error {
	app := new(types.App)
	reply := new(types.Event)
	err := RecvData(c, app)

	if err != nil {
		reply.Code = http.StatusBadRequest
		reply.Content = "数据序列化错误"
		return SendData(c, http.StatusBadRequest, reply)
	}

	err = appHandler.Post(app, reply)

	if err != nil {
		reply.Code = http.StatusInternalServerError
		reply.Content = err.Error()
		return SendData(c, http.StatusInternalServerError, reply)
	}

	return SendData(c, http.StatusOK, reply)
}
예제 #3
0
파일: app.go 프로젝트: asyoume/paas_srv
func appPut(c echo.Context) error {
	app := new(types.App)
	reply := new(types.Event)
	err := RecvData(c, app)

	if err != nil {
		reply.Code = http.StatusBadRequest
		reply.Content = "数据格式为非protobuf"
		return SendData(c, http.StatusBadRequest, reply)
	}

	err = appHandler.Post(app, reply)

	if err != nil {
		fmt.Println(err)
		fmt.Println(reply)
		return SendData(c, http.StatusInternalServerError, reply)
	}

	return SendData(c, http.StatusOK, reply)
}