fix lint errors

pull/19935/head
Steven Powell 2024-11-12 10:18:20 -05:00
parent 280ecd4d4b
commit eea20cd06f
10 changed files with 36 additions and 42 deletions

View File

@ -37,9 +37,9 @@ var FOLDER = "site/static/images/benchmarks/cpuUsage/autoPause"
type integerTicks struct{} type integerTicks struct{}
func (integerTicks) Ticks(min, max float64) []plot.Tick { func (integerTicks) Ticks(minimum, maximum float64) []plot.Tick {
var t []plot.Tick var t []plot.Tick
for i := math.Trunc(min); i <= max; i += 50 { for i := math.Trunc(minimum); i <= maximum; i += 50 {
t = append(t, plot.Tick{Value: i, Label: fmt.Sprint(i)}) t = append(t, plot.Tick{Value: i, Label: fmt.Sprint(i)})
} }
return t return t

View File

@ -36,9 +36,9 @@ var FOLDER = "site/static/images/benchmarks/cpuUsage/idleOnly"
type integerTicks struct{} type integerTicks struct{}
func (integerTicks) Ticks(min, max float64) []plot.Tick { func (integerTicks) Ticks(minimum, maximum float64) []plot.Tick {
var t []plot.Tick var t []plot.Tick
for i := math.Trunc(min); i <= max; i += 50 { for i := math.Trunc(minimum); i <= maximum; i += 50 {
t = append(t, plot.Tick{Value: i, Label: fmt.Sprint(i)}) t = append(t, plot.Tick{Value: i, Label: fmt.Sprint(i)})
} }
return t return t

View File

@ -327,8 +327,8 @@ func parsePortRange(rawPortRange string) (int, int, error) {
return minPort, maxPort, nil return minPort, maxPort, nil
} }
func getRandomPortNumberInRange(min, max int) int { func getRandomPortNumberInRange(minimum, maximum int) int {
return rand.Intn(max-min) + min return rand.Intn(maximum-minimum) + minimum
} }
func getAvailableTCPPortFromRange(minPort, maxPort int) (int, error) { func getAvailableTCPPortFromRange(minPort, maxPort int) (int, error) {

View File

@ -268,8 +268,8 @@ func (m *MemoryAsset) GetLength() int {
} }
// SetLength returns length // SetLength returns length
func (m *MemoryAsset) SetLength(len int) { func (m *MemoryAsset) SetLength(length int) {
m.length = len m.length = length
} }
// Read reads the asset // Read reads the asset
@ -403,8 +403,8 @@ func (m *BinAsset) GetLength() int {
} }
// SetLength sets length // SetLength sets length
func (m *BinAsset) SetLength(len int) { func (m *BinAsset) SetLength(length int) {
m.length = len m.length = length
} }
// Read reads the asset // Read reads the asset

View File

@ -507,13 +507,13 @@ func (r *Containerd) StopContainers(ids []string) error {
} }
// ContainerLogCmd returns the command to retrieve the log for a container based on ID // ContainerLogCmd returns the command to retrieve the log for a container based on ID
func (r *Containerd) ContainerLogCmd(id string, len int, follow bool) string { func (r *Containerd) ContainerLogCmd(id string, length int, follow bool) string {
return criContainerLogCmd(r.Runner, id, len, follow) return criContainerLogCmd(r.Runner, id, length, follow)
} }
// SystemLogCmd returns the command to retrieve system logs // SystemLogCmd returns the command to retrieve system logs
func (r *Containerd) SystemLogCmd(len int) string { func (r *Containerd) SystemLogCmd(length int) string {
return fmt.Sprintf("sudo journalctl -u containerd -n %d", len) return fmt.Sprintf("sudo journalctl -u containerd -n %d", length)
} }
// Preload preloads the container runtime with k8s images // Preload preloads the container runtime with k8s images

View File

@ -329,14 +329,14 @@ func listCRIImages(cr CommandRunner) ([]ListImage, error) {
} }
// criContainerLogCmd returns the command to retrieve the log for a container based on ID // criContainerLogCmd returns the command to retrieve the log for a container based on ID
func criContainerLogCmd(cr CommandRunner, id string, len int, follow bool) string { func criContainerLogCmd(cr CommandRunner, id string, length int, follow bool) string {
crictl := getCrictlPath(cr) crictl := getCrictlPath(cr)
var cmd strings.Builder var cmd strings.Builder
cmd.WriteString("sudo ") cmd.WriteString("sudo ")
cmd.WriteString(crictl) cmd.WriteString(crictl)
cmd.WriteString(" logs ") cmd.WriteString(" logs ")
if len > 0 { if length > 0 {
cmd.WriteString(fmt.Sprintf("--tail %d ", len)) cmd.WriteString(fmt.Sprintf("--tail %d ", length))
} }
if follow { if follow {
cmd.WriteString("--follow ") cmd.WriteString("--follow ")

View File

@ -406,13 +406,13 @@ func (r *CRIO) StopContainers(ids []string) error {
} }
// ContainerLogCmd returns the command to retrieve the log for a container based on ID // ContainerLogCmd returns the command to retrieve the log for a container based on ID
func (r *CRIO) ContainerLogCmd(id string, len int, follow bool) string { func (r *CRIO) ContainerLogCmd(id string, length int, follow bool) string {
return criContainerLogCmd(r.Runner, id, len, follow) return criContainerLogCmd(r.Runner, id, length, follow)
} }
// SystemLogCmd returns the command to retrieve system logs // SystemLogCmd returns the command to retrieve system logs
func (r *CRIO) SystemLogCmd(len int) string { func (r *CRIO) SystemLogCmd(length int) string {
return fmt.Sprintf("sudo journalctl -u crio -n %d", len) return fmt.Sprintf("sudo journalctl -u crio -n %d", length)
} }
// Preload preloads the container runtime with k8s images // Preload preloads the container runtime with k8s images

View File

@ -524,14 +524,14 @@ func (r *Docker) UnpauseContainers(ids []string) error {
} }
// ContainerLogCmd returns the command to retrieve the log for a container based on ID // ContainerLogCmd returns the command to retrieve the log for a container based on ID
func (r *Docker) ContainerLogCmd(id string, len int, follow bool) string { func (r *Docker) ContainerLogCmd(id string, length int, follow bool) string {
if r.UseCRI { if r.UseCRI {
return criContainerLogCmd(r.Runner, id, len, follow) return criContainerLogCmd(r.Runner, id, length, follow)
} }
var cmd strings.Builder var cmd strings.Builder
cmd.WriteString("docker logs ") cmd.WriteString("docker logs ")
if len > 0 { if length > 0 {
cmd.WriteString(fmt.Sprintf("--tail %d ", len)) cmd.WriteString(fmt.Sprintf("--tail %d ", length))
} }
if follow { if follow {
cmd.WriteString("--follow ") cmd.WriteString("--follow ")
@ -542,8 +542,8 @@ func (r *Docker) ContainerLogCmd(id string, len int, follow bool) string {
} }
// SystemLogCmd returns the command to retrieve system logs // SystemLogCmd returns the command to retrieve system logs
func (r *Docker) SystemLogCmd(len int) string { func (r *Docker) SystemLogCmd(length int) string {
return fmt.Sprintf("sudo journalctl -u docker -u cri-docker -n %d", len) return fmt.Sprintf("sudo journalctl -u docker -u cri-docker -n %d", length)
} }
type dockerDaemonConfig struct { type dockerDaemonConfig struct {

View File

@ -65,16 +65,10 @@ func TestNewBinary(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.input, func(t *testing.T) { t.Run(test.input, func(t *testing.T) {
bin, err := NewBinary(test.input) bin, err := NewBinary(test.input)
if err == nil && test.errExpected { if wantErr, gotErr := test.errExpected, (err != nil); wantErr != gotErr {
t.Fatalf("Input %v returned unexpected error", test.input) t.Fatalf("NewBinary(%s) returned err = %v; expected err %t", test.input, err, wantErr)
} }
if test.errExpected { if err == nil && !strings.Contains(bin.path, test.prNum) {
return
}
if bin == nil {
t.Fatalf("Input string(%v) returned unexpected empty binary", test.input)
}
if !strings.Contains(bin.path, test.prNum) {
t.Fatalf("Binary path(%v) doesn't contain expected(%v)", bin.path, test.prNum) t.Fatalf("Binary path(%v) doesn't contain expected(%v)", bin.path, test.prNum)
} }
}) })

View File

@ -148,13 +148,13 @@ var Inspect = func(addr string) (*Parameters, error) {
} }
gatewayIP := binary.BigEndian.Uint32(gateway) gatewayIP := binary.BigEndian.Uint32(gateway)
min := make(net.IP, 4) minIP := make(net.IP, 4)
binary.BigEndian.PutUint32(min, gatewayIP+1) // clients-from: first network IP address after gateway binary.BigEndian.PutUint32(minIP, gatewayIP+1) // clients-from: first network IP address after gateway
n.ClientMin = min.String() n.ClientMin = minIP.String()
max := make(net.IP, 4) maxIP := make(net.IP, 4)
binary.BigEndian.PutUint32(max, broadcastIP-1) // clients-to: last network IP address before broadcast binary.BigEndian.PutUint32(maxIP, broadcastIP-1) // clients-to: last network IP address before broadcast
n.ClientMax = max.String() n.ClientMax = maxIP.String()
return n, nil return n, nil
} }