Add WNodeFactory.MakeConfigMap,MakeSecret

This commit is contained in:
jregan
2020-11-17 17:04:31 -08:00
parent f7613631d1
commit 486be07e22
5 changed files with 495 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ func (s k8sDataSetter) Filter(rn *RNode) (*RNode, error) {
// test in a mapping field called "data" as a string. Pairs with a 'v'
// failing this test go into a field called binaryData as a []byte.
// TODO: support this distinction in kyaml with NodeTagBytes?
return nil, fmt.Errorf(
return nil, errors.Errorf(
"key '%s' appears to have non-utf8 data; "+
"binaryData field not yet supported", s.Key)
}
@@ -73,8 +73,8 @@ func (s k8sDataSetter) Filter(rn *RNode) (*RNode, error) {
}
v := NewScalarRNode(s.Value)
v.YNode().Tag = NodeTagString
// Add quotes?
// v.YNode().Style = yaml.SingleQuotedStyle
// TODO: use schema to determine node style and tag.
// FormatNonStringStyle(v.YNode(), *k8sSch)
_, err = rn.Pipe(
LookupCreate(yaml.MappingNode, DataField), SetField(s.Key, v))
return rn, err

View File

@@ -39,8 +39,8 @@ data:
fruit: apple
veggie: celery
`
if output != expected {
t.Fatalf("expected \n%s\nbut got \n%s\n", expected, output)
if !assert.Equal(t, expected, output) {
t.FailNow()
}
}
@@ -79,8 +79,8 @@ metadata:
name: foo
namespace: bar
`
if output != expected {
t.Fatalf("expected \n%s\nbut got \n%s\n", expected, output)
if !assert.Equal(t, expected, output) {
t.FailNow()
}
}