feat: lookup default apps

This commit is contained in:
Denis Gukov 2024-07-08 00:51:50 +05:00
parent 3ce78b11fd
commit a6133354c1
2 changed files with 27 additions and 0 deletions

View File

@ -110,6 +110,8 @@ func createStore(token string) db.Store {
err = db.FillConfigFromDB(store) err = db.FillConfigFromDB(store)
util.CheckDefaultApps()
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -786,3 +786,28 @@ func (conf *ConfigType) GenerateSecrets() {
conf.CookieEncryption = base64.StdEncoding.EncodeToString(encryption) conf.CookieEncryption = base64.StdEncoding.EncodeToString(encryption)
conf.AccessKeyEncryption = base64.StdEncoding.EncodeToString(accessKeyEncryption) conf.AccessKeyEncryption = base64.StdEncoding.EncodeToString(accessKeyEncryption)
} }
func CheckDefaultApps() {
appCommands := map[string]string{
"": "ansible-playbook",
"terraform": "terraform",
"tofu": "tofu",
"bash": "bash",
}
for app, cmd := range appCommands {
if _, ok := Config.Apps[app]; ok {
continue
}
_, err := exec.LookPath(cmd)
if err != nil {
continue
}
Config.Apps[app] = AppConfig{
Active: true,
}
}
}