Skip to content

Commit

Permalink
runtime: Allow to accept runtime config as a flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtverstehen committed Jun 25, 2024
1 parent ee53cbf commit b7acded
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions framework/runtime/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@ package runtime

import (
"encoding/json"
"flag"
"fmt"
"os"

"namespacelabs.dev/foundation/schema/runtime"
)

var (
runtimeConfigJSON = flag.String("foundation_runtime_config_json", "", "runtime config to use instead of /namespace/config/runtime.json.")
)

type Server = runtime.Server

func LoadRuntimeConfig() (*runtime.RuntimeConfig, error) {
configBytes, err := os.ReadFile("/namespace/config/runtime.json")
if err != nil {
return nil, fmt.Errorf("failed to unwrap runtime configuration: %w", err)
var configBytes []byte

if *runtimeConfigJSON != "" {
configBytes = []byte(*runtimeConfigJSON)
} else {
bs, err := os.ReadFile("/namespace/config/runtime.json")
if err != nil {
return nil, fmt.Errorf("failed to unwrap runtime configuration: %w", err)
}
configBytes = bs
}

rt := &runtime.RuntimeConfig{}
Expand Down

0 comments on commit b7acded

Please sign in to comment.