diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a406ee3..5a7447b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,10 +4,12 @@ name: Main workflow on: + pull_request: + branches: + - main push: branches: - main - pull_request: jobs: build: @@ -30,6 +32,20 @@ jobs: - name: Build Docker image run: make docker-build + staticcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: WillAbides/setup-go-faster@v1.14.0 + with: + go-version-file: 'go.mod' + + - uses: dominikh/staticcheck-action@v1.3.1 + with: + version: latest + install-go: false + lint: name: lint runs-on: ubuntu-latest diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 2f5ae56..7a338f2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright 2022-present Open Networking Foundation +# Copyright 2024 Intel Corporation name: GitHub release and Docker images on: @@ -183,7 +184,7 @@ jobs: commit-message: Update version committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> - signoff: false + signoff: true branch: version-update delete-branch: true title: Update version diff --git a/internal/pfcpsim/export/export.go b/internal/pfcpsim/export/export.go index 0dad5b3..1301417 100644 --- a/internal/pfcpsim/export/export.go +++ b/internal/pfcpsim/export/export.go @@ -26,8 +26,8 @@ const ( ) var ( - notConnected = errors.New("Not connected") - notAssociated = errors.New("Not associated") + errNotConnected = errors.New("not connected") + errNotAssociated = errors.New("not associated") ) const SessionStep = 10 @@ -74,7 +74,7 @@ func (c *PfcpSimCfg) TerminatePFCPSim() error { func (c *PfcpSimCfg) Associate() error { switch c.state { case SVC_INIT: - return notConnected + return errNotConnected case SVC_CONNECTED: err := c.sim.SetupAssociation() if err != nil { @@ -90,9 +90,9 @@ func (c *PfcpSimCfg) Associate() error { func (c *PfcpSimCfg) Deassociate() error { switch c.state { case SVC_INIT: - return notConnected + return errNotConnected case SVC_CONNECTED: - return notAssociated + return errNotAssociated case SVC_ASSOCIATED: err := c.sim.TeardownAssociation() if err != nil { diff --git a/internal/pfcpsim/helpers.go b/internal/pfcpsim/helpers.go index 5c346c4..325af71 100644 --- a/internal/pfcpsim/helpers.go +++ b/internal/pfcpsim/helpers.go @@ -17,7 +17,7 @@ import ( "google.golang.org/grpc/status" ) -var notInit = errors.New("PFCP simulator is not initialized") +var errNotInit = errors.New("PFCP simulator is not initialized") const ( sdfFilterFormatWPort = "permit out %v from %v to assigned %v-%v" @@ -50,7 +50,7 @@ func ConnectPFCPSim() error { func DisconnectPFCPSim() error { if sim == nil { - return notInit + return errNotInit } return sim.TeardownAssociation() diff --git a/pkg/pfcpsim/pfcpsim.go b/pkg/pfcpsim/pfcpsim.go index 4b788eb..23968ac 100644 --- a/pkg/pfcpsim/pfcpsim.go +++ b/pkg/pfcpsim/pfcpsim.go @@ -11,7 +11,6 @@ import ( "sync" "time" - "github.com/wmnsk/go-pfcp/ie" ieLib "github.com/wmnsk/go-pfcp/ie" "github.com/wmnsk/go-pfcp/message" ) @@ -25,8 +24,8 @@ const ( var ( activeSessions = make(map[int]*PFCPSession, 0) lockActiveSessions = new(sync.Mutex) - wrongRspType = errors.New("unexpected response type") - assocFailed = errors.New("association failed") + errWrongRspType = errors.New("unexpected response type") + errAssocFailed = errors.New("association failed") ) func GetActiveSessionNum() int { @@ -304,7 +303,7 @@ func (c *PFCPClient) sendSessionReportResponse(seq uint32, seid uint64) error { } res := message.NewSessionReportResponse(0, 0, rseid, seq, 0, - ie.NewCause(ie.CauseRequestAccepted)) + ieLib.NewCause(ieLib.CauseRequestAccepted)) return c.sendMsg(res) } @@ -456,7 +455,7 @@ func (c *PFCPClient) SetupAssociation() error { assocResp, ok := resp.(*message.AssociationSetupResponse) if !ok { - return NewInvalidResponseError(wrongRspType) + return NewInvalidResponseError(errWrongRspType) } cause, err := assocResp.Cause.Cause() @@ -465,7 +464,7 @@ func (c *PFCPClient) SetupAssociation() error { } if cause != ieLib.CauseRequestAccepted { - return NewInvalidResponseError(assocFailed) + return NewInvalidResponseError(errAssocFailed) } c.setAssociationStatus(true)