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 @@
"ksonnet-gen/nodemaker",
"ksonnet-gen/printer"
]
revision = "b13dc1c505011ee838ae45324994dac432233000"
revision = "9f27c242ff65da0620f8324cc0cd50c8ef00bf5b"
[[projects]]
branch = "master"
......@@ -610,6 +610,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "e99bb34d06691779ec855657a6aa077e80428aee4db1141c5849a84420033170"
inputs-digest = "0b7cc9568e8af03ad2c4e3b5febdef644b40057c6c01aced232c101df726ca4e"
solver-name = "gps-cdcl"
solver-version = 1
......@@ -54,7 +54,7 @@
[[constraint]]
name = "github.com/ksonnet/ksonnet-lib"
revision = "b13dc1c505011ee838ae45324994dac432233000"
revision = "9f27c242ff65da0620f8324cc0cd50c8ef00bf5b"
[[constraint]]
name = "github.com/mattn/go-isatty"
......
......@@ -152,7 +152,7 @@ func (c *Catalog) Fields() ([]Field, error) {
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.
if _, ok := c.paths[name]; ok {
continue
......
......@@ -275,7 +275,7 @@ func setArray(varName string) *nm.Conditional {
}
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)
return nm.NewBinary(
......
......@@ -74,7 +74,7 @@ func isSkippedProperty(name string, schema spec.Schema) bool {
return true
}
if strings.Contains(strings.ToLower(schema.Description), "read-only") {
if strings.Contains(strings.ToLower(schema.Description), "read-only") && name != "readOnly" {
return true
}
......
......@@ -87,6 +87,13 @@ func KVFromMap(m map[string]interface{}) (*Object, error) {
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)
default:
return nil, errors.Errorf("unsupported type %T", t)
......@@ -179,6 +186,10 @@ func (o *Object) Keys() []Key {
return keys
}
var (
reField = regexp.MustCompile(`^[A-Za-z]+[A-Za-z0-9]*$`)
)
// Node converts the object to a jsonnet node.
func (o *Object) Node() ast.Node {
ao := &astext.Object{
......@@ -193,12 +204,21 @@ func (o *Object) Node() ast.Node {
Comment: o.generateComment(k.comment),
}
if k.category == ast.ObjectFieldStr {
of.Expr1 = NewStringDouble(k.name).Node()
if k.category == ast.ObjectLocal {
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 {
of.Id = newIdentifier(k.name)
of.Expr1 = NewStringDouble(name).Node()
of.Kind = ast.ObjectFieldStr
}
of.Kind = k.category
of.Hide = k.visibility
of.Expr2 = v.Node()
of.Method = k.Method()
......@@ -939,3 +959,13 @@ func newIdentifier(value string) *ast.Identifier {
id := ast.Identifier(value)
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