Skip to content

Commit 6bddefc

Browse files
committed
fix: golangci-lint errors fixed
Signed-off-by: James Lu <[email protected]>
1 parent 7156bae commit 6bddefc

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

.github/workflows/build.yml

+21-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
build:
1212
name: Build Binaries
1313
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
id-token: write
1417
steps:
1518
- name: Checkout Codes
1619
uses: actions/checkout@v4
@@ -20,8 +23,8 @@ jobs:
2023
run: make ci
2124

2225
# Run e2e test
23-
#- name: Run E2e Test
24-
# run: make e2e-test
26+
- name: Run e2e Test
27+
run: make e2e-test
2528

2629
# Upload binaries
2730
- name: Upload Binaries
@@ -33,6 +36,9 @@ jobs:
3336
build_push_image:
3437
name: Build and Push Images
3538
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
41+
id-token: write
3642
needs: build
3743
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
3844
steps:
@@ -59,14 +65,22 @@ jobs:
5965
- name: Set up Docker Buildx
6066
uses: docker/setup-buildx-action@v3
6167

62-
- name: Declare Branch
68+
- name: Read Secrets
69+
uses: rancher-eio/read-vault-secrets@main
70+
if: ${{ inputs.push == true }}
71+
with:
72+
secrets: |
73+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
74+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
75+
76+
- name: Login to Docker Hub
6377
run: |
6478
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV"
6579
- name: Login to Docker Hub
6680
uses: docker/login-action@v3
6781
with:
68-
username: ${{ secrets.DOCKER_USERNAME }}
69-
password: ${{ secrets.DOCKER_PASSWORD }}
82+
username: ${{ env.DOCKER_USERNAME }}
83+
password: ${{ env.DOCKER_PASSWORD }}
7084

7185
# rancher/local-path-provisioner image
7286
- name: docker-publish
@@ -75,7 +89,7 @@ jobs:
7589
with:
7690
context: ./
7791
push: true
78-
platforms: linux/amd64,linux/arm64
92+
platforms: linux/amd64,linux/arm64, linux/arm
7993
tags: rancher/local-path-provisioner:${{ env.branch }}-head
8094
file: package/Dockerfile
8195

@@ -85,6 +99,6 @@ jobs:
8599
with:
86100
context: ./
87101
push: true
88-
platforms: linux/amd64,linux/arm64
102+
platforms: linux/amd64,linux/arm64, linux/arm
89103
tags: rancher/local-path-provisioner:${{ github.ref_name }}
90104
file: package/Dockerfile

main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ var (
5151
EnvConfigMountPath = "CONFIG_MOUNT_PATH"
5252
)
5353

54-
func cmdNotFound(c *cli.Context, command string) {
54+
func cmdNotFound(_ *cli.Context, command string) {
5555
panic(fmt.Errorf("Unrecognized command: %s", command))
5656
}
5757

58-
func onUsageError(c *cli.Context, err error, isSubcommand bool) error {
59-
panic(fmt.Errorf("Usage error, please check your command"))
58+
func onUsageError(_ *cli.Context, err error, _ bool) error {
59+
panic(errors.Wrap(err, "Usage error, please check your command"))
6060
}
6161

6262
func RegisterShutdownChannel(cancelFn context.CancelFunc) {

package/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
FROM alpine
44

55
ARG TARGETPLATFORM
6-
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
6+
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ] && [ "$TARGETPLATFORM" != "linux/arm/v7" ]; then \
77
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
88
exit 1; \
99
fi
1010

1111
ENV ARCH ${TARGETPLATFORM#linux/}
12+
ENV ARCH ${ARCH%/v7}
1213

1314
RUN apk update
1415
RUN apk upgrade --no-cache busybox zlib

provisioner.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ type pvMetadata struct {
300300
func pathFromPattern(pattern string, opts pvController.ProvisionOptions) (string, error) {
301301
metadata := pvMetadata{
302302
PVName: opts.PVName,
303-
PVC: opts.PVC.ObjectMeta,
303+
PVC: opts.PVC.ObjectMeta,
304304
}
305305

306306
tpl, err := template.New("pathPattern").Parse(pattern)
@@ -317,7 +317,7 @@ func pathFromPattern(pattern string, opts pvController.ProvisionOptions) (string
317317
return buf.String(), nil
318318
}
319319

320-
func (p *LocalPathProvisioner) Provision(ctx context.Context, opts pvController.ProvisionOptions) (*v1.PersistentVolume, pvController.ProvisioningState, error) {
320+
func (p *LocalPathProvisioner) Provision(_ context.Context, opts pvController.ProvisionOptions) (*v1.PersistentVolume, pvController.ProvisioningState, error) {
321321
cfg, err := p.pickConfig(opts.StorageClass.Name)
322322
if err != nil {
323323
return nil, pvController.ProvisioningFinished, err
@@ -462,7 +462,7 @@ func (p *LocalPathProvisioner) provisionFor(opts pvController.ProvisionOptions,
462462
}, pvController.ProvisioningFinished, nil
463463
}
464464

465-
func (p *LocalPathProvisioner) Delete(ctx context.Context, pv *v1.PersistentVolume) (err error) {
465+
func (p *LocalPathProvisioner) Delete(_ context.Context, pv *v1.PersistentVolume) (err error) {
466466
cfg, err := p.pickConfig(pv.Spec.StorageClassName)
467467
if err != nil {
468468
return err

scripts/build

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fi
1212
LINKFLAGS="-X main.VERSION=$VERSION"
1313
CGO_ENABLED=0 GOARCH=amd64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/local-path-provisioner-amd64
1414
CGO_ENABLED=0 GOARCH=arm64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/local-path-provisioner-arm64
15+
CGO_ENABLED=0 GOARCH=arm go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/local-path-provisioner-arm
1516
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
1617
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-darwin
1718
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-windows

test/util.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func createCmd(t *testing.T, cmd, kustomizeDir string, envs []string, callback func(*exec.Cmd)) *exec.Cmd {
15+
t.Logf("creating command: %s", cmd)
1516
c := exec.Command("bash", "-c", cmd)
1617
c.Env = append(os.Environ(), envs...)
1718
c.Dir = kustomizeDir

0 commit comments

Comments
 (0)