Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed Feb 24, 2024
1 parent 7935266 commit d70522e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 4 additions & 5 deletions pkg/pod/pod.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package pod

import (
"github.com/mercari/tortoise/api/v1beta3"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/ptr"

"github.com/mercari/tortoise/api/v1beta3"
)

type Service struct {
Expand All @@ -24,10 +25,10 @@ func New(
}, nil
}

func (s *Service) ModifyPodResource(pod *v1.Pod, t *v1beta3.Tortoise) *v1.Pod {
func (s *Service) ModifyPodResource(pod *v1.Pod, t *v1beta3.Tortoise) {
if t.Spec.UpdateMode == v1beta3.UpdateModeOff {
// DryRun, don't update Pod
return pod
return
}

oldRequestsMap := map[containerNameAndResource]resource.Quantity{}
Expand Down Expand Up @@ -80,8 +81,6 @@ func (s *Service) ModifyPodResource(pod *v1.Pod, t *v1beta3.Tortoise) *v1.Pod {
pod.Spec.Containers[i].Resources.Limits[k] = *newLim
}
}

return pod
}

type containerNameAndResource struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/mercari/tortoise/api/v1beta3"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"

"github.com/mercari/tortoise/api/v1beta3"
)

func TestService_ModifyPodResource(t *testing.T) {
Expand Down Expand Up @@ -456,7 +457,8 @@ func TestService_ModifyPodResource(t *testing.T) {
resourceLimitMultiplier: tt.fields.resourceLimitMultiplier,
minimumCPULimit: tt.fields.minimumCPULimit,
}
got := s.ModifyPodResource(tt.args.pod, tt.args.tortoise)
got := tt.args.pod.DeepCopy()
s.ModifyPodResource(got, tt.args.tortoise)
if d := cmp.Diff(got, tt.want); d != "" {
t.Errorf("ModifyPodResource() mismatch (-want +got):\n%s", d)
}
Expand Down

0 comments on commit d70522e

Please sign in to comment.