fix(forgejo): add support for enabling actions

This commit is contained in:
Dan Anglin 2023-08-28 08:53:22 +01:00
parent dd339eb3d6
commit 18412e62cb
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
3 changed files with 49 additions and 27 deletions

View file

@ -74,6 +74,12 @@ type forgejoConfig struct {
Oauth2Enable bool `json:"oauth2Enable"`
Oauth2JwtSigningAlgo string `json:"oauth2JwtSigningAlgo"`
Oauth2JwtSecret string `json:"oauth2JwtSecret"`
Actions forgejoActionsConfig `json:"actions"`
}
type forgejoActionsConfig struct {
Enabled bool `json:"enabled"`
DefaultActionsURL string `json:"defaultActionsURL"`
}
type gotosocialConfig struct {

View file

@ -110,6 +110,10 @@ func render(cfg config, environment, component string) error {
return fmt.Errorf("unable to read files from %s; %w ", templateDirName, err)
}
funcMap := template.FuncMap{
"default": defaultValue,
}
for _, f := range files {
err := func() error {
templateFilename := f.Name()
@ -128,7 +132,7 @@ func render(cfg config, environment, component string) error {
defer file.Close()
templatePath := filepath.Join(templateDirName, templateFilename)
tmpl, err := template.New(templateFilename).ParseFiles(templatePath)
tmpl, err := template.New(templateFilename).Funcs(funcMap).ParseFiles(templatePath)
if err != nil {
return fmt.Errorf("unable to create a new template value from '%s'; %w", templateFilename, err)
}
@ -205,3 +209,11 @@ func copyAssets(environment, service string) error {
return nil
}
func defaultValue(value, defaultValue string) string {
if value == "" {
return defaultValue
}
return value
}

View file

@ -136,3 +136,7 @@ FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
; Input is not a standard input but a file
IS_INPUT_FILE = false
[actions]
ENABLED = {{ .Forgejo.Actions.Enabled }}
DEFAULT_ACTIONS_URL = {{ default .Forgejo.Actions.DefaultActionsURL "https://code.forgejo.org" }}