Unverified Commit e3806408 authored by Bryan Liles's avatar Bryan Liles Committed by GitHub
Browse files

Merge pull request #350 from bryanl/bug-extension-map-container

bug: mapContainer extension typo
parents 2b4acaf2 c6aa7d28
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
"ksonnet-gen/nodemaker", "ksonnet-gen/nodemaker",
"ksonnet-gen/printer" "ksonnet-gen/printer"
] ]
revision = "b13dc1c505011ee838ae45324994dac432233000" revision = "9f27c242ff65da0620f8324cc0cd50c8ef00bf5b"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -610,6 +610,6 @@ ...@@ -610,6 +610,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "e99bb34d06691779ec855657a6aa077e80428aee4db1141c5849a84420033170" inputs-digest = "0b7cc9568e8af03ad2c4e3b5febdef644b40057c6c01aced232c101df726ca4e"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
[[constraint]] [[constraint]]
name = "github.com/ksonnet/ksonnet-lib" name = "github.com/ksonnet/ksonnet-lib"
revision = "b13dc1c505011ee838ae45324994dac432233000" revision = "9f27c242ff65da0620f8324cc0cd50c8ef00bf5b"
[[constraint]] [[constraint]]
name = "github.com/mattn/go-isatty" name = "github.com/mattn/go-isatty"
......
...@@ -152,7 +152,7 @@ func (c *Catalog) Fields() ([]Field, error) { ...@@ -152,7 +152,7 @@ func (c *Catalog) Fields() ([]Field, error) {
return nil, errors.Wrapf(err, "parse description for %s", name) return nil, errors.Wrapf(err, "parse description for %s", name)
} }
// If there is a path, this should ot be a hidden object. This // If there is a path, this should not be a hidden object. This
// makes this schema a field. // makes this schema a field.
if _, ok := c.paths[name]; ok { if _, ok := c.paths[name]; ok {
continue continue
......
...@@ -275,7 +275,7 @@ func setArray(varName string) *nm.Conditional { ...@@ -275,7 +275,7 @@ func setArray(varName string) *nm.Conditional {
} }
func genIsIntersection(a, b nm.Noder) *nm.Binary { func genIsIntersection(a, b nm.Noder) *nm.Binary {
intersection := nm.ApplyCall("std.Inter", a, b) intersection := nm.ApplyCall("std.setInter", a, b)
checkLen := nm.ApplyCall("std.length", intersection) checkLen := nm.ApplyCall("std.length", intersection)
return nm.NewBinary( return nm.NewBinary(
......
...@@ -74,7 +74,7 @@ func isSkippedProperty(name string, schema spec.Schema) bool { ...@@ -74,7 +74,7 @@ func isSkippedProperty(name string, schema spec.Schema) bool {
return true return true
} }
if strings.Contains(strings.ToLower(schema.Description), "read-only") { if strings.Contains(strings.ToLower(schema.Description), "read-only") && name != "readOnly" {
return true return true
} }
......
...@@ -87,6 +87,13 @@ func KVFromMap(m map[string]interface{}) (*Object, error) { ...@@ -87,6 +87,13 @@ func KVFromMap(m map[string]interface{}) (*Object, error) {
return nil, err return nil, err
} }
o.Set(InheritedKey(name), child)
case map[string]interface{}:
child, err := KVFromMap(t)
if err != nil {
return nil, err
}
o.Set(InheritedKey(name), child) o.Set(InheritedKey(name), child)
default: default:
return nil, errors.Errorf("unsupported type %T", t) return nil, errors.Errorf("unsupported type %T", t)
...@@ -179,6 +186,10 @@ func (o *Object) Keys() []Key { ...@@ -179,6 +186,10 @@ func (o *Object) Keys() []Key {
return keys return keys
} }
var (
reField = regexp.MustCompile(`^[A-Za-z]+[A-Za-z0-9]*$`)
)
// Node converts the object to a jsonnet node. // Node converts the object to a jsonnet node.
func (o *Object) Node() ast.Node { func (o *Object) Node() ast.Node {
ao := &astext.Object{ ao := &astext.Object{
...@@ -193,12 +204,21 @@ func (o *Object) Node() ast.Node { ...@@ -193,12 +204,21 @@ func (o *Object) Node() ast.Node {
Comment: o.generateComment(k.comment), Comment: o.generateComment(k.comment),
} }
if k.category == ast.ObjectFieldStr { if k.category == ast.ObjectLocal {
of.Expr1 = NewStringDouble(k.name).Node() of.Id = newIdentifier(name)
of.Kind = k.category
} else if stringInSlice(name, jsonnetReservedWords) {
of.Expr1 = NewStringDouble(name).Node()
of.Kind = ast.ObjectFieldStr
} else if reField.MatchString(name) {
id := ast.Identifier(name)
of.Kind = ast.ObjectFieldID
of.Id = &id
} else { } else {
of.Id = newIdentifier(k.name) of.Expr1 = NewStringDouble(name).Node()
of.Kind = ast.ObjectFieldStr
} }
of.Kind = k.category
of.Hide = k.visibility of.Hide = k.visibility
of.Expr2 = v.Node() of.Expr2 = v.Node()
of.Method = k.Method() of.Method = k.Method()
...@@ -939,3 +959,13 @@ func newIdentifier(value string) *ast.Identifier { ...@@ -939,3 +959,13 @@ func newIdentifier(value string) *ast.Identifier {
id := ast.Identifier(value) id := ast.Identifier(value)
return &id return &id
} }
func stringInSlice(s string, sl []string) bool {
for i := range sl {
if sl[i] == s {
return true
}
}
return false
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment