in deployers/servicedeployer.go [492:536]
func (deployer *ServiceDeployer) RefreshManagedActions(packageName string, ma map[string]interface{}) error {
options := whisk.ActionListOptions{}
// get a list of actions in your namespace
actions, _, err := deployer.Client.Actions.List(packageName, &options)
if err != nil {
return err
}
// iterate over list of actions to find an action with managed annotations
// check if "managed" annotation is attached to an action
for _, action := range actions {
// an annotation with "managed" key indicates that an action was deployed as part of managed deployment
// if such annotation exists, check if it belongs to the current managed deployment
// this action has attached managed annotations
if a := action.Annotations.GetValue(utils.MANAGED); a != nil {
// decode the JSON blob and retrieve __OW_PROJECT_NAME and __OW_PROJECT_HASH
aa := a.(map[string]interface{})
// we have found an action which was earlier part of the current project
// and this action was deployed as part of managed deployment and now
// must be undeployed as its not part of the project anymore
// The annotation with same project name but different project hash indicates
// that this action is deleted from the project in manifest file
if aa[utils.OW_PROJECT_NAME] == ma[utils.OW_PROJECT_NAME] && aa[utils.OW_PROJECT_HASH] != ma[utils.OW_PROJECT_HASH] {
actionName := strings.Join([]string{packageName, action.Name}, "/")
output := wski18n.T(wski18n.ID_MSG_MANAGED_FOUND_DELETED_X_key_X_name_X_project_X,
map[string]interface{}{
wski18n.KEY_KEY: parsers.YAML_KEY_ACTION,
wski18n.KEY_NAME: actionName,
wski18n.KEY_PROJECT: aa[utils.OW_PROJECT_NAME]})
wskprint.PrintOpenWhiskWarning(output)
var err error
err = retry(DEFAULT_ATTEMPTS, DEFAULT_INTERVAL, func() error {
_, err := deployer.Client.Actions.Delete(actionName)
return err
})
if err != nil {
return err
}
}
}
}
return nil
}