本文整理匯總了Golang中github.com/docker/libcompose/config.ServiceConfigs.Len方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceConfigs.Len方法的具體用法?Golang ServiceConfigs.Len怎麽用?Golang ServiceConfigs.Len使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/libcompose/config.ServiceConfigs
的用法示例。
在下文中一共展示了ServiceConfigs.Len方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ConvertToTaskDefinition
// ConvertToTaskDefinition transforms the yaml configs to its ecs equivalent (task definition)
func ConvertToTaskDefinition(taskDefinitionName string, context *project.Context,
serviceConfigs *config.ServiceConfigs) (*ecs.TaskDefinition, error) {
if serviceConfigs.Len() == 0 {
return nil, errors.New("cannot create a task definition with no containers; invalid service config")
}
logUnsupportedConfigFields(context.Project)
containerDefinitions := []*ecs.ContainerDefinition{}
volumes := make(map[string]string) // map with key:=hostSourcePath value:=VolumeName
for _, name := range serviceConfigs.Keys() {
serviceConfig, ok := serviceConfigs.Get(name)
if !ok {
return nil, fmt.Errorf("Couldn't get service with name=[%s]", name)
}
logUnsupportedServiceConfigFields(name, serviceConfig)
containerDef := &ecs.ContainerDefinition{
Name: aws.String(name),
}
if err := convertToContainerDef(context, serviceConfig, volumes, containerDef); err != nil {
return nil, err
}
containerDefinitions = append(containerDefinitions, containerDef)
}
taskDefinition := &ecs.TaskDefinition{
Family: aws.String(taskDefinitionName),
ContainerDefinitions: containerDefinitions,
Volumes: convertToECSVolumes(volumes),
}
return taskDefinition, nil
}