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

@ -48,32 +48,38 @@ type traefikConfig struct {
}
type forgejoConfig struct {
Version string `json:"version"`
Name string `json:"name"`
Subdomain string `json:"subdomain"`
ContainerName string `json:"containerName"`
ContainerIpv4Address string `json:"containerIpv4Address"`
SshPort int32 `json:"sshPort"`
HttpPort int32 `json:"httpPort"`
RunMode string `json:"runMode"`
LogLevel string `json:"logLevel"`
LinuxUID int32 `json:"linuxUID"`
DataHostDirectory string `json:"dataHostDirectory"`
DataContainerDirectory string `json:"dataContainerDirectory"`
Home string `json:"home"`
Work string `json:"work"`
Custom string `json:"custom"`
AppIni string `json:"appIni"`
Bin string `json:"bin"`
Tmp string `json:"tmp"`
SecretHostDirectory string `json:"secretHostDirectory"`
SecretContainerDirectory string `json:"secretContainerDirectory"`
SecretKey string `json:"secretKey"`
InternalToken string `json:"internalToken"`
LfsJwtSecret string `json:"lfsJwtSecret"`
Oauth2Enable bool `json:"oauth2Enable"`
Oauth2JwtSigningAlgo string `json:"oauth2JwtSigningAlgo"`
Oauth2JwtSecret string `json:"oauth2JwtSecret"`
Version string `json:"version"`
Name string `json:"name"`
Subdomain string `json:"subdomain"`
ContainerName string `json:"containerName"`
ContainerIpv4Address string `json:"containerIpv4Address"`
SshPort int32 `json:"sshPort"`
HttpPort int32 `json:"httpPort"`
RunMode string `json:"runMode"`
LogLevel string `json:"logLevel"`
LinuxUID int32 `json:"linuxUID"`
DataHostDirectory string `json:"dataHostDirectory"`
DataContainerDirectory string `json:"dataContainerDirectory"`
Home string `json:"home"`
Work string `json:"work"`
Custom string `json:"custom"`
AppIni string `json:"appIni"`
Bin string `json:"bin"`
Tmp string `json:"tmp"`
SecretHostDirectory string `json:"secretHostDirectory"`
SecretContainerDirectory string `json:"secretContainerDirectory"`
SecretKey string `json:"secretKey"`
InternalToken string `json:"internalToken"`
LfsJwtSecret string `json:"lfsJwtSecret"`
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" }}