Skip to content

Commit a3dc6a3

Browse files
author
Marek Dalewski
authored
change: introduce ordering to query filter enums (#251)
## What Introduce order (base on declaration of individual enum values) to query filter enums. ## Why To allow slices of those enum values to be orderable, so in all places in the system they look and behave the same. ## References - [AT-2744](https://jira.greenbone.net/browse/AT-2744) - [AT-2806](https://jira.greenbone.net/browse/AT-2806) ## Checklist - [x] Tests _(newly added code have 100% tests coverage)_
1 parent f21fd55 commit a3dc6a3

30 files changed

Lines changed: 985 additions & 439 deletions

File tree

go.mod

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ require (
3131
dario.cat/mergo v1.0.2 // indirect
3232
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
3333
github.com/KyleBanks/depth v1.2.1 // indirect
34+
github.com/Masterminds/goutils v1.1.1 // indirect
35+
github.com/Masterminds/semver/v3 v3.3.0 // indirect
36+
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
3437
github.com/Microsoft/go-winio v0.6.2 // indirect
38+
github.com/abice/go-enum v0.9.2 // indirect
3539
github.com/bytedance/gopkg v0.1.3 // indirect
3640
github.com/bytedance/sonic v1.14.1 // indirect
3741
github.com/bytedance/sonic/loader v0.3.0 // indirect
@@ -42,6 +46,7 @@ require (
4246
github.com/containerd/log v0.1.0 // indirect
4347
github.com/containerd/platforms v0.2.1 // indirect
4448
github.com/cpuguy83/dockercfg v0.3.2 // indirect
49+
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
4550
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4651
github.com/distribution/reference v0.6.0 // indirect
4752
github.com/docker/docker v28.5.1+incompatible // indirect
@@ -72,7 +77,9 @@ require (
7277
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
7378
github.com/goccy/go-json v0.10.5 // indirect
7479
github.com/goccy/go-yaml v1.18.0 // indirect
80+
github.com/golang/mock v1.6.0 // indirect
7581
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
82+
github.com/huandu/xstrings v1.5.0 // indirect
7683
github.com/jackc/pgpassfile v1.0.0 // indirect
7784
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
7885
github.com/jackc/pgx/v5 v5.7.6 // indirect
@@ -81,12 +88,16 @@ require (
8188
github.com/jinzhu/now v1.1.5 // indirect
8289
github.com/klauspost/compress v1.18.1 // indirect
8390
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
91+
github.com/labstack/gommon v0.4.2 // indirect
8492
github.com/leodido/go-urn v1.4.0 // indirect
8593
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
8694
github.com/magiconair/properties v1.8.10 // indirect
8795
github.com/mattn/go-colorable v0.1.14 // indirect
8896
github.com/mattn/go-isatty v0.0.20 // indirect
8997
github.com/mattn/go-sqlite3 v1.14.32 // indirect
98+
github.com/mattn/goveralls v0.0.12 // indirect
99+
github.com/mitchellh/copystructure v1.2.0 // indirect
100+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
90101
github.com/moby/docker-image-spec v1.3.1 // indirect
91102
github.com/moby/go-archive v0.1.0 // indirect
92103
github.com/moby/patternmatcher v0.6.0 // indirect
@@ -105,8 +116,10 @@ require (
105116
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
106117
github.com/quic-go/qpack v0.5.1 // indirect
107118
github.com/quic-go/quic-go v0.55.0 // indirect
119+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
108120
github.com/sagikazarmark/locafero v0.12.0 // indirect
109121
github.com/shirou/gopsutil/v4 v4.25.9 // indirect
122+
github.com/shopspring/decimal v1.4.0 // indirect
110123
github.com/sirupsen/logrus v1.9.3 // indirect
111124
github.com/spf13/afero v1.15.0 // indirect
112125
github.com/spf13/cast v1.10.0 // indirect
@@ -117,6 +130,8 @@ require (
117130
github.com/tklauser/numcpus v0.10.0 // indirect
118131
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
119132
github.com/ugorji/go/codec v1.3.0 // indirect
133+
github.com/urfave/cli/v2 v2.27.7 // indirect
134+
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
120135
github.com/yusufpapurcu/wmi v1.2.4 // indirect
121136
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
122137
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
@@ -133,9 +148,11 @@ require (
133148
golang.org/x/net v0.46.0 // indirect
134149
golang.org/x/sync v0.17.0 // indirect
135150
golang.org/x/sys v0.37.0 // indirect
151+
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect
136152
golang.org/x/text v0.30.0 // indirect
137153
golang.org/x/time v0.14.0 // indirect
138154
golang.org/x/tools v0.38.0 // indirect
155+
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect
139156
google.golang.org/protobuf v1.36.10 // indirect
140157
gopkg.in/yaml.v3 v3.0.1 // indirect
141158
)

go.sum

Lines changed: 83 additions & 0 deletions
Large diffs are not rendered by default.

pkg/configReader/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import "github.com/greenbone/opensight-golang-libraries/pkg/configReader"
6767

6868

6969
<a name="ReadEnvVarsIntoStruct"></a>
70-
## func [ReadEnvVarsIntoStruct](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/configReader/configReader.go#L21>)
70+
## func ReadEnvVarsIntoStruct
7171

7272
```go
7373
func ReadEnvVarsIntoStruct(s any) (any, error)

pkg/dbcrypt/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import "github.com/greenbone/opensight-golang-libraries/pkg/dbcrypt"
8181

8282

8383
<a name="Decrypt"></a>
84-
## func [Decrypt](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/dbcrypt/dbcrypt.go#L107>)
84+
## func Decrypt
8585

8686
```go
8787
func Decrypt(encrypted string, key []byte) (string, error)
@@ -90,7 +90,7 @@ func Decrypt(encrypted string, key []byte) (string, error)
9090

9191

9292
<a name="Encrypt"></a>
93-
## func [Encrypt](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/dbcrypt/dbcrypt.go#L85>)
93+
## func Encrypt
9494

9595
```go
9696
func Encrypt(plaintext string, key []byte) (string, error)
@@ -99,7 +99,7 @@ func Encrypt(plaintext string, key []byte) (string, error)
9999

100100

101101
<a name="DBCrypt"></a>
102-
## type [DBCrypt](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/dbcrypt/dbcrypt.go#L26-L28>)
102+
## type DBCrypt
103103

104104

105105

@@ -110,7 +110,7 @@ type DBCrypt[T any] struct {
110110
```
111111

112112
<a name="DBCrypt[T].DecryptStruct"></a>
113-
### func \(\*DBCrypt\[T\]\) [DecryptStruct](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/dbcrypt/dbcrypt.go#L67>)
113+
### func \(\*DBCrypt\[T\]\) DecryptStruct
114114

115115
```go
116116
func (d *DBCrypt[T]) DecryptStruct(data *T) error
@@ -119,7 +119,7 @@ func (d *DBCrypt[T]) DecryptStruct(data *T) error
119119
DecryptStruct decrypts all fields of a struct that are tagged with \`encrypt:"true"\`
120120

121121
<a name="DBCrypt[T].EncryptStruct"></a>
122-
### func \(\*DBCrypt\[T\]\) [EncryptStruct](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/dbcrypt/dbcrypt.go#L43>)
122+
### func \(\*DBCrypt\[T\]\) EncryptStruct
123123

124124
```go
125125
func (d *DBCrypt[T]) EncryptStruct(data *T) error

pkg/errorResponses/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var ErrorInternalResponse = ErrorResponse{
4545
```
4646

4747
<a name="ErrorResponse"></a>
48-
## type [ErrorResponse](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/errorResponses/errorResponses.go#L10-L15>)
48+
## type ErrorResponse
4949

5050

5151

@@ -59,7 +59,7 @@ type ErrorResponse struct {
5959
```
6060

6161
<a name="NewErrorGenericResponse"></a>
62-
### func [NewErrorGenericResponse](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/errorResponses/errorResponses.go#L33>)
62+
### func NewErrorGenericResponse
6363

6464
```go
6565
func NewErrorGenericResponse(message ...any) ErrorResponse
@@ -68,7 +68,7 @@ func NewErrorGenericResponse(message ...any) ErrorResponse
6868
NewErrorGenericResponse returns a [ErrorResponse](<#ErrorResponse>) of type Generic with the given error message. The message is handled the same as [fmt.Println](<https://pkg.go.dev/fmt/#Println>).
6969

7070
<a name="NewErrorValidationResponse"></a>
71-
### func [NewErrorValidationResponse](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/errorResponses/errorResponses.go#L41>)
71+
### func NewErrorValidationResponse
7272

7373
```go
7474
func NewErrorValidationResponse(title, details string, errors map[string]string) ErrorResponse

pkg/jobQueue/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Package jobQueue provides a thread\-safe queue of requests to execute a predefin
8383

8484

8585
<a name="JobQueue"></a>
86-
## type [JobQueue](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/jobQueue/jobQueue.go#L20-L25>)
86+
## type JobQueue
8787

8888
JobQueue is a thread\-safe queue of requests to execute a predefined function.
8989

@@ -94,7 +94,7 @@ type JobQueue struct {
9494
```
9595

9696
<a name="NewJobQueue"></a>
97-
### func [NewJobQueue](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/jobQueue/jobQueue.go#L30>)
97+
### func NewJobQueue
9898

9999
```go
100100
func NewJobQueue(execFunc func() error, context context.Context) *JobQueue
@@ -103,7 +103,7 @@ func NewJobQueue(execFunc func() error, context context.Context) *JobQueue
103103
NewJobQueue creates a new job queue execFunc is the function to be executed for each request that is processed context is the context of the caller
104104

105105
<a name="JobQueue.AddQueueRequest"></a>
106-
### func \(\*JobQueue\) [AddQueueRequest](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/jobQueue/jobQueue.go#L49>)
106+
### func \(\*JobQueue\) AddQueueRequest
107107

108108
```go
109109
func (q *JobQueue) AddQueueRequest(req Request)
@@ -116,7 +116,7 @@ The job queue is designed to be used in situations where multiple requests of th
116116
If a request is added to the queue while another request is being processed, the new request will be added to the queue and processed after the current request has finished. If there is already a request in the queue, the old request will be considered obsolete and replaced by the new request. \[jobQueue\_test.go\]\(jobQueue\_test.go\) illustrates this behaviour.
117117

118118
<a name="Request"></a>
119-
## type [Request](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/jobQueue/jobQueue.go#L15-L17>)
119+
## type Request
120120

121121
Request is a request to be processed by the queue and allows to provide an ID for identification
122122

pkg/logs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const (
4040
```
4141

4242
<a name="Ctx"></a>
43-
## func [Ctx](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/logs.go#L61>)
43+
## func Ctx
4444

4545
```go
4646
func Ctx(ctx context.Context) *zerolog.Logger
@@ -49,7 +49,7 @@ func Ctx(ctx context.Context) *zerolog.Logger
4949
Ctx retrieves the zerolog logger from the given context. If the context does not have a logger attached, the global logger is returned instead.
5050

5151
<a name="SetupLogger"></a>
52-
## func [SetupLogger](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/logs.go#L49>)
52+
## func SetupLogger
5353

5454
```go
5555
func SetupLogger(logLevel string) error
@@ -77,7 +77,7 @@ if err != nil {
7777
```
7878

7979
<a name="WithCorrelationID"></a>
80-
## func [WithCorrelationID](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/logs.go#L105>)
80+
## func WithCorrelationID
8181

8282
```go
8383
func WithCorrelationID(ctx context.Context, correlationID string) context.Context
@@ -86,7 +86,7 @@ func WithCorrelationID(ctx context.Context, correlationID string) context.Contex
8686
WithCorrelationID adds a correlation ID to the logger in the context and returns the updated context.
8787

8888
<a name="WithCtxField"></a>
89-
## func [WithCtxField](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/logs.go#L87>)
89+
## func WithCtxField
9090

9191
```go
9292
func WithCtxField(ctx context.Context, key, value string) context.Context
@@ -113,7 +113,7 @@ ctx = WithCtxField(ctx, "request_id", "abc123")
113113
```
114114

115115
<a name="WithJob"></a>
116-
## func [WithJob](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/logs.go#L100>)
116+
## func WithJob
117117

118118
```go
119119
func WithJob(ctx context.Context, jobName string) context.Context
@@ -122,7 +122,7 @@ func WithJob(ctx context.Context, jobName string) context.Context
122122
WithJob adds a job name field to the logger in the context and returns the updated context.
123123

124124
<a name="WithNewCorrelationID"></a>
125-
## func [WithNewCorrelationID](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/logs.go#L111>)
125+
## func WithNewCorrelationID
126126

127127
```go
128128
func WithNewCorrelationID(ctx context.Context) context.Context

pkg/logs/ginMiddleware/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import "github.com/greenbone/opensight-golang-libraries/pkg/logs/ginMiddleware"
1414

1515

1616
<a name="Logging"></a>
17-
## func [Logging](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/logs/ginMiddleware/ginMiddleware.go#L27>)
17+
## func Logging
1818

1919
```go
2020
func Logging() gin.HandlerFunc

pkg/notifications/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Package Notifications provides a client to communicate with the OpenSight Notifi
2323

2424

2525
<a name="Client"></a>
26-
## type [Client](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/notification.go#L27-L34>)
26+
## type Client
2727

2828
Client can be used to send notifications
2929

@@ -34,7 +34,7 @@ type Client struct {
3434
```
3535

3636
<a name="NewClient"></a>
37-
### func [NewClient](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/notification.go#L56>)
37+
### func NewClient
3838

3939
```go
4040
func NewClient(httpClient *http.Client, config Config, authentication KeycloakAuthentication) *Client
@@ -43,7 +43,7 @@ func NewClient(httpClient *http.Client, config Config, authentication KeycloakAu
4343
NewClient returns a new [Client](<#Client>) with the notification service address \(host:port\) set. As httpClient you can use e.g. \[http.DefaultClient\].
4444

4545
<a name="Client.CreateNotification"></a>
46-
### func \(\*Client\) [CreateNotification](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/notification.go#L70>)
46+
### func \(\*Client\) CreateNotification
4747

4848
```go
4949
func (c *Client) CreateNotification(ctx context.Context, notification Notification) error
@@ -52,7 +52,7 @@ func (c *Client) CreateNotification(ctx context.Context, notification Notificati
5252
CreateNotification sends a notification to the notification service. It is retried up to the configured number of retries with an exponential backoff, So it can take some time until the functions returns.
5353

5454
<a name="Client.GetAuthenticationToken"></a>
55-
### func \(\*Client\) [GetAuthenticationToken](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/notification.go#L108>)
55+
### func \(\*Client\) GetAuthenticationToken
5656

5757
```go
5858
func (c *Client) GetAuthenticationToken(ctx context.Context) (string, error)
@@ -61,7 +61,7 @@ func (c *Client) GetAuthenticationToken(ctx context.Context) (string, error)
6161
GetAuthenticationToken retrieves an authentication token using client credentials. It constructs a form\-encoded request, sends it with retry logic, and parses the response.
6262

6363
<a name="Config"></a>
64-
## type [Config](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/notification.go#L37-L42>)
64+
## type Config
6565

6666
Config configures the notification service client
6767

@@ -75,7 +75,7 @@ type Config struct {
7575
```
7676

7777
<a name="KeycloakAuthentication"></a>
78-
## type [KeycloakAuthentication](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/notification.go#L46-L52>)
78+
## type KeycloakAuthentication
7979

8080
KeycloakAuthentication holds the credentials and configuration details required for Keycloak authentication in the notification service.
8181

@@ -90,7 +90,7 @@ type KeycloakAuthentication struct {
9090
```
9191

9292
<a name="Level"></a>
93-
## type [Level](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/model.go#L34>)
93+
## type Level
9494

9595
Level describes the severity of the notification
9696

@@ -109,7 +109,7 @@ const (
109109
```
110110

111111
<a name="Notification"></a>
112-
## type [Notification](<https://github.com/greenbone/opensight-golang-libraries/blob/main/pkg/notifications/model.go#L9-L18>)
112+
## type Notification
113113

114114

115115

0 commit comments

Comments
 (0)