// GetDaemonSetServices returns list of services that are related to daemon set targeted by given // name. func GetDaemonSetServices(client client.Interface, dsQuery *dataselect.DataSelectQuery, namespace, name string) (*service.ServiceList, error) { daemonSet, err := client.Extensions().DaemonSets(namespace).Get(name) if err != nil { return nil, err } channels := &common.ResourceChannels{ ServiceList: common.GetServiceListChannel(client, common.NewSameNamespaceQuery(namespace), 1), } services := <-channels.ServiceList.List if err := <-channels.ServiceList.Error; err != nil { return nil, err } matchingServices := common.FilterNamespacedServicesBySelector(services.Items, namespace, daemonSet.Spec.Selector.MatchLabels) return service.CreateServiceList(matchingServices, dsQuery), nil }
// GetReplicationControllerServices returns list of services that are related to replication // controller targeted by given name. func GetReplicationControllerServices(client client.Interface, dsQuery *dataselect.DataSelectQuery, namespace, rcName string) (*service.ServiceList, error) { replicationController, err := client.ReplicationControllers(namespace).Get(rcName) if err != nil { return nil, err } channels := &common.ResourceChannels{ ServiceList: common.GetServiceListChannel(client, common.NewSameNamespaceQuery(namespace), 1), } services := <-channels.ServiceList.List if err := <-channels.ServiceList.Error; err != nil { return nil, err } matchingServices := common.FilterNamespacedServicesBySelector(services.Items, namespace, replicationController.Spec.Selector) return service.CreateServiceList(matchingServices, dsQuery), nil }