1. add registries create, query apis

2.  fix components bug
This commit is contained in:
yanmingfan
2018-06-05 15:58:42 +08:00
parent d71f7770b8
commit 49e32284d6
4 changed files with 227 additions and 22 deletions

View File

@@ -17,11 +17,13 @@ limitations under the License.
package registries
import (
"github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/models"
"kubesphere.io/kubesphere/pkg/filter/route"
"net/http"
"github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/filter/route"
"kubesphere.io/kubesphere/pkg/models"
)
func Register(ws *restful.WebService, subPath string) {
@@ -30,6 +32,14 @@ func Register(ws *restful.WebService, subPath string) {
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
ws.Route(ws.POST(subPath).To(handleCreateRegistries).Filter(route.RouteLogging)).
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
ws.Route(ws.GET(subPath + "/{project}").To(handleQueryRegistries).Filter(route.RouteLogging)).
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)
}
func handlerRegistryValidation(request *restful.Request, response *restful.Response) {
@@ -42,12 +52,55 @@ func handlerRegistryValidation(request *restful.Request, response *restful.Respo
response.WriteHeaderAndEntity(http.StatusInternalServerError, constants.MessageResponse{Message: err.Error()})
} else {
result := models.RegistryLoginAuth(authinfo)
response.WriteAsJson(result)
}
result := models.RegistryLoginAuth(authinfo)
response.WriteAsJson(result)
}
func handleCreateRegistries(request *restful.Request, response *restful.Response) {
registries := models.Registries{}
err := request.ReadEntity(&registries)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, constants.MessageResponse{Message: err.Error()})
}
result, err := models.CreateRegistries(registries)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, constants.MessageResponse{Message: err.Error()})
} else {
response.WriteAsJson(result)
}
}
func handleQueryRegistries(request *restful.Request, response *restful.Response) {
project := request.PathParameter("project")
result, err := models.QueryRegistries(project)
if err != nil {
response.WriteHeaderAndEntity(http.StatusInternalServerError, constants.MessageResponse{Message: err.Error()})
} else {
response.WriteAsJson(result)
}
}