Skip to content

Commit

Permalink
runtime: Allow config values that are not in the schema (#126)
Browse files Browse the repository at this point in the history
If an app has schema, print a warning if we're passing config values
that are _not_ in the schema.
  • Loading branch information
rohansingh authored Jan 17, 2022
1 parent 61d5238 commit a555891
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/md5"
"encoding/json"
"fmt"
"log"
"strconv"
"strings"

Expand Down Expand Up @@ -146,8 +147,8 @@ func (a *Applet) Run(config map[string]string, initializers ...ThreadInitializer

if field == nil {
// we have a value, but it's not part of the app's schema.
// drop it entirely.
continue
// allow it for now, but we will deprecate it in the future.
log.Printf("received config value for '%s', but it is not in the schema for %s", k, a.Filename)
} else if field.Type == "onoff" {
b, _ := strconv.ParseBool(v)
starlarkVal = starlark.Bool(b)
Expand Down
3 changes: 2 additions & 1 deletion runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ def main(config):
actual_not_in_schema = config.get("not_in_schema")
if actual_not_in_schema != expected_not_in_schema:
fail("not_in_schema - expected", expected_not_in_schema, "got", actual_not_in_schema)
pass # this is actually allowed for now
# fail("not_in_schema - expected", expected_not_in_schema, "got", actual_not_in_schema)
return []
Expand Down

0 comments on commit a555891

Please sign in to comment.