wrap log
This commit is contained in:
parent
d17d521e4a
commit
c3cd41a24f
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -13,6 +12,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rootprojects.org/root/gitdeploy/internal/log"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/options"
|
"git.rootprojects.org/root/gitdeploy/internal/options"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ func Route(r chi.Router, runOpts *options.ServerConfig) {
|
||||||
// r.Body is always .Close()ed by Go's http server
|
// r.Body is always .Close()ed by Go's http server
|
||||||
r.Body = http.MaxBytesReader(w, r.Body, options.DefaultMaxBodySize)
|
r.Body = http.MaxBytesReader(w, r.Body, options.DefaultMaxBodySize)
|
||||||
// TODO admin auth middleware
|
// TODO admin auth middleware
|
||||||
log.Println("TODO: handle authentication")
|
log.Printf("TODO: handle authentication")
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -153,7 +153,7 @@ func Route(r chi.Router, runOpts *options.ServerConfig) {
|
||||||
decoder := json.NewDecoder(r.Body)
|
decoder := json.NewDecoder(r.Body)
|
||||||
msg := &KillMsg{}
|
msg := &KillMsg{}
|
||||||
if err := decoder.Decode(msg); nil != err {
|
if err := decoder.Decode(msg); nil != err {
|
||||||
log.Println("kill job invalid json:", err)
|
log.Printf("kill job invalid json:\n%v", err)
|
||||||
http.Error(w, "invalid json body", http.StatusBadRequest)
|
http.Error(w, "invalid json body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -178,12 +178,12 @@ func Route(r chi.Router, runOpts *options.ServerConfig) {
|
||||||
decoder := json.NewDecoder(r.Body)
|
decoder := json.NewDecoder(r.Body)
|
||||||
msg := &webhooks.Ref{}
|
msg := &webhooks.Ref{}
|
||||||
if err := decoder.Decode(msg); nil != err {
|
if err := decoder.Decode(msg); nil != err {
|
||||||
log.Println("promotion job invalid json:", err)
|
log.Printf("promotion job invalid json:\n%v", err)
|
||||||
http.Error(w, "invalid json body", http.StatusBadRequest)
|
http.Error(w, "invalid json body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if "" == msg.HTTPSURL || "" == msg.RefName {
|
if "" == msg.HTTPSURL || "" == msg.RefName {
|
||||||
log.Println("promotion job incomplete json", msg)
|
log.Printf("promotion job incomplete json %s", msg)
|
||||||
http.Error(w, "incomplete json body", http.StatusBadRequest)
|
http.Error(w, "incomplete json body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ func Route(r chi.Router, runOpts *options.ServerConfig) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
log.Println("promotion job invalid: cannot promote:", n)
|
log.Printf("promotion job invalid: cannot promote: %d", n)
|
||||||
http.Error(w, "invalid promotion", http.StatusBadRequest)
|
http.Error(w, "invalid promotion", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ func remove(jobID string, nokill bool) {
|
||||||
if nil != job.Cmd.Process {
|
if nil != job.Cmd.Process {
|
||||||
// but definitely was started
|
// but definitely was started
|
||||||
err := job.Cmd.Process.Kill()
|
err := job.Cmd.Process.Kill()
|
||||||
log.Println("error killing job:", err)
|
log.Printf("error killing job:\n%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Printf wraps log.Printf
|
||||||
|
func Printf(msg string, els ...interface{}) {
|
||||||
|
log.Printf(msg, els...)
|
||||||
|
}
|
|
@ -5,11 +5,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.rootprojects.org/root/gitdeploy/internal/log"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/options"
|
"git.rootprojects.org/root/gitdeploy/internal/options"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func InitWebhook(providername string, secretList *string, envname string) func()
|
||||||
branch = refName
|
branch = refName
|
||||||
ref = fmt.Sprintf("refs/heads/%s", refName)
|
ref = fmt.Sprintf("refs/heads/%s", refName)
|
||||||
default:
|
default:
|
||||||
log.Println("unexpected bitbucket RefType", refType)
|
log.Printf("unexpected bitbucket RefType %s\n", refType)
|
||||||
ref = fmt.Sprintf("refs/UNKNOWN/%s", refName)
|
ref = fmt.Sprintf("refs/UNKNOWN/%s", refName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.rootprojects.org/root/gitdeploy/internal/log"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/options"
|
"git.rootprojects.org/root/gitdeploy/internal/options"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ package github
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.rootprojects.org/root/gitdeploy/internal/log"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/options"
|
"git.rootprojects.org/root/gitdeploy/internal/options"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -15,6 +14,7 @@ import (
|
||||||
"git.rootprojects.org/root/gitdeploy/assets/examples"
|
"git.rootprojects.org/root/gitdeploy/assets/examples"
|
||||||
"git.rootprojects.org/root/gitdeploy/assets/public"
|
"git.rootprojects.org/root/gitdeploy/assets/public"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/api"
|
"git.rootprojects.org/root/gitdeploy/internal/api"
|
||||||
|
"git.rootprojects.org/root/gitdeploy/internal/log"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/options"
|
"git.rootprojects.org/root/gitdeploy/internal/options"
|
||||||
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
"git.rootprojects.org/root/gitdeploy/internal/webhooks"
|
||||||
"git.rootprojects.org/root/vfscopy"
|
"git.rootprojects.org/root/vfscopy"
|
||||||
|
|
Loading…
Reference in New Issue