Skip to content

Commit

Permalink
codebeat: remove optional args from MakeContainerRes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbrainard committed Sep 12, 2024
1 parent 2af813b commit 0e70b11
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions internal/dao/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ func (c *Container) List(ctx context.Context, _ string) ([]runtime.Object, error
}
res := make([]runtime.Object, 0, len(po.Spec.InitContainers)+len(po.Spec.Containers))
for i, co := range po.Spec.InitContainers {
res = append(res, render.MakeContainerRes(po, true, i, cmx[co.Name]))
cr := render.MakeContainerRes(po, true, i)
cr.MX = cmx[co.Name]
res = append(res, cr)
}
for i, co := range po.Spec.Containers {
res = append(res, render.MakeContainerRes(po, false, i, cmx[co.Name]))
cr := render.MakeContainerRes(po, false, i)
cr.MX = cmx[co.Name]
res = append(res, cr)
}

return res, nil
Expand Down
3 changes: 1 addition & 2 deletions internal/render/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,11 @@ func probe(p *v1.Probe) string {
return on
}

func MakeContainerRes(po *v1.Pod, isInit bool, index int, cmx *mv1beta1.ContainerMetrics) ContainerRes {
func MakeContainerRes(po *v1.Pod, isInit bool, index int) ContainerRes {
return ContainerRes{
pod: po,
IsInit: isInit,
Index: index,
MX: cmx,
Age: po.GetCreationTimestamp(),
}
}
Expand Down
5 changes: 3 additions & 2 deletions internal/render/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ func makeContainerRes(container *v1.Container, status *v1.ContainerStatus, cmx *
po.Status.ContainerStatuses = []v1.ContainerStatus{*status}
}

return render.MakeContainerRes(
cr := render.MakeContainerRes(
po,
isInit,
0,
cmx,
)
cr.MX = cmx
return cr
}

func toQty(s string) resource.Quantity {
Expand Down
2 changes: 1 addition & 1 deletion internal/xray/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,5 @@ func makeContainerRes(container *v1.Container) render.ContainerRes {
},
}

return render.MakeContainerRes(po, false, 0, nil)
return render.MakeContainerRes(po, false, 0)
}
4 changes: 2 additions & 2 deletions internal/xray/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func (*Pod) containerRefs(ctx context.Context, parent *TreeNode, ns string, po *
ctx = context.WithValue(ctx, KeyParent, parent)
var cre Container
for i := 0; i < len(po.Spec.InitContainers); i++ {
if err := cre.Render(ctx, ns, render.MakeContainerRes(po, true, i, nil)); err != nil {
if err := cre.Render(ctx, ns, render.MakeContainerRes(po, true, i)); err != nil {
return err
}
}
for i := 0; i < len(po.Spec.Containers); i++ {
if err := cre.Render(ctx, ns, render.MakeContainerRes(po, false, i, nil)); err != nil {
if err := cre.Render(ctx, ns, render.MakeContainerRes(po, false, i)); err != nil {
return err
}
}
Expand Down

0 comments on commit 0e70b11

Please sign in to comment.