mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
add CreateWorkflowData
This commit is contained in:
parent
d92f9305dc
commit
f81731e2d9
1 changed files with 15 additions and 2 deletions
|
@ -47,6 +47,18 @@ type WorkflowData struct {
|
|||
repositoryMAC string
|
||||
}
|
||||
|
||||
func (h *Handler) CreateWorkflowData(owner string, name string, runnumber string, timestamp string) WorkflowData {
|
||||
repo := owner + "/" + name
|
||||
mac := computeMac(h.cacheSecret, repo, runnumber, timestamp)
|
||||
return WorkflowData{
|
||||
repositoryOwner: owner,
|
||||
repositoryName: name,
|
||||
runNumber: runnumber,
|
||||
timestamp: timestamp,
|
||||
repositoryMAC: mac,
|
||||
}
|
||||
}
|
||||
|
||||
func StartHandler(targetHost string, outboundIP string, port uint16, cacheSecret string, logger logrus.FieldLogger) (*Handler, error) {
|
||||
h := &Handler{}
|
||||
|
||||
|
@ -59,6 +71,7 @@ func StartHandler(targetHost string, outboundIP string, port uint16, cacheSecret
|
|||
h.logger = logger
|
||||
|
||||
h.cacheSecret = cacheSecret
|
||||
h.workflows = make(map[string]WorkflowData)
|
||||
|
||||
if outboundIP != "" {
|
||||
h.outboundIP = outboundIP
|
||||
|
@ -187,8 +200,8 @@ func (h *Handler) Close() error {
|
|||
return retErr
|
||||
}
|
||||
|
||||
func computeMac(key, repo, run, ts string) string {
|
||||
mac := hmac.New(sha256.New, []byte(key))
|
||||
func computeMac(secret, repo, run, ts string) string {
|
||||
mac := hmac.New(sha256.New, []byte(secret))
|
||||
mac.Write([]byte(repo))
|
||||
mac.Write([]byte(run))
|
||||
mac.Write([]byte(ts))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue