mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-04 04:38:04 +08:00
commit
242757fac1
@ -51,16 +51,7 @@ func init() {
|
||||
//InitTenant 实现中间件
|
||||
func InitTenant(next http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
if !apiExclude(r) {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
logrus.Warningf("error reading request body: %v", err)
|
||||
} else {
|
||||
logrus.Debugf("method: %s; uri: %s; body: %s", r.Method, r.RequestURI, string(body))
|
||||
}
|
||||
// set a new body, which will simulate the same data we read
|
||||
r.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
||||
}
|
||||
debugRequestBody(r)
|
||||
|
||||
tenantName := chi.URLParam(r, "tenant_name")
|
||||
if tenantName == "" {
|
||||
@ -117,6 +108,8 @@ func InitService(next http.Handler) http.Handler {
|
||||
//InitPlugin 实现plugin init中间件
|
||||
func InitPlugin(next http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
debugRequestBody(r)
|
||||
|
||||
pluginID := chi.URLParam(r, "plugin_id")
|
||||
tenantID := r.Context().Value(ContextKey("tenant_id")).(string)
|
||||
if pluginID == "" {
|
||||
@ -282,3 +275,16 @@ func WrapEL(f http.HandlerFunc, target, optType string, synType int) http.Handle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func debugRequestBody(r *http.Request) {
|
||||
if !apiExclude(r) {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
logrus.Warningf("error reading request body: %v", err)
|
||||
}
|
||||
logrus.Debugf("method: %s; uri: %s; body: %s", r.Method, r.RequestURI, string(body))
|
||||
|
||||
// set a new body, which will simulate the same data we read
|
||||
r.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ func (b *BackupAPPNew) backupPluginInfo(appSnapshot *AppSnapshot) error {
|
||||
func (b *BackupAPPNew) checkVersionExist(version *dbmodel.VersionInfo) (bool, error) {
|
||||
if version.DeliveredType == "image" {
|
||||
imageInfo := sources.ImageNameHandle(version.DeliveredPath)
|
||||
reg, err := registry.NewInsecure(imageInfo.Host, "", "")
|
||||
reg, err := registry.NewInsecure(imageInfo.Host, builder.REGISTRYUSER, builder.REGISTRYPASS)
|
||||
if err != nil {
|
||||
logrus.Errorf("new registry client error %s", err.Error())
|
||||
return false, err
|
||||
|
@ -68,7 +68,8 @@ func (e *exectorManager) pluginImageBuild(task *pb.TaskMessage) {
|
||||
}
|
||||
|
||||
func (e *exectorManager) run(t *model.BuildPluginTaskBody, logger event.Logger) error {
|
||||
if _, err := sources.ImagePull(e.DockerClient, t.ImageURL, t.ImageInfo.HubUser, t.ImageInfo.HubPassword, logger, 10); err != nil {
|
||||
hubUser, hubPass := builder.GetImageUserInfo(t.ImageInfo.HubUser, t.ImageInfo.HubPassword)
|
||||
if _, err := sources.ImagePull(e.DockerClient, t.ImageURL, hubUser, hubPass, logger, 10); err != nil {
|
||||
logrus.Errorf("pull image %v error, %v", t.ImageURL, err)
|
||||
logger.Error("拉取镜像失败", map[string]string{"step": "builder-exector", "status": "failure"})
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user