decouple bouncer dependencies: use go-cs-lib/pkg/ptr in apiclient (#2227)
This commit is contained in:
parent
e1400d28f1
commit
e5fe74ce77
2 changed files with 10 additions and 8 deletions
|
@ -6,6 +6,8 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/crowdsecurity/go-cs-lib/pkg/ptr"
|
||||
|
||||
"github.com/crowdsecurity/crowdsec/pkg/models"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/modelscapi"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
|
@ -102,10 +104,10 @@ func (s *DecisionsService) GetDecisionsFromGroups(decisionsGroups []*modelscapi.
|
|||
partialDecisions[idx] = &models.Decision{
|
||||
Scenario: decisionsGroup.Scenario,
|
||||
Scope: decisionsGroup.Scope,
|
||||
Type: types.StrPtr(types.DecisionTypeBan),
|
||||
Type: ptr.Of(types.DecisionTypeBan),
|
||||
Value: decision.Value,
|
||||
Duration: decision.Duration,
|
||||
Origin: types.StrPtr(types.CAPIOrigin),
|
||||
Origin: ptr.Of(types.CAPIOrigin),
|
||||
}
|
||||
}
|
||||
decisions = append(decisions, partialDecisions...)
|
||||
|
@ -138,10 +140,10 @@ func (s *DecisionsService) FetchV3Decisions(ctx context.Context, url string) (*m
|
|||
partialDecisions[idx] = &models.Decision{
|
||||
Scenario: &scenarioDeleted,
|
||||
Scope: decisionsGroup.Scope,
|
||||
Type: types.StrPtr(types.DecisionTypeBan),
|
||||
Type: ptr.Of(types.DecisionTypeBan),
|
||||
Value: &decision,
|
||||
Duration: &durationDeleted,
|
||||
Origin: types.StrPtr(types.CAPIOrigin),
|
||||
Origin: ptr.Of(types.CAPIOrigin),
|
||||
}
|
||||
}
|
||||
v2Decisions.Deleted = append(v2Decisions.Deleted, partialDecisions...)
|
||||
|
@ -210,7 +212,7 @@ func (s *DecisionsService) GetDecisionsFromBlocklist(ctx context.Context, blockl
|
|||
Type: blocklist.Remediation,
|
||||
Value: &decision,
|
||||
Duration: blocklist.Duration,
|
||||
Origin: types.StrPtr(types.ListOrigin),
|
||||
Origin: ptr.Of(types.ListOrigin),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/crowdsecurity/go-cs-lib/pkg/ptr"
|
||||
"github.com/crowdsecurity/go-cs-lib/pkg/version"
|
||||
|
||||
"github.com/crowdsecurity/crowdsec/pkg/models"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/modelscapi"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/types"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -461,7 +461,7 @@ func TestDecisionsFromBlocklist(t *testing.T) {
|
|||
Remediation: &tremediationBlocklist,
|
||||
Name: &tnameBlocklist,
|
||||
Duration: &tdurationBlocklist,
|
||||
}, types.StrPtr("Sun, 01 Jan 2023 01:01:01 GMT"))
|
||||
}, ptr.Of("Sun, 01 Jan 2023 01:01:01 GMT"))
|
||||
require.NoError(t, err)
|
||||
assert.False(t, isModified)
|
||||
_, isModified, err = newcli.Decisions.GetDecisionsFromBlocklist(context.Background(), &modelscapi.BlocklistLink{
|
||||
|
@ -470,7 +470,7 @@ func TestDecisionsFromBlocklist(t *testing.T) {
|
|||
Remediation: &tremediationBlocklist,
|
||||
Name: &tnameBlocklist,
|
||||
Duration: &tdurationBlocklist,
|
||||
}, types.StrPtr("Mon, 02 Jan 2023 01:01:01 GMT"))
|
||||
}, ptr.Of("Mon, 02 Jan 2023 01:01:01 GMT"))
|
||||
require.NoError(t, err)
|
||||
assert.True(t, isModified)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue