Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Oct 24, 2016
1 parent 529759b commit 9881a6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/api_topologies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func TestAPITopologyAddsKubernetes(t *testing.T) {
{ContainerID: "container2"},
},
},
Spec: api.PodSpec{
SecurityContext: &api.PodSecurityContext{},
},
}).GetNode("")
buf := &bytes.Buffer{}
encoder := codec.NewEncoder(buf, &codec.MsgpackHandle{})
Expand Down
2 changes: 1 addition & 1 deletion probe/kubernetes/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (p *pod) GetNode(probeID string) report.Node {
report.ControlProbeID: probeID,
}

if p.Pod.Spec.SecurityContext.HostNetwork {
if sc := p.Pod.Spec.SecurityContext; sc != nil && sc.HostNetwork {
latests[IsInHostNetwork] = "true"
}

Expand Down
6 changes: 5 additions & 1 deletion probe/kubernetes/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var (
},
Spec: api.PodSpec{
NodeName: nodeName,
SecurityContext: &api.PodSecurityContext{
HostNetwork: true,
},
},
}
apiPod2 = api.Pod{
Expand All @@ -65,7 +68,8 @@ var (
},
},
Spec: api.PodSpec{
NodeName: nodeName,
NodeName: nodeName,
SecurityContext: &api.PodSecurityContext{},
},
}
apiService1 = api.Service{
Expand Down

0 comments on commit 9881a6b

Please sign in to comment.