fix(apps): init apps in config

This commit is contained in:
fiftin 2024-07-10 17:35:21 +05:00
parent 08a09492ee
commit 37230c2f2b
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
3 changed files with 14 additions and 16 deletions

View File

@ -80,19 +80,6 @@ func appMiddleware(next http.Handler) http.Handler {
}
func getApps(w http.ResponseWriter, r *http.Request) {
defaultApps := map[string]util.App{
string(db.TemplateAnsible): {},
string(db.TemplateTerraform): {},
string(db.TemplateTofu): {},
string(db.TemplateBash): {},
string(db.TemplatePowerShell): {},
string(db.TemplatePython): {},
}
for k, a := range util.Config.Apps {
defaultApps[k] = a
}
type app struct {
ID string `json:"id"`
Title string `json:"title"`
@ -104,7 +91,7 @@ func getApps(w http.ResponseWriter, r *http.Request) {
apps := make([]app, 0)
for k, a := range defaultApps {
for k, a := range util.Config.Apps {
apps = append(apps, app{
ID: k,

View File

@ -114,7 +114,7 @@ func createStore(token string) db.Store {
panic(err)
}
util.CheckDefaultApps()
util.LookupDefaultApps()
return store
}

View File

@ -250,6 +250,17 @@ func LoadRunnerSettings(path string) (config RunnerConfig, err error) {
// ConfigInit reads in cli flags, and switches actions appropriately on them
func ConfigInit(configPath string) {
fmt.Println("Loading config")
Config = &ConfigType{}
Config.Apps = map[string]App{
"ansible": {},
"terraform": {},
"tofu": {},
"bash": {},
"powershell": {},
"python": {},
}
loadConfigFile(configPath)
loadConfigEnvironment()
loadConfigDefaults()
@ -800,7 +811,7 @@ func (conf *ConfigType) GenerateSecrets() {
conf.AccessKeyEncryption = base64.StdEncoding.EncodeToString(accessKeyEncryption)
}
func CheckDefaultApps() {
func LookupDefaultApps() {
appCommands := map[string]string{
"": "ansible-playbook",
"terraform": "terraform",