func createLaunchConfigs(r *RancherService) (rancherClient.LaunchConfig, []rancherClient.SecondaryLaunchConfig, error) { secondaryLaunchConfigs := []rancherClient.SecondaryLaunchConfig{} launchConfig, err := createLaunchConfig(r, r.Name(), r.Config()) if err != nil { return launchConfig, nil, err } launchConfig.HealthCheck = r.HealthCheck("") if secondaries, ok := r.Context().SidekickInfo.primariesToSidekicks[r.Name()]; ok { for _, secondaryName := range secondaries { serviceConfig, ok := r.Context().Project.Configs[secondaryName] if !ok { return launchConfig, nil, fmt.Errorf("Failed to find sidekick: %s", secondaryName) } launchConfig, err := createLaunchConfig(r, secondaryName, serviceConfig) if err != nil { return launchConfig, nil, err } launchConfig.HealthCheck = r.HealthCheck(secondaryName) var secondaryLaunchConfig rancherClient.SecondaryLaunchConfig utils.Convert(launchConfig, &secondaryLaunchConfig) secondaryLaunchConfig.Name = secondaryName if secondaryLaunchConfig.Labels == nil { secondaryLaunchConfig.Labels = map[string]interface{}{} } secondaryLaunchConfigs = append(secondaryLaunchConfigs, secondaryLaunchConfig) } } return launchConfig, secondaryLaunchConfigs, nil }
func (r *RancherService) createNormalService() (*rancherClient.Service, error) { secondaryLaunchConfigs := []interface{}{} launchConfig, err := r.createLaunchConfig(r.serviceConfig) if err != nil { return nil, err } if secondaries, ok := r.context.SidekickInfo.primariesToSidekicks[r.name]; ok { for _, secondaryName := range secondaries { serviceConfig, ok := r.context.Project.Configs[secondaryName] if !ok { return nil, fmt.Errorf("Failed to find sidekick: %s", secondaryName) } launchConfig, err := r.createLaunchConfig(serviceConfig) if err != nil { return nil, err } var secondaryLaunchConfig rancherClient.SecondaryLaunchConfig utils.Convert(launchConfig, &secondaryLaunchConfig) secondaryLaunchConfig.Name = secondaryName secondaryLaunchConfigs = append(secondaryLaunchConfigs, secondaryLaunchConfig) } } return r.context.Client.Service.Create(&rancherClient.Service{ Name: r.name, Metadata: r.getMetadata(), LaunchConfig: launchConfig, SecondaryLaunchConfigs: secondaryLaunchConfigs, Scale: int64(r.getConfiguredScale()), EnvironmentId: r.context.Environment.Id, SelectorContainer: r.getSelectorContainer(), SelectorLink: r.getSelectorLink(), }) }