Skip to content

Commit f2b63de

Browse files
committed
Fix linting issues
1 parent 6d72160 commit f2b63de

File tree

4 files changed

+3
-63
lines changed

4 files changed

+3
-63
lines changed

.github/workflows/publish-docker.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ jobs:
5353
flavor: |
5454
latest=${{ github.ref == 'refs/heads/main' }}
5555
56-
- name: Set short git commit SHA
57-
id: vars
58-
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
59-
6056
- name: Set up QEMU
6157
uses: docker/setup-qemu-action@v3
6258
with:
@@ -88,5 +84,5 @@ jobs:
8884
target: ${{ matrix.image.target }}
8985
build-args: |
9086
VERSION=${{ steps.meta.outputs.version }}
91-
GIT_COMMIT=${{ steps.vars.sha_short }}
92-
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
87+
GIT_COMMIT=${{ github.sha }}
88+
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ linters:
7979
path: internal/provider/cisco/nxos/vrf
8080
- linters:
8181
- lll
82+
- goconst
8283
path: internal/provider/cisco/nxos
8384
- linters:
8485
- lll

internal/provider/cisco/nxos/iface/portchannel_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ func Test_PortChannel_ToYGOT_GnmiClient(t *testing.T) {
160160
}
161161

162162
func Test_PortChannel_ToYGOT_Updates(t *testing.T) {
163-
164163
tests := []struct {
165164
name string
166165
pcName string
@@ -272,10 +271,8 @@ func Test_PortChannel_ToYGOT_Updates(t *testing.T) {
272271
updates, err := pc.ToYGOT(t.Context(), &gnmiext.ClientMock{
273272
ExistsFunc: func(_ context.Context, _ string) (bool, error) { return true, nil },
274273
})
275-
276274
if err != nil {
277275
t.Fatalf("unexpected error during ToYGOT: %v", err)
278-
279276
}
280277
if len(updates) != tt.expectedNumberOfUpdates {
281278
t.Fatalf("expected %d updates, got %d", tt.expectedNumberOfUpdates, len(updates))

test/utils/util.go

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package utils
55

66
import (
7-
"bufio"
8-
"bytes"
97
"fmt"
108
"os"
119
"os/exec"
@@ -200,55 +198,3 @@ func GetProjectDir() (string, error) {
200198
wd = strings.ReplaceAll(wd, "/test/e2e", "")
201199
return wd, nil
202200
}
203-
204-
// UncommentCode searches for target in the file and remove the comment prefix
205-
// of the target content. The target content may span multiple lines.
206-
func UncommentCode(filename, target, prefix string) error {
207-
// false positive
208-
// nolint:gosec
209-
content, err := os.ReadFile(filename)
210-
if err != nil {
211-
return fmt.Errorf("failed to read file %q: %w", filename, err)
212-
}
213-
strContent := string(content)
214-
215-
idx := strings.Index(strContent, target)
216-
if idx < 0 {
217-
return fmt.Errorf("unable to find the code %q to be uncomment", target)
218-
}
219-
220-
out := new(bytes.Buffer)
221-
_, err = out.Write(content[:idx])
222-
if err != nil {
223-
return fmt.Errorf("failed to write to output: %w", err)
224-
}
225-
226-
scanner := bufio.NewScanner(bytes.NewBufferString(target))
227-
if !scanner.Scan() {
228-
return nil
229-
}
230-
for {
231-
if _, err = out.WriteString(strings.TrimPrefix(scanner.Text(), prefix)); err != nil {
232-
return fmt.Errorf("failed to write to output: %w", err)
233-
}
234-
// Avoid writing a newline in case the previous line was the last in target.
235-
if !scanner.Scan() {
236-
break
237-
}
238-
if _, err = out.WriteString("\n"); err != nil {
239-
return fmt.Errorf("failed to write to output: %w", err)
240-
}
241-
}
242-
243-
if _, err = out.Write(content[idx+len(target):]); err != nil {
244-
return fmt.Errorf("failed to write to output: %w", err)
245-
}
246-
247-
// false positive
248-
// nolint:gosec
249-
if err = os.WriteFile(filename, out.Bytes(), 0o644); err != nil {
250-
return fmt.Errorf("failed to write file %q: %w", filename, err)
251-
}
252-
253-
return nil
254-
}

0 commit comments

Comments
 (0)