-
Notifications
You must be signed in to change notification settings - Fork 4
/
istio.go
69 lines (61 loc) · 1.65 KB
/
istio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package controllers
import (
"github.com/hidevopsio/hiboot/pkg/starter/web"
"istio.io/istio/pkg/log"
"github.com/hidevopsio/hicicd/pkg/orch/istio"
"net/http"
)
// Operations about object
type IstioController struct {
BaseController
}
func init() {
web.Add(new(IstioController))
}
type IResponse struct {
Version string `json:"version"`
}
func (c *IstioController) PostDelete(ctx *web.Context) {
log.Debug("istio delete controller type")
var route istio.RouterRule
ctx.RequestBody(&route)
if route.Type >= 5 {
ctx.ResponseError("Index Out Of Bounds Exception route Type Length to Large", http.StatusLengthRequired)
return
}
config, err := istio.NewClient()
if err != nil {
ctx.ResponseError(err.Error(), http.StatusRequestedRangeNotSatisfiable)
return
}
route.Crd = config
err = route.Delete(istio.Typ[route.Type])
if err != nil {
ctx.ResponseError( err.Error(), http.StatusRequestedRangeNotSatisfiable)
return
}
message := "success"
ctx.ResponseBody(message, nil)
}
func (c *IstioController) PostGet(ctx *web.Context) {
log.Debug("istio get controller type")
var route istio.RouterRule
ctx.RequestBody(&route)
if route.Type >= 5 {
ctx.ResponseError("Index Out Of Bounds Exception route Type Length to Large", http.StatusLengthRequired)
return
}
config, err := istio.NewClient()
if err != nil {
ctx.ResponseError(err.Error(), http.StatusRequestedRangeNotSatisfiable)
return
}
route.Crd = config
conf, exists := route.Get(istio.Typ[route.Type])
if exists == false {
ctx.ResponseError( "not found istio type:" + istio.Typ[route.Type] , http.StatusNotFound)
return
}
message := "success"
ctx.ResponseBody(message, conf)
}