@@ -31,9 +31,15 @@ import (
3131
3232"k8s.io/api/core/v1" 
3333metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 
34- corev1 "k8s.io/client-go/kubernetes/typed/core/v1" 
3534)
3635
36+ // ServiceInterface has methods to work with Service resources. 
37+ type  ServiceInterface  interface  {
38+ Create (* v1.Service ) (* v1.Service , error )
39+ Delete (name  string , options  * metav1.DeleteOptions ) error 
40+ Get (name  string , options  metav1.GetOptions ) (* v1.Service , error )
41+ }
42+ 
3743// CreateHeadlessServiceName returns the name of the headless service for the given 
3844// deployment name. 
3945func  CreateHeadlessServiceName (deploymentName  string ) string  {
@@ -63,7 +69,7 @@ func CreateSyncMasterClientServiceName(deploymentName string) string {
6369// If the service already exists, nil is returned. 
6470// If another error occurs, that error is returned. 
6571// The returned bool is true if the service is created, or false when the service already existed. 
66- func  CreateHeadlessService (svcs  corev1. ServiceInterface , deployment  metav1.Object , owner  metav1.OwnerReference ) (string , bool , error ) {
72+ func  CreateHeadlessService (svcs  ServiceInterface , deployment  metav1.Object , owner  metav1.OwnerReference ) (string , bool , error ) {
6773deploymentName  :=  deployment .GetName ()
6874svcName  :=  CreateHeadlessServiceName (deploymentName )
6975ports  :=  []v1.ServicePort {
@@ -86,7 +92,7 @@ func CreateHeadlessService(svcs corev1.ServiceInterface, deployment metav1.Objec
8692// If the service already exists, nil is returned. 
8793// If another error occurs, that error is returned. 
8894// The returned bool is true if the service is created, or false when the service already existed. 
89- func  CreateDatabaseClientService (svcs  corev1. ServiceInterface , deployment  metav1.Object , single  bool , owner  metav1.OwnerReference ) (string , bool , error ) {
95+ func  CreateDatabaseClientService (svcs  ServiceInterface , deployment  metav1.Object , single  bool , owner  metav1.OwnerReference ) (string , bool , error ) {
9096deploymentName  :=  deployment .GetName ()
9197svcName  :=  CreateDatabaseClientServiceName (deploymentName )
9298ports  :=  []v1.ServicePort {
@@ -115,7 +121,7 @@ func CreateDatabaseClientService(svcs corev1.ServiceInterface, deployment metav1
115121// If the service already exists, nil is returned. 
116122// If another error occurs, that error is returned. 
117123// The returned bool is true if the service is created, or false when the service already existed. 
118- func  CreateExternalAccessService (svcs  corev1. ServiceInterface , svcName , role  string , deployment  metav1.Object , serviceType  v1.ServiceType , port , nodePort  int , loadBalancerIP  string , owner  metav1.OwnerReference ) (string , bool , error ) {
124+ func  CreateExternalAccessService (svcs  ServiceInterface , svcName , role  string , deployment  metav1.Object , serviceType  v1.ServiceType , port , nodePort  int , loadBalancerIP  string , owner  metav1.OwnerReference ) (string , bool , error ) {
119125deploymentName  :=  deployment .GetName ()
120126ports  :=  []v1.ServicePort {
121127v1.ServicePort {
@@ -137,7 +143,7 @@ func CreateExternalAccessService(svcs corev1.ServiceInterface, svcName, role str
137143// If the service already exists, nil is returned. 
138144// If another error occurs, that error is returned. 
139145// The returned bool is true if the service is created, or false when the service already existed. 
140- func  createService (svcs  corev1. ServiceInterface , svcName , deploymentName , ns , clusterIP , role  string , serviceType  v1.ServiceType ,
146+ func  createService (svcs  ServiceInterface , svcName , deploymentName , ns , clusterIP , role  string , serviceType  v1.ServiceType ,
141147ports  []v1.ServicePort , loadBalancerIP  string , publishNotReadyAddresses  bool , owner  metav1.OwnerReference ) (bool , error ) {
142148labels  :=  LabelsForDeployment (deploymentName , role )
143149svc  :=  & v1.Service {
0 commit comments