// NewStaticAWSService uses the static credential provider (pass in access key ID and secret key)
169211
func NewStaticAWSService(id string, secret string) AWSService {
	s := session.New(&aws.Config{Credentials: credentials.NewStaticCredentials(id, secret, ""), Region: &awsRegion})

	return &RealAWSService{
		elbc: elb.New(s),
		r53c: route53.New(s),
		ec2:  ec2.New(s),
	}
}
374308
func NewService(config ServiceConfig) (*Service, error) {
	// Dependencies.
	if config.K8sClient == nil {
		return nil, microerror.Maskf(invalidConfigError, "config.K8sClient must not be empty")
	}
	if config.Logger == nil {
		return nil, microerror.Maskf(invalidConfigError, "config.Logger must not be empty")
	}

	newService := &Service{
		// Dependencies.
		k8sClient: config.K8sClient,
		logger:    config.Logger,
	}

	return newService, nil
}
307132
func newStatsProvider(
	cadvisor cadvisor.Interface,
	podManager kubepod.Manager,
	runtimeCache kubecontainer.RuntimeCache,
	containerStatsProvider containerStatsProvider,
) *StatsProvider {
	return &StatsProvider{
		cadvisor:               cadvisor,
		podManager:             podManager,
		runtimeCache:           runtimeCache,
		containerStatsProvider: containerStatsProvider,
	}
}
1328778
func NewService(r cargo.HandlingEventRepository, f cargo.HandlingEventFactory, h EventHandler) Service {
	return &service{
		handlingEventRepository: r,
		handlingEventFactory:    f,
		handlingEventHandler:    h,
	}
}
813691
func NewServiceAccountFromKey(jsonKey []byte, scope ...string) (credentials.PerRPCCredentials, error) {
	config, err := google.JWTConfigFromJSON(jsonKey, scope...)
	if err != nil {
		return nil, err
	}
	return &serviceAccount{config: config}, nil
}
633228
func NewService(th Thumbnailer, timeout time.Duration, maxProcs int) *Service {

	var g *syncutil.Gate
	if maxProcs > 0 {
		g = syncutil.NewGate(maxProcs)
	}

	return &Service{
		thumbnailer: th,
		timeout:     timeout,
		gate:        g,
	}
}
795607
func NewStaticCredentials(projectID, privateKeyID, privateKey, clientEmail, clientID string) *Credentials {
	_, err := url.ParseQuery(clientEmail)
	if err != nil {
		return nil
	}
	return NewCredentials(&StaticProvider{Value: Value{
		Type:                    "service_account",
		ProjectID:               projectID,
		PrivateKeyID:            privateKeyID,
		PrivateKey:              privateKey,
		ClientEmail:             clientEmail,
		ClientID:                clientID,
		AuthURI:                 "https://accounts.google.com/o/oauth2/auth",
		TokenURI:                "https://accounts.google.com/o/oauth2/token",
		AuthProviderX509CertURL: "https://www.googleapis.com/oauth2/v1/certs",
		ClientX509CertURL:       fmt.Sprintf("https://www.googleapis.com/robot/v1/metadata/x509/%s", url.QueryEscape(clientEmail)),
	}})

}
1175959
func NewService(
	name string, conf common.Conf, dataDir string, newDBus DBusAPIFactory, fallBackDirName string,
) (*Service, error) {
	confName := name + ".service"
	var volName string
	if conf.ExecStart != "" {
		volName = renderer.VolumeName(common.Unquote(strings.Fields(conf.ExecStart)[0]))
	}
	dirName := volName + renderer.Join(dataDir, name)

	service := &Service{
		Service: common.Service{
			Name: name,
			// Conf is set in setConf.
		},
		ConfName:        confName,
		UnitName:        confName,
		DirName:         dirName,
		FallBackDirName: fallBackDirName,
		newDBus:         newDBus,
	}

	if err := service.setConf(conf); err != nil {
		return nil, errors.Trace(err)
	}

	return service, nil
}
9542
func NewService(events *exchange.Exchange) api.EventsServer {
	return &service{
		ttService: &ttrpcService{
			events: events,
		},
		events: events,
	}
}
963416
func NewServiceCache() ServiceCache {
	return ServiceCache{
		services:          map[ServiceID]*Service{},
		endpoints:         map[ServiceID]*Endpoints{},
		ingresses:         map[ServiceID]*Service{},
		externalEndpoints: map[ServiceID]externalEndpoints{},
		Events:            make(chan ServiceEvent, 128),
	}
}
739898
func (s *Application) NewStatic(urlPath string, absPath string, f ...map[string]interface{}) *resource.Static {
	st := resource.NewStatic(urlPath, absPath)
	if len(f) > 0 {
		f[0] = st.Register(f[0])
	}
	return st
}
171211
func NewServiceWithDefaults(name string, conf common.Conf) (*Service, error) {
	svc, err := NewService(name, conf, LibSystemdDir, NewDBusAPI, renderer.Join(paths.NixDataDir, "init"))
	return svc, errors.Trace(err)
}
1031119
func (n *Narcissus) NewServices() (s *Services, err error) {
	s = &Services{}
	err = n.Parse(s)
	return
}
980559
func NewSearchService(client *Client) *SearchService {
	builder := &SearchService{
		client:       client,
		searchSource: NewSearchSource(),
	}
	return builder
}
270165
func NewService(queueSize ...int) *Service {
	var qs = 100
	if len(queueSize) > 0 {
		qs = queueSize[0]
	}

	return &Service{
		state:                       serviceStopped,
		Session:                     session.NewMemorySession(),
		MinReconnectDelay:           50 * time.Millisecond,
		MaxReconnectDelay:           10 * time.Second,
		ConnectTimeout:              5 * time.Second,
		DisconnectTimeout:           10 * time.Second,
		ResubscribeTimeout:          5 * time.Second,
		ResubscribeAllSubscriptions: true,
		subscriptions:               topic.NewTree(),
		commandQueue:                make(chan *command, qs),
		futureStore:                 future.NewStore(),
	}
}
469318
func NewService(policyRepo policyReader, resourceRepo resourceReader, sessionRepo sessionReader) Service {
	return &service{
		policyRepo:   policyRepo,
		resourceRepo: resourceRepo,
		sessionRepo:  sessionRepo,
	}
}
94564
func newServiceInfo(svcPortName proxy.ServicePortName, port *v1.ServicePort, service *v1.Service, hns HostNetworkService) *serviceInfo {
	onlyNodeLocalEndpoints := false
	if apiservice.RequestsOnlyLocalTraffic(service) {
		onlyNodeLocalEndpoints = true
	}

	// set default session sticky max age 180min=10800s
	stickyMaxAgeSeconds := 10800
	if service.Spec.SessionAffinity == v1.ServiceAffinityClientIP && service.Spec.SessionAffinityConfig != nil {
		stickyMaxAgeSeconds = int(*service.Spec.SessionAffinityConfig.ClientIP.TimeoutSeconds)
	}
	info := &serviceInfo{
		clusterIP: net.ParseIP(service.Spec.ClusterIP),
		port:      int(port.Port),
		protocol:  port.Protocol,
		nodePort:  int(port.NodePort),
		// targetPort is zero if it is specified as a name in port.TargetPort.
		// Its real value would be got later from endpoints.
		targetPort: port.TargetPort.IntValue(),
		// Deep-copy in case the service instance changes
		loadBalancerStatus:       *service.Status.LoadBalancer.DeepCopy(),
		sessionAffinityType:      service.Spec.SessionAffinity,
		stickyMaxAgeSeconds:      stickyMaxAgeSeconds,
		loadBalancerSourceRanges: make([]string, len(service.Spec.LoadBalancerSourceRanges)),
		onlyNodeLocalEndpoints:   onlyNodeLocalEndpoints,
		hns:                      hns,
	}

	copy(info.loadBalancerSourceRanges, service.Spec.LoadBalancerSourceRanges)
	for _, eip := range service.Spec.ExternalIPs {
		info.externalIPs = append(info.externalIPs, &externalIPInfo{ip: eip})
	}
	for _, ingress := range service.Status.LoadBalancer.Ingress {
		info.loadBalancerIngressIPs = append(info.loadBalancerIngressIPs, &loadBalancerIngressInfo{ip: ingress.IP})
	}

	if apiservice.NeedsHealthCheck(service) {
		p := service.Spec.HealthCheckNodePort
		if p == 0 {
			klog.Errorf("Service %q has no healthcheck nodeport", svcPortName.NamespacedName.String())
		} else {
			info.healthCheckNodePort = int(p)
		}
	}

	return info
}