Skip to content

Commit

Permalink
use hasura.ReadCustomConfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
852Kerfunkle committed Apr 25, 2022
1 parent 8f5b383 commit d91838b
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions cmd/metadata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func main() {
return
}

custom_configs, err := readCustomHasuraConfigs(ctx, cfg.Database)
custom_configs, err := hasura.ReadCustomConfigs(ctx, cfg.Database, "custom_hasura_config")
if err != nil {
log.Err(err).Msg("readCustomHasuraConfigs")
return
Expand Down Expand Up @@ -115,7 +115,7 @@ func main() {
return
}

custom_configs, err := readCustomHasuraConfigs(ctx, cfg.Database)
custom_configs, err := hasura.ReadCustomConfigs(ctx, cfg.Database, "custom_hasura_config")
if err != nil {
log.Err(err).Msg("readCustomHasuraConfigs")
return
Expand Down Expand Up @@ -224,33 +224,3 @@ func createViews(ctx context.Context, database golibConfig.Database) ([]string,

return views, nil
}

func readCustomHasuraConfigs(ctx context.Context, database golibConfig.Database) ([]hasura.Request, error) {
files, err := ioutil.ReadDir("custom_hasura_config")
if err != nil {
return nil, err
}

custom_configs := make([]hasura.Request, 0)
for i := range files {
if files[i].IsDir() || strings.HasPrefix(files[i].Name(), ".") {
continue
}

path := fmt.Sprintf("custom_hasura_config/%s", files[i].Name())
raw, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}

conf := hasura.Request{}

err = json.Unmarshal([]byte(raw), &conf)
if err != nil {
return nil, err
}
custom_configs = append(custom_configs, conf)
}

return custom_configs, nil
}

0 comments on commit d91838b

Please sign in to comment.