Skip to content

Commit

Permalink
Merge pull request #90 from humblec/better
Browse files Browse the repository at this point in the history
Enable golang-ci linter in the project
  • Loading branch information
k8s-ci-robot committed Jan 21, 2022
2 parents f0701e9 + a1e15e1 commit 81d283f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 9 deletions.
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

0 comments on commit 81d283f

Please sign in to comment.