Skip to content
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

Enable golang-ci linter in the project #90

Merged
merged 2 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
45 changes: 45 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.42

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
- name: errors
run: golangci-lint run
if: ${{ failure() }}
15 changes: 10 additions & 5 deletions cmd/iscsiplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ var (
)

func init() {
flag.Set("logtostderr", "true")
flag.Set("logtostderr", "true") //nolint:errcheck
}

func main() {

flag.CommandLine.Parse([]string{})
flag.CommandLine.Parse([]string{}) //nolint:errcheck

cmd := &cobra.Command{
Use: "iscsi.csi.k8s.io",
Expand All @@ -53,10 +52,16 @@ func main() {
cmd.Flags().AddGoFlagSet(flag.CommandLine)

cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "node id")
cmd.MarkPersistentFlagRequired("nodeid")
err := cmd.MarkPersistentFlagRequired("nodeid")
if err != nil {
return
}

cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "", "CSI endpoint")
cmd.MarkPersistentFlagRequired("endpoint")
err = cmd.MarkPersistentFlagRequired("endpoint")
if err != nil {
return
}

if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%s", err.Error())
Expand Down
2 changes: 0 additions & 2 deletions pkg/iscsi/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type driver struct {
nodeID string
version string
endpoint string
ns *nodeServer
cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}
Expand Down Expand Up @@ -99,5 +98,4 @@ func (d *driver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapa

d.cscap = csc

return
}
2 changes: 0 additions & 2 deletions pkg/iscsi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ func (s *nonBlockingGRPCServer) Start(endpoint string, ids csi.IdentityServer, c
s.wg.Add(1)

go s.serve(endpoint, ids, cs, ns)

return
}

func (s *nonBlockingGRPCServer) Wait() {
Expand Down