Skip to content

importas: config seems to get sorted before execution #1110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
grosser opened this issue Sep 30, 2024 · 2 comments · Fixed by julz/importas#24
Closed
3 tasks done

importas: config seems to get sorted before execution #1110

grosser opened this issue Sep 30, 2024 · 2 comments · Fixed by julz/importas#24
Labels
question Further information is requested

Comments

@grosser
Copy link

grosser commented Sep 30, 2024

Welcome

  • Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Description of the problem

I'm using import amissionv1 "k8s.io/api/admissionregistration/v1/admissionregistration/v1"
and locally it does not complain, but when running CI it does
so I looks like the config is getting sorted/shuffled before execution somehow

Version of golangci-lint

v1.60.3

Version of the GitHub Action

4

Workflow file

  lint:
    name: make lint
    runs-on: [self-hosted, zendesk-stable]
    steps:
      - name: Checkout source
        uses: actions/checkout@v4
      - name: Setup Golang
        uses: actions/setup-go@v5
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v4
        with:
          version: v1.60.3
          skip-go-installation: true
          working-directory: workload-migration

Golangci-lint configuration

linters:
  disable-all: true
  enable:
    - importas
linters-settings:
  importas:
    alias:
      - pkg: k8s.io/api/admissionregistration/v1
        alias: admissionv1
      - pkg: k8s.io/api/(\w+)/(v\d+\w*)
        alias: "$1$2"

Go version

1.22.2

Code example or link to a public repository

import amissionv1 "k8s.io/api/admissionregistration/v1/admissionregistration/v1"
@ldez ldez added the question Further information is requested label Sep 30, 2024
@ldez ldez changed the title config seems to get sorted before execution importas: config seems to get sorted before execution Sep 30, 2024
@ldez
Copy link
Member

ldez commented Sep 30, 2024

Hello,

the importas configuration is a slice, so there is no sort.

But, the configuration is set to the linter through the flags, and those flags are stored inside a map.

https://github.com/julz/importas/blob/b8654f969a5f5c63b119cadb1d310322a9d08d00/flags.go#L14

https://github.com/julz/importas/blob/b8654f969a5f5c63b119cadb1d310322a9d08d00/flags.go#L20

https://github.com/julz/importas/blob/b8654f969a5f5c63b119cadb1d310322a9d08d00/config.go#L11

So the problem is not inside golangci-lint but inside importas.

@grosser
Copy link
Author

grosser commented Oct 2, 2024

thx. made a fix PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants