Skip to content
Snippets Groups Projects
Commit 8d208075 authored by James Lu's avatar James Lu Committed by Derek Su
Browse files

fix: golangci-lint errors fixed


Signed-off-by: default avatarJames Lu <james.lu@suse.com>
parent 16f15ccd
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,9 @@ jobs: ...@@ -11,6 +11,9 @@ jobs:
build: build:
name: Build Binaries name: Build Binaries
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps: steps:
- name: Checkout Codes - name: Checkout Codes
uses: actions/checkout@v4 uses: actions/checkout@v4
...@@ -20,8 +23,8 @@ jobs: ...@@ -20,8 +23,8 @@ jobs:
run: make ci run: make ci
# Run e2e test # Run e2e test
#- name: Run E2e Test - name: Run e2e Test
# run: make e2e-test run: make e2e-test
# Upload binaries # Upload binaries
- name: Upload Binaries - name: Upload Binaries
...@@ -33,6 +36,9 @@ jobs: ...@@ -33,6 +36,9 @@ jobs:
build_push_image: build_push_image:
name: Build and Push Images name: Build and Push Images
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs: build needs: build
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }} if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
steps: steps:
...@@ -59,14 +65,22 @@ jobs: ...@@ -59,14 +65,22 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Declare Branch - name: Read Secrets
uses: rancher-eio/read-vault-secrets@main
if: ${{ inputs.push == true }}
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Login to Docker Hub
run: | run: |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV" echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV"
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ env.DOCKER_PASSWORD }}
# rancher/local-path-provisioner image # rancher/local-path-provisioner image
- name: docker-publish - name: docker-publish
...@@ -75,7 +89,7 @@ jobs: ...@@ -75,7 +89,7 @@ jobs:
with: with:
context: ./ context: ./
push: true push: true
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64, linux/arm
tags: rancher/local-path-provisioner:${{ env.branch }}-head tags: rancher/local-path-provisioner:${{ env.branch }}-head
file: package/Dockerfile file: package/Dockerfile
...@@ -85,6 +99,6 @@ jobs: ...@@ -85,6 +99,6 @@ jobs:
with: with:
context: ./ context: ./
push: true push: true
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64, linux/arm
tags: rancher/local-path-provisioner:${{ github.ref_name }} tags: rancher/local-path-provisioner:${{ github.ref_name }}
file: package/Dockerfile file: package/Dockerfile
...@@ -51,12 +51,12 @@ var ( ...@@ -51,12 +51,12 @@ var (
EnvConfigMountPath = "CONFIG_MOUNT_PATH" EnvConfigMountPath = "CONFIG_MOUNT_PATH"
) )
func cmdNotFound(c *cli.Context, command string) { func cmdNotFound(_ *cli.Context, command string) {
panic(fmt.Errorf("Unrecognized command: %s", command)) panic(fmt.Errorf("Unrecognized command: %s", command))
} }
func onUsageError(c *cli.Context, err error, isSubcommand bool) error { func onUsageError(_ *cli.Context, err error, _ bool) error {
panic(fmt.Errorf("Usage error, please check your command")) panic(errors.Wrap(err, "Usage error, please check your command"))
} }
func RegisterShutdownChannel(cancelFn context.CancelFunc) { func RegisterShutdownChannel(cancelFn context.CancelFunc) {
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
FROM alpine FROM alpine
ARG TARGETPLATFORM 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" && \ echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
exit 1; \ exit 1; \
fi fi
ENV ARCH ${TARGETPLATFORM#linux/} ENV ARCH ${TARGETPLATFORM#linux/}
ENV ARCH ${ARCH%/v7}
RUN apk update RUN apk update
RUN apk upgrade --no-cache busybox zlib RUN apk upgrade --no-cache busybox zlib
......
...@@ -317,7 +317,7 @@ func pathFromPattern(pattern string, opts pvController.ProvisionOptions) (string ...@@ -317,7 +317,7 @@ func pathFromPattern(pattern string, opts pvController.ProvisionOptions) (string
return buf.String(), nil 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) cfg, err := p.pickConfig(opts.StorageClass.Name)
if err != nil { if err != nil {
return nil, pvController.ProvisioningFinished, err return nil, pvController.ProvisioningFinished, err
...@@ -462,7 +462,7 @@ func (p *LocalPathProvisioner) provisionFor(opts pvController.ProvisionOptions, ...@@ -462,7 +462,7 @@ func (p *LocalPathProvisioner) provisionFor(opts pvController.ProvisionOptions,
}, pvController.ProvisioningFinished, nil }, 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) cfg, err := p.pickConfig(pv.Spec.StorageClassName)
if err != nil { if err != nil {
return err return err
......
...@@ -12,6 +12,7 @@ fi ...@@ -12,6 +12,7 @@ fi
LINKFLAGS="-X main.VERSION=$VERSION" 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=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=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 if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-darwin GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-windows GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/local-path-provisioner-windows
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
) )
func createCmd(t *testing.T, cmd, kustomizeDir string, envs []string, callback func(*exec.Cmd)) *exec.Cmd { 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 := exec.Command("bash", "-c", cmd)
c.Env = append(os.Environ(), envs...) c.Env = append(os.Environ(), envs...)
c.Dir = kustomizeDir c.Dir = kustomizeDir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment