Repository: zegl/kube-score (go)

Issue:
Failing when use ExternalName in Service
```
---
apiVersion: v1
kind: Service
metadata:
  name: wp-site
  namespace: site
spec:
  externalName: wp.example.com
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  type: ExternalName
```

**Output:**

```
v1/Service wp-site in site
    [OK] Stable version
    [CRITICAL] Service Targets Pod
        * The services selector does not match any pods
```

Pull request description:
service: ignore services of type ExternalName in the service-targets-pod test
Fixes #53

Patch:
diff --git a/score/service/service.go b/score/service/service.go
index db23c2d..3fd4bf1 100644
--- a/score/service/service.go
+++ b/score/service/service.go
@@ -29,6 +29,12 @@ func ScoreServiceTargetsPod(pods []corev1.Pod, podspecers []ks.PodSpecer) func(c
 		score.Name = "Service Targets Pod"
 		score.ID = "service-targets-pod"
 
+		// Services of type ExternalName does not have a selector
+		if service.Spec.Type == corev1.ServiceTypeExternalName {
+			score.Grade = scorecard.GradeAllOK
+			return
+		}
+
 		hasMatch := false
 
 		for _, podLables := range podsInNamespace[service.Namespace] {


Test patch:
diff --git a/score/service_test.go b/score/service_test.go
index 5398fba..bb971e0 100644
--- a/score/service_test.go
+++ b/score/service_test.go
@@ -41,3 +41,7 @@ func TestServiceTargetsPodDeploymentSameNamespace(t *testing.T) {
 func TestServiceTargetsPodDeploymentDifferentNamespace(t *testing.T) {
 	testExpectedScore(t, "service-target-deployment-different-namespace.yaml", "Service Targets Pod", 1)
 }
+
+func TestServiceExternalName(t *testing.T) {
+	testExpectedScore(t, "service-externalname.yaml", "Service Targets Pod", 10)
+}
diff --git a/score/testdata/service-externalname.yaml b/score/testdata/service-externalname.yaml
new file mode 100644
index 0000000..41e96d2
--- /dev/null
+++ b/score/testdata/service-externalname.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: wp-site
+  namespace: site
+spec:
+  externalName: wp.example.com
+  ports:
+  - name: http
+    port: 80
+    protocol: TCP
+    targetPort: 80
+  type: ExternalName