Skip to content

Commit

Permalink
Checking for type assertion success (#181)
Browse files Browse the repository at this point in the history
Fixes #174

Signed-off-by: Aaron Schlesinger <[email protected]>

Co-authored-by: Tom Kerkhove <[email protected]>
  • Loading branch information
arschles and tomkerkhove authored Jul 1, 2021
1 parent c0aaa60 commit 09f3812
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 3 additions & 7 deletions interceptor/forward_wait_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ func newDeployReplicasForwardWaitFunc(
for {
select {
case event := <-eventCh:
deployment := event.Object.(*appsv1.Deployment)
if err != nil {
log.Printf(
"Error getting deployment %s after change was triggered (%s)",
deployName,
err,
)
deployment, ok := event.Object.(*appsv1.Deployment)
if !ok {
log.Println("Didn't get a deployment back in event")
}
if moreThanPtr(deployment.Spec.Replicas, 0) {
return nil
Expand Down
7 changes: 6 additions & 1 deletion pkg/k8s/deployment_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ func NewK8sDeploymentCache(
evt := <-ch
ret.broadcaster.Action(evt.Type, evt.Object)
ret.rwm.Lock()
depl := evt.Object.(*appsv1.Deployment)
depl, ok := evt.Object.(*appsv1.Deployment)
// if we didn't get back a deployment in the event,
// something is wrong that we can't fix, so just continue
if !ok {
continue
}
ret.latestEvts[depl.GetObjectMeta().GetName()] = evt
ret.rwm.Unlock()
}
Expand Down

0 comments on commit 09f3812

Please sign in to comment.