[FIX] Fix uri permission bug

This commit is contained in:
pujielan 2018-01-05 14:17:45 +08:00
parent 3df840379e
commit fa9515fc9a
3 changed files with 13 additions and 22 deletions

View File

@ -94,6 +94,7 @@ CREATE:
rui := &dbmodel.RegionUserInfo{
EID: gt.Body.EID,
RegionTag: c.RegionTag,
APIRange: gt.Body.Range,
ValidityPeriod: gt.Body.ValidityPeriod,
Token: token,
}

View File

@ -23,6 +23,7 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os/exec"
"github.com/goodrain/rainbond/pkg/event"
@ -58,8 +59,6 @@ func ShowExec(command string, params []string, logger ...event.Logger) error {
if err != nil {
return err
}
errReader := bufio.NewReader(stderr)
errChan := make(chan error)
cmd.Start()
reader := bufio.NewReader(stdout)
go func() {
@ -73,24 +72,15 @@ func ShowExec(command string, params []string, logger ...event.Logger) error {
logger[0].Debug(fmt.Sprintf("builder:%v", line), map[string]string{"step": "build-exector"})
}
}()
go func() {
for {
errLine, errL := errReader.ReadString('\n')
if errL != nil {
logrus.Debugf("err line error: %s", errL.Error())
}
logrus.Errorf(fmt.Sprintf("builder error: %v", errLine))
logger[0].Error(fmt.Sprintf("build Error: %v", errLine), map[string]string{"step": "builder-exector", "status": "failure"})
errChan <- fmt.Errorf(errLine)
break
}
}()
//cmd.Wait()
select {
case mm := <-errChan:
return mm
default:
cmd.Wait()
bytesErr, err := ioutil.ReadAll(stderr)
if err != nil {
return err
}
if len(bytesErr) != 0 {
logrus.Debugf("builder: %s", bytesErr)
logger[0].Debug(fmt.Sprintf("builder:%v", string(bytesErr)), map[string]string{"step": "build-exector"})
return fmt.Errorf("%s", bytesErr)
}
cmd.Wait()
return nil
}

View File

@ -163,8 +163,8 @@ func clone(gitURL string, sourceDir string, logger event.Logger, repo string) er
}
} else {
logrus.Debugf("pull: %s", fmt.Sprintf("cd %s && sudo -P git pull", sourceDir))
mm := []string{"-P", "cd", sourceDir, "&", "sudo", "-P", "git", "pull"}
if err := ShowExec("sudo", mm, logger); err != nil {
mm := []string{sourceDir, "&", "sudo", "-P", "git", "pull"}
if err := ShowExec("cd", mm, logger); err != nil {
return err
}
}