update dependencies

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2020-12-22 16:48:26 +08:00
parent 4a11a50544
commit fe6c5de00f
2857 changed files with 252134 additions and 115656 deletions

View File

@@ -19,7 +19,6 @@ package v1alpha2
import (
"fmt"
"github.com/emicklei/go-restful"
"github.com/kiali/kiali/handlers"
"io/ioutil"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api"
@@ -46,14 +45,10 @@ var KialiQueryUrl string
// Get app metrics
func getAppMetrics(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.AppMetrics(request, response)
} else {
namespace := request.PathParameter("namespace")
app := request.PathParameter("app")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/apps/%s/metrics?%s", KialiQueryUrl, namespace, app, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
app := request.PathParameter("app")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/apps/%s/metrics?%s", KialiQueryUrl, namespace, app, request.Request.URL.RawQuery)
getData(response, url)
}
// Get workload metrics
@@ -65,35 +60,23 @@ func getWorkloadMetrics(request *restful.Request, response *restful.Response) {
request.Request.URL.RawQuery = fmt.Sprintf("%s&namespaces=%s&workload=%s", request.Request.URL.RawQuery, namespace, workload)
}
if len(KialiQueryUrl) == 0 {
handlers.WorkloadMetrics(request, response)
} else {
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/workloads/%s/metrics?%s", KialiQueryUrl, namespace, workload, request.Request.URL.RawQuery)
getData(response, url)
}
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/workloads/%s/metrics?%s", KialiQueryUrl, namespace, workload, request.Request.URL.RawQuery)
getData(response, url)
}
// Get service metrics
func getServiceMetrics(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.ServiceMetrics(request, response)
} else {
namespace := request.PathParameter("namespace")
service := request.PathParameter("service")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/services/%s/metrics?%s", KialiQueryUrl, namespace, service, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
service := request.PathParameter("service")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/services/%s/metrics?%s", KialiQueryUrl, namespace, service, request.Request.URL.RawQuery)
getData(response, url)
}
// Get namespace metrics
func getNamespaceMetrics(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.NamespaceMetrics(request, response)
} else {
namespace := request.PathParameter("namespace")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/metrics?%s", KialiQueryUrl, namespace, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/metrics?%s", KialiQueryUrl, namespace, request.Request.URL.RawQuery)
getData(response, url)
}
// Get service graph for namespace
@@ -104,65 +87,39 @@ func getNamespaceGraph(request *restful.Request, response *restful.Response) {
request.Request.URL.RawQuery = fmt.Sprintf("%s&namespaces=%s", request.Request.URL.RawQuery, namespace)
}
if len(KialiQueryUrl) == 0 {
handlers.GetNamespaceGraph(request, response)
} else {
url := fmt.Sprintf("%s/kiali/api/namespaces/graph?%s", KialiQueryUrl, request.Request.URL.RawQuery)
getData(response, url)
}
}
// Deprecated
// Get service graph for namespaces
func getNamespacesGraph(request *restful.Request, response *restful.Response) {
handlers.GraphNamespaces(request, response)
url := fmt.Sprintf("%s/kiali/api/namespaces/graph?%s", KialiQueryUrl, request.Request.URL.RawQuery)
getData(response, url)
}
// Get namespace health
func getNamespaceHealth(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.NamespaceHealth(request, response)
} else {
namespace := request.PathParameter("namespace")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/health?%s", KialiQueryUrl, namespace, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/health?%s", KialiQueryUrl, namespace, request.Request.URL.RawQuery)
getData(response, url)
}
// Get workload health
func getWorkloadHealth(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.WorkloadHealth(request, response)
} else {
namespace := request.PathParameter("namespace")
workload := request.PathParameter("workload")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/workloads/%s/health?%s", KialiQueryUrl, namespace, workload, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
workload := request.PathParameter("workload")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/workloads/%s/health?%s", KialiQueryUrl, namespace, workload, request.Request.URL.RawQuery)
getData(response, url)
}
// Get app health
func getAppHealth(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.AppHealth(request, response)
} else {
namespace := request.PathParameter("namespace")
app := request.PathParameter("app")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/apps/%s/health?%s", KialiQueryUrl, namespace, app, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
app := request.PathParameter("app")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/apps/%s/health?%s", KialiQueryUrl, namespace, app, request.Request.URL.RawQuery)
getData(response, url)
}
// Get service health
func getServiceHealth(request *restful.Request, response *restful.Response) {
if len(KialiQueryUrl) == 0 {
handlers.ServiceHealth(request, response)
} else {
namespace := request.PathParameter("namespace")
service := request.PathParameter("service")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/services/%s/health?%s", KialiQueryUrl, namespace, service, request.Request.URL.RawQuery)
getData(response, url)
}
namespace := request.PathParameter("namespace")
service := request.PathParameter("service")
url := fmt.Sprintf("%s/kiali/api/namespaces/%s/services/%s/health?%s", KialiQueryUrl, namespace, service, request.Request.URL.RawQuery)
getData(response, url)
}
func getServiceTracing(request *restful.Request, response *restful.Response) {

View File

@@ -21,7 +21,7 @@ import (
"github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"net/http"
_ "net/http"
)
const groupName = "servicemesh.kubesphere.io"
@@ -52,8 +52,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
Returns(http.StatusOK, "ok", metricsResponse{}).
Writes(metricsResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get app metrics
// Get /namespaces/{namespace}/apps/{app}/metrics
@@ -73,9 +72,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
Returns(http.StatusOK, "ok", metricsResponse{}).
Writes(metricsResponse{})).
Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get workload metrics
// Get /namespaces/{namespace}/workloads/{workload}/metrics
@@ -95,9 +92,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
Returns(http.StatusOK, "ok", metricsResponse{}).
Writes(metricsResponse{})).
Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get namespace metrics
// Get /namespaces/{namespace}/metrics
@@ -116,8 +111,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.QueryParameter("byLabels[]", "list of labels to use for grouping metrics(via Prometheus 'by' clause), e.g. source_workload, destination_service_name").DefaultValue("[]")).
Param(webservice.QueryParameter("requestProtocol", "request protocol for the telemetry, e.g. http/tcp/grpc").DefaultValue("all protocols")).
Param(webservice.QueryParameter("reporter", "istio telemetry reporter, 'source' or 'destination'").DefaultValue("source")).
Returns(http.StatusOK, "ok", metricsResponse{}).
Writes(metricsResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get namespace graph
// Get /namespaces/{namespace}/graph
@@ -131,26 +125,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.QueryParameter("groupBy", "app box grouping characteristic. Available groupings: [app, none, version].").DefaultValue("none")).
Param(webservice.QueryParameter("queryTime", "from which time point in UNIX timestamp, default now")).
Param(webservice.QueryParameter("injectServiceNodes", "flag for injecting the requested service node between source and destination nodes.").DefaultValue("false")).
Returns(http.StatusBadRequest, "bad request", BadRequestError{}).
Returns(http.StatusNotFound, "not found", NotFoundError{}).
Returns(http.StatusOK, "ok", graphResponse{}).
Writes(graphResponse{})).Produces(restful.MIME_JSON)
// Get namespaces graph, for multiple namespaces
// Get /namespaces/graph
webservice.Route(webservice.GET("/namespaces/graph").
To(getNamespacesGraph).
Metadata(restfulspec.KeyOpenAPITags, tags).
Doc("Get graph from all namespaces").
Param(webservice.QueryParameter("duration", "duration of the query period, in seconds").DefaultValue("10m")).
Param(webservice.QueryParameter("graphType", "type of the generated service graph. Available graph types: [app, service, versionedApp, workload].").DefaultValue("workload")).
Param(webservice.QueryParameter("groupBy", "app box grouping characteristic. Available groupings: [app, none, version].").DefaultValue("none")).
Param(webservice.QueryParameter("queryTime", "from which time point in UNIX timestamp, default now")).
Param(webservice.QueryParameter("injectServiceNodes", "flag for injecting the requested service node between source and destination nodes.").DefaultValue("false")).
Returns(http.StatusBadRequest, "bad request", BadRequestError{}).
Returns(http.StatusNotFound, "not found", NotFoundError{}).
Returns(http.StatusOK, "ok", graphResponse{}).
Writes(graphResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get namespace health
webservice.Route(webservice.GET("/namespaces/{namespace}/health").
@@ -160,10 +135,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.PathParameter("namespace", "name of a namespace").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Returns(http.StatusBadRequest, "bad request", BadRequestError{}).
Returns(http.StatusNotFound, "not found", NotFoundError{}).
Returns(http.StatusOK, "ok", namespaceAppHealthResponse{}).
Writes(namespaceAppHealthResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get workloads health
webservice.Route(webservice.GET("/namespaces/{namespace}/workloads/{workload}/health").
@@ -174,8 +146,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.PathParameter("workload", "workload name").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Returns(http.StatusOK, "ok", workloadHealthResponse{}).
Writes(workloadHealthResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get app health
webservice.Route(webservice.GET("/namespaces/{namespace}/apps/{app}/health").
@@ -186,8 +157,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.PathParameter("app", "app name").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Returns(http.StatusOK, "ok", appHealthResponse{}).
Writes(appHealthResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get service health
webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/health").
@@ -198,8 +168,7 @@ func AddToContainer(c *restful.Container) error {
Param(webservice.PathParameter("service", "service name").Required(true)).
Param(webservice.QueryParameter("rateInterval", "the rate interval used for fetching error rate").DefaultValue("10m").Required(true)).
Param(webservice.QueryParameter("queryTime", "the time to use for query")).
Returns(http.StatusOK, "ok", serviceHealthResponse{}).
Writes(serviceHealthResponse{})).Produces(restful.MIME_JSON)
Produces(restful.MIME_JSON))
// Get service tracing
webservice.Route(webservice.GET("/namespaces/{namespace}/services/{service}/traces").

View File

@@ -1,70 +0,0 @@
/*
Copyright 2020 KubeSphere Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha2
import (
"github.com/kiali/kiali/graph/cytoscape"
"github.com/kiali/kiali/models"
"github.com/kiali/kiali/prometheus"
)
/////////////////////
// SWAGGER RESPONSES
/////////////////////
// NoContent: the response is empty
type NoContent struct {
Status int32 `json:"status"`
Reason error `json:"reason"`
}
// BadRequestError: the client request is incorrect
type BadRequestError struct {
Status int32 `json:"status"`
Reason error `json:"reason"`
}
// NotFoundError is the error message that is generated when server could not find
// what was requested
type NotFoundError struct {
Status int32 `json:"status"`
Reason error `json:"reason"`
}
type graphResponse struct {
cytoscape.Config
}
type serviceHealthResponse struct {
models.ServiceHealth
}
type namespaceAppHealthResponse struct {
models.NamespaceAppHealth
}
type workloadHealthResponse struct {
models.WorkloadHealth
}
type appHealthResponse struct {
models.AppHealth
}
type metricsResponse struct {
prometheus.Metrics
}