Skip to content

Commit

Permalink
fix: golangci-lint errors fixed
Browse files Browse the repository at this point in the history
Signed-off-by: James Lu <[email protected]>
  • Loading branch information
mantissahz committed May 29, 2024
1 parent 328b6f3 commit bf53d83
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
run: make ci

# Run e2e test
#- name: Run E2e Test
# run: make e2e-test
- name: Run e2e Test
run: make e2e-test

# Upload binaries
- name: Upload Binaries
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
with:
context: ./
push: true
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64, linux/arm
tags: rancher/local-path-provisioner:${{ env.branch }}-head
file: package/Dockerfile

Expand All @@ -85,6 +85,6 @@ jobs:
with:
context: ./
push: true
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64, linux/arm
tags: rancher/local-path-provisioner:${{ github.ref_name }}
file: package/Dockerfile
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ var (
EnvConfigMountPath = "CONFIG_MOUNT_PATH"
)

func cmdNotFound(c *cli.Context, command string) {
func cmdNotFound(_ *cli.Context, command string) {
panic(fmt.Errorf("Unrecognized command: %s", command))
}

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

func RegisterShutdownChannel(cancelFn context.CancelFunc) {
Expand Down
3 changes: 2 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
FROM alpine

ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ] && [ "$TARGETPLATFORM" != "linux/arm/v7" ]; then \
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
exit 1; \
fi

ENV ARCH ${TARGETPLATFORM#linux/}
ENV ARCH ${ARCH%/v7}

RUN apk update
RUN apk upgrade --no-cache busybox zlib
Expand Down
6 changes: 3 additions & 3 deletions provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ type pvMetadata struct {
func pathFromPattern(pattern string, opts pvController.ProvisionOptions) (string, error) {
metadata := pvMetadata{
PVName: opts.PVName,
PVC: opts.PVC.ObjectMeta,
PVC: opts.PVC.ObjectMeta,
}

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

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

func (p *LocalPathProvisioner) Delete(ctx context.Context, pv *v1.PersistentVolume) (err error) {
func (p *LocalPathProvisioner) Delete(_ context.Context, pv *v1.PersistentVolume) (err error) {
cfg, err := p.pickConfig(pv.Spec.StorageClassName)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fi
LINKFLAGS="-X main.VERSION=$VERSION"
CGO_ENABLED=0 GOARCH=amd64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/local-path-provisioner-amd64
CGO_ENABLED=0 GOARCH=arm64 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/local-path-provisioner-arm64
CGO_ENABLED=0 GOARCH=arm go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/local-path-provisioner-arm
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-windows
Expand Down
1 change: 1 addition & 0 deletions test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

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

0 comments on commit bf53d83

Please sign in to comment.