in cmd/export.go [51:118]
func ExportAction(actionName string, packageName string, maniyaml *parsers.YAML, targetManifest string, projectName string) error {
pkg := maniyaml.Packages[packageName]
if pkg.Actions == nil {
pkg.Actions = make(map[string]parsers.Action)
maniyaml.Packages[packageName] = pkg
}
wskAction, _, err := client.Actions.Get(actionName, true)
if err != nil {
return err
}
if a := wskAction.Annotations.GetValue(utils.MANAGED); a != nil {
// decode the JSON blob and retrieve __OW_PROJECT_NAME
pa := a.(map[string]interface{})
// we have found a package which is part of the current project
if pa[utils.OW_PROJECT_NAME] != projectName {
return nil
}
} else {
return nil
}
if wskAction.Exec.Kind == "sequence" {
seq := new(parsers.Sequence)
for _, component := range wskAction.Exec.Components {
// must ommit namespace from seq component name
ExportAction(strings.SplitN(component, "/", 3)[2], packageName, maniyaml, targetManifest, projectName)
if len(seq.Actions) > 0 {
seq.Actions += ","
}
// save action in the seq list as package/action
seq.Actions += strings.SplitN(component, "/", 3)[2]
}
pkg = maniyaml.Packages[packageName]
if pkg.Sequences == nil {
pkg.Sequences = make(map[string]parsers.Sequence)
}
pkg.Sequences[wskAction.Name] = *seq
} else {
parsedAction := *maniyaml.ComposeParsersAction(*wskAction)
manifestDir := filepath.Dir(targetManifest)
// store function file under action package name subdirectory in the specified manifest folder
functionDir := filepath.Join(manifestDir, packageName)
// save the code in file
filename, err := saveCode(*wskAction, functionDir)
if err != nil {
return err
}
if filename != "" {
// store function in manifest if action has code section
parsedAction.Function = packageName + "/" + filename
}
pkg.Actions[wskAction.Name] = parsedAction
}
maniyaml.Packages[packageName] = pkg
return nil
}