Skip to content

Commit

Permalink
fix(apps): init apps in config
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Jul 10, 2024
1 parent 08a0949 commit 37230c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
15 changes: 1 addition & 14 deletions api/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func createStore(token string) db.Store {
panic(err)
}

util.CheckDefaultApps()
util.LookupDefaultApps()

return store
}
13 changes: 12 additions & 1 deletion util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 37230c2

Please sign in to comment.