in parsers/manifest_parser.go [865:982]
func (dm *YAMLParser) ComposeActions(manifestFilePath string, actions map[string]Action, packageName string, managedAnnotations whisk.KeyValue, packageInputs PackageInputs) ([]utils.ActionRecord, error) {
var errorParser error
var listOfActions []utils.ActionRecord = make([]utils.ActionRecord, 0)
splitManifestFilePath := strings.Split(manifestFilePath, string(PATH_SEPARATOR))
manifestFileName := splitManifestFilePath[len(splitManifestFilePath)-1]
for actionName, action := range actions {
var actionFilePath string
// update the action (of type Action) to set its name
// here key name is the action name
action.Name = actionName
// Create action data object from client library
wskaction := new(whisk.Action)
//set action.Function to action.Location
//because Location is deprecated in Action entity
if len(action.Function) == 0 && len(action.Location) != 0 {
action.Function = action.Location
}
actionFilePath, wskaction.Exec, errorParser = dm.composeActionExec(manifestFilePath, manifestFileName, action)
if errorParser != nil {
return nil, errorParser
}
// Action.Inputs
listOfInputs, err := dm.composeInputs(action.Inputs, packageInputs, manifestFilePath)
if err != nil {
return nil, err
}
if len(listOfInputs) > 0 {
wskaction.Parameters = listOfInputs
}
// Action.Outputs
// TODO{} add outputs as annotations (work to discuss officially supporting for compositions)
//listOfOutputs, err := dm.composeOutputs(action.Outputs, manifestFilePath)
//if err != nil {
// return nil, err
//}
//if len(listOfOutputs) > 0 {
// wskaction.Annotations = listOfOutputs
//}
// Action.Annotations
// ==================
// WARNING! Processing of explicit Annotations MUST occur before handling of Action keys, as these
// keys often need to check for inconsistencies (and raise errors).
if listOfAnnotations := dm.composeAnnotations(action.Annotations); len(listOfAnnotations) > 0 {
wskaction.Annotations = append(wskaction.Annotations, listOfAnnotations...)
}
// add managed annotations if its marked as managed deployment
if utils.Flags.Managed || utils.Flags.Sync {
wskaction.Annotations = append(wskaction.Annotations, managedAnnotations)
}
// Web Export (i.e., "web-export" annotation)
// ==========
// Treat ACTION as a web action, a raw HTTP web action, or as a standard action based on web-export;
// when web-export is set to yes | true, treat action as a web action,
// when web-export is set to raw, treat action as a raw HTTP web action,
// when web-export is set to no | false, treat action as a standard action
dm.warnIfRedundantWebActionFlags(action)
if len(action.GetWeb()) != 0 {
wskaction.Annotations, errorParser = webaction.SetWebActionAnnotations(
manifestFilePath,
action.Name,
action.GetWeb(),
wskaction.Annotations,
false)
if errorParser != nil {
return listOfActions, errorParser
}
}
// validate special action annotations such as "require-whisk-auth"
// TODO: the Manifest parser will validate any declared APIs that ref. this action
if wskaction.Annotations != nil {
if webaction.HasAnnotation(&wskaction.Annotations, webaction.REQUIRE_WHISK_AUTH) {
_, errorParser = webaction.ValidateRequireWhiskAuthAnnotationValue(
actionName,
wskaction.Annotations.GetValue(webaction.REQUIRE_WHISK_AUTH))
}
if errorParser != nil {
return listOfActions, errorParser
}
}
// Action.Limits
if action.Limits != nil {
if wsklimits := dm.composeActionLimits(*(action.Limits)); wsklimits != nil {
wskaction.Limits = wsklimits
}
}
// Conductor Action
if action.Conductor {
wskaction.Annotations = append(wskaction.Annotations, conductor.ConductorAction())
}
// Set other top-level values for the action (e.g., name, version, publish, etc.)
wskaction.Name = actionName
pub := false
wskaction.Publish = &pub
wskaction.Version = wskenv.ConvertSingleName(action.Version)
// create a "record" of the Action relative to its package and function filepath
// which will be used to compose the REST API calls
record := utils.ActionRecord{Action: wskaction, Packagename: packageName, Filepath: actionFilePath}
listOfActions = append(listOfActions, record)
}
return listOfActions, nil
}