in deployers/servicedeployer.go [684:732]
func (deployer *ServiceDeployer) RefreshManagedPackagesWithDependencies(ma map[string]interface{}) error {
// iterate over each package from the given project
for _, p := range deployer.Deployment.Packages {
dependencyAnnotations := make(whisk.KeyValueArr, 0)
// iterate over the list of dependencies of the package
// dependencies could be labeled same as dependent package name
// for example, "helloworld" where the package it depends on is also called "helloworld"
// dependencies could be labeled different from the dependent package name
// for example, "custom-helloworld" where the package it depends on it called "helloworld"
for label, n := range p.Dependencies {
// we do not append dependencies in whisk-managed in case of a package binding
// for example when a package has dependencies on /whisk.system/ or any other /<namespace>/
// the dependent packages are pre-installed and should not be managed by current project
if !n.IsBinding {
// find the package using dependency label
pkg, _, err := deployer.Client.Packages.Get(label)
if err != nil {
return err
}
// if dependency label (custom-helloworld) is different from the dependent package name,
// it must have binding set to the original package ("helloworld")
if len(pkg.Binding.Name) != 0 {
// having dependency on packages under /whisk.system is treated in a different way
// in which dependent package under /whisk.system are not modified to add managed annotation
// and parent package does not show this dependency in its managed annotation
// because whisk.system packages comes pre-packaged and deployed with OpenWhisk server and not
// deployed along with application deployments.
// get the original package to retrieve its managed annotations
pkg, _, err := deployer.Client.Packages.Get(pkg.Binding.Name)
if err != nil {
return err
}
dependencyAnnotations = deployer.appendDepAnnotation(dependencyAnnotations, pkg)
} else {
dependencyAnnotations = deployer.appendDepAnnotation(dependencyAnnotations, pkg)
}
}
}
updatedAnnotation, err := utils.AddDependentAnnotation(ma, dependencyAnnotations)
if err != nil {
return err
}
p.Package.Annotations.AddOrReplace(&updatedAnnotation)
}
if err := deployer.DeployPackages(); err != nil {
return err
}
return nil
}