refactor: switch from base64-encoding to base36-encoding of cron task IDs
This allows the IDs to be used as DNS labels, meaning they can be used as is for external scheduler task names. Closes #4903
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
appjson "github.com/dokku/dokku/plugins/app-json"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
|
||||
base36 "github.com/multiformats/go-base36"
|
||||
cronparser "github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
@@ -126,7 +126,7 @@ func writeCronEntries() error {
|
||||
return fmt.Errorf("Invalid injected cron task: %v", line)
|
||||
}
|
||||
|
||||
id := base64.StdEncoding.EncodeToString([]byte(strings.Join(parts, ";;;")))
|
||||
id := base36.EncodeToStringLc([]byte(strings.Join(parts, ";;;")))
|
||||
command := templateCommand{
|
||||
ID: id,
|
||||
Schedule: parts[0],
|
||||
@@ -189,5 +189,5 @@ func getCronTemplate() (*template.Template, error) {
|
||||
}
|
||||
|
||||
func generateCommandID(appName string, c appjson.CronCommand) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(appName + "===" + c.Command + "===" + c.Schedule))
|
||||
return base36.EncodeToStringLc([]byte(appName + "===" + c.Command + "===" + c.Schedule))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user