Skip to content

Commit

Permalink
Implement "bytes" primitive type
Browse files Browse the repository at this point in the history
  • Loading branch information
tliron committed Dec 10, 2020
1 parent 5923489 commit d01bfbe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 17 additions & 0 deletions examples/tosca/future/tosca_2_0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@ metadata:

template_name: TOSCA 2.0 Example
template_author: Puccini

node_types:

DataNode:
properties:
bytes:
# Base64-encoded data
type: bytes

topology_template:

node_templates:

data:
type: DataNode
properties:
bytes: UHVjY2luaQ==
17 changes: 15 additions & 2 deletions tosca/grammars/tosca_v2_0/bytes.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
package tosca_v2_0

import (
"github.com/tliron/kutil/util"
"github.com/tliron/puccini/tosca"
)

//
// Bytes
//

// tosca.Reader signature
func ReadBytes(context *tosca.Context) tosca.EntityPtr {
// TODO
return nil
var bytes []byte

if b64 := context.ReadString(); b64 != nil {
var err error
if bytes, err = util.FromBase64(*b64); err != nil {
context.ReportValueMalformed("bytes", "invalid base64")
}
}

return bytes
}

0 comments on commit d01bfbe

Please sign in to comment.