fix(forgejo): add support for enabling actions
This commit is contained in:
parent
dd339eb3d6
commit
18412e62cb
3 changed files with 49 additions and 27 deletions
|
@ -74,6 +74,12 @@ type forgejoConfig struct {
|
||||||
Oauth2Enable bool `json:"oauth2Enable"`
|
Oauth2Enable bool `json:"oauth2Enable"`
|
||||||
Oauth2JwtSigningAlgo string `json:"oauth2JwtSigningAlgo"`
|
Oauth2JwtSigningAlgo string `json:"oauth2JwtSigningAlgo"`
|
||||||
Oauth2JwtSecret string `json:"oauth2JwtSecret"`
|
Oauth2JwtSecret string `json:"oauth2JwtSecret"`
|
||||||
|
Actions forgejoActionsConfig `json:"actions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type forgejoActionsConfig struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
DefaultActionsURL string `json:"defaultActionsURL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type gotosocialConfig struct {
|
type gotosocialConfig struct {
|
||||||
|
|
|
@ -110,6 +110,10 @@ func render(cfg config, environment, component string) error {
|
||||||
return fmt.Errorf("unable to read files from %s; %w ", templateDirName, err)
|
return fmt.Errorf("unable to read files from %s; %w ", templateDirName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funcMap := template.FuncMap{
|
||||||
|
"default": defaultValue,
|
||||||
|
}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
err := func() error {
|
err := func() error {
|
||||||
templateFilename := f.Name()
|
templateFilename := f.Name()
|
||||||
|
@ -128,7 +132,7 @@ func render(cfg config, environment, component string) error {
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
templatePath := filepath.Join(templateDirName, templateFilename)
|
templatePath := filepath.Join(templateDirName, templateFilename)
|
||||||
tmpl, err := template.New(templateFilename).ParseFiles(templatePath)
|
tmpl, err := template.New(templateFilename).Funcs(funcMap).ParseFiles(templatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to create a new template value from '%s'; %w", templateFilename, err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultValue(value, defaultValue string) string {
|
||||||
|
if value == "" {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
|
@ -136,3 +136,7 @@ FILE_EXTENSIONS = .adoc,.asciidoc
|
||||||
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
|
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
|
||||||
; Input is not a standard input but a file
|
; Input is not a standard input but a file
|
||||||
IS_INPUT_FILE = false
|
IS_INPUT_FILE = false
|
||||||
|
|
||||||
|
[actions]
|
||||||
|
ENABLED = {{ .Forgejo.Actions.Enabled }}
|
||||||
|
DEFAULT_ACTIONS_URL = {{ default .Forgejo.Actions.DefaultActionsURL "https://code.forgejo.org" }}
|
||||||
|
|
Loading…
Reference in a new issue