olehborysevych commented on code in PR #25080:
URL: https://github.com/apache/beam/pull/25080#discussion_r1081627036
##########
learning/tour-of-beam/backend/internal/fs_content/load.go:
##########
@@ -97,27 +115,57 @@ func collectUnit(infopath string, ctx *sdkContext) (unit
*tob.Unit, err error) {
return builder.Build(), err
}
+func processTemplate(source []byte, sdk tob.Sdk) ([]byte, error) {
+ t := template.New("")
+ t, err := t.Parse(string(source))
+ if err != nil {
+ return nil, err
+ }
+
+ var output bytes.Buffer
+ err = t.Execute(&output, struct{ Sdk tob.Sdk }{Sdk: sdk})
+ if err != nil {
+ return nil, err
+ }
+
+ return output.Bytes(), nil
+}
+
func collectGroup(infopath string, ctx *sdkContext) (*tob.Group, error) {
info := loadLearningGroupInfo(infopath)
+
+ supported, err := isSupportedSdk(info.Sdk, ctx, infopath)
+ if err != nil {
+ return nil, err
+ }
+ if !supported {
+ log.Printf("Group %v at %v not supported in %v\n", info.Id,
infopath, ctx.sdk)
+ return nil, nil
+ }
+
log.Printf("Found Group %v metadata at %v\n", info.Name, infopath)
group := tob.Group{Id: info.Id, Title: info.Name}
for _, item := range info.Content {
node, err := collectNode(filepath.Join(infopath, "..", item),
ctx)
if err != nil {
return &group, err
}
- group.Nodes = append(group.Nodes, node)
+ if node == nil {
+ continue
+ }
+ group.Nodes = append(group.Nodes, *node)
}
return &group, nil
}
// Collect node which is either a unit or a group.
-func collectNode(rootpath string, ctx *sdkContext) (node tob.Node, err error) {
+func collectNode(rootpath string, ctx *sdkContext) (*tob.Node, error) {
files, err := os.ReadDir(rootpath)
if err != nil {
- return node, err
+ return nil, err
}
+ node := &tob.Node{}
for _, f := range files {
Review Comment:
Thank you! Nice catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]