Skip to content

Commit add7232

Browse files
Adding test + fixing OFREP issue (#1760)
Signed-off-by: Thomas Poignant <[email protected]>
1 parent 2a35d96 commit add7232

28 files changed

+512
-29
lines changed

cmd/relayproxy/controller/all_flags.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func NewAllFlags(goFF *ffclient.GoFeatureFlag, metrics metric.Metrics) Controlle
2626

2727
// Handler is the entry point for the allFlags endpoint
2828
// @Summary All flags variations for a user
29+
// @Tags GO Feature Flag Evaluation API
2930
// @Description Making a **POST** request to the URL `/v1/allflags` will give you the values of all the flags for
3031
// @Description this user.
3132
// @Description

cmd/relayproxy/controller/collect_eval_data.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func NewCollectEvalData(goFF *ffclient.GoFeatureFlag, metrics metric.Metrics) Co
2828

2929
// Handler is the entry point for the data/collector endpoint
3030
// @Summary Endpoint to send usage of your flags to be collected
31+
// @Tags GO Feature Flag Evaluation API
3132
// @Description This endpoint is receiving the events of your flags usage to send them in the data collector.
3233
// @Description
3334
// @Description It is used by the different Open Feature providers to send in bulk all the cached events to avoid

cmd/relayproxy/controller/flag_eval.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func NewFlagEval(goFF *ffclient.GoFeatureFlag, metrics metric.Metrics) Controlle
2727

2828
// Handler is the entry point for the flag eval endpoint
2929
// @Summary Evaluate a feature flag
30+
// @Tags GO Feature Flag Evaluation API
3031
// @Description Making a **POST** request to the URL `/v1/feature/<your_flag_name>/eval` will give you the value of the
3132
// @Description flag for this user.
3233
// @Description

cmd/relayproxy/controller/health.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func NewHealth(monitoring service.Monitoring) Controller {
2020

2121
// Handler is the entry point for this API
2222
// @Summary Health
23+
// @Tags Monitoring
2324
// @Description Making a **GET** request to the URL path `/health` will tell you if the relay proxy is ready to serve
2425
// @Description traffic.
2526
// @Description

cmd/relayproxy/controller/info.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func NewInfo(monitoring service.Monitoring) Controller {
1919

2020
// Handler is the entry point for the Info API
2121
// @Summary Info
22+
// @Tags Monitoring
2223
// @Description Making a **GET** request to the URL path `/info` will give you information about the actual state
2324
// @Description of the relay proxy.
2425
// @Description

cmd/relayproxy/controller/ws_flag_change.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type wsFlagChange struct {
3232

3333
// Handler is the entry point for the websocket endpoint to get notified when a flag has been edited
3434
// @Summary Websocket endpoint to be notified about flag changes
35+
// @Tags GO Feature Flag Evaluation API
3536
// @Description This endpoint is a websocket endpoint to be notified about flag changes, every change
3637
// @Description will send a request to the client with a model.DiffCache format.
3738
// @Description

cmd/relayproxy/docs/docs.go

+27
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const docTemplate = `{
3232
"produces": [
3333
"application/json"
3434
],
35+
"tags": [
36+
"Monitoring"
37+
],
3538
"summary": "Health",
3639
"responses": {
3740
"200": {
@@ -49,6 +52,9 @@ const docTemplate = `{
4952
"produces": [
5053
"application/json"
5154
],
55+
"tags": [
56+
"Monitoring"
57+
],
5258
"summary": "Info",
5359
"responses": {
5460
"200": {
@@ -66,6 +72,9 @@ const docTemplate = `{
6672
"produces": [
6773
"text/plain"
6874
],
75+
"tags": [
76+
"Monitoring"
77+
],
6978
"summary": "Prometheus endpoint",
7079
"responses": {
7180
"200": {
@@ -91,6 +100,9 @@ const docTemplate = `{
91100
"produces": [
92101
"application/json"
93102
],
103+
"tags": [
104+
"OpenFeature Remote Evaluation Protocol (OFREP)"
105+
],
94106
"summary": "Open-Feature Remote Evaluation Protocol bulk evaluation API.",
95107
"parameters": [
96108
{
@@ -157,6 +169,9 @@ const docTemplate = `{
157169
"produces": [
158170
"application/json"
159171
],
172+
"tags": [
173+
"OpenFeature Remote Evaluation Protocol (OFREP)"
174+
],
160175
"summary": "Evaluate a feature flag using the OpenFeature Remote Evaluation Protocol",
161176
"parameters": [
162177
{
@@ -224,6 +239,9 @@ const docTemplate = `{
224239
"produces": [
225240
"application/json"
226241
],
242+
"tags": [
243+
"GO Feature Flag Evaluation API"
244+
],
227245
"summary": "All flags variations for a user",
228246
"parameters": [
229247
{
@@ -272,6 +290,9 @@ const docTemplate = `{
272290
"produces": [
273291
"application/json"
274292
],
293+
"tags": [
294+
"GO Feature Flag Evaluation API"
295+
],
275296
"summary": "Endpoint to send usage of your flags to be collected",
276297
"parameters": [
277298
{
@@ -320,6 +341,9 @@ const docTemplate = `{
320341
"produces": [
321342
"application/json"
322343
],
344+
"tags": [
345+
"GO Feature Flag Evaluation API"
346+
],
323347
"summary": "Evaluate a feature flag",
324348
"parameters": [
325349
{
@@ -370,6 +394,9 @@ const docTemplate = `{
370394
"produces": [
371395
"application/json"
372396
],
397+
"tags": [
398+
"GO Feature Flag Evaluation API"
399+
],
373400
"summary": "Websocket endpoint to be notified about flag changes",
374401
"parameters": [
375402
{

cmd/relayproxy/docs/swagger.json

+27
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"produces": [
2525
"application/json"
2626
],
27+
"tags": [
28+
"Monitoring"
29+
],
2730
"summary": "Health",
2831
"responses": {
2932
"200": {
@@ -41,6 +44,9 @@
4144
"produces": [
4245
"application/json"
4346
],
47+
"tags": [
48+
"Monitoring"
49+
],
4450
"summary": "Info",
4551
"responses": {
4652
"200": {
@@ -58,6 +64,9 @@
5864
"produces": [
5965
"text/plain"
6066
],
67+
"tags": [
68+
"Monitoring"
69+
],
6170
"summary": "Prometheus endpoint",
6271
"responses": {
6372
"200": {
@@ -83,6 +92,9 @@
8392
"produces": [
8493
"application/json"
8594
],
95+
"tags": [
96+
"OpenFeature Remote Evaluation Protocol (OFREP)"
97+
],
8698
"summary": "Open-Feature Remote Evaluation Protocol bulk evaluation API.",
8799
"parameters": [
88100
{
@@ -149,6 +161,9 @@
149161
"produces": [
150162
"application/json"
151163
],
164+
"tags": [
165+
"OpenFeature Remote Evaluation Protocol (OFREP)"
166+
],
152167
"summary": "Evaluate a feature flag using the OpenFeature Remote Evaluation Protocol",
153168
"parameters": [
154169
{
@@ -216,6 +231,9 @@
216231
"produces": [
217232
"application/json"
218233
],
234+
"tags": [
235+
"GO Feature Flag Evaluation API"
236+
],
219237
"summary": "All flags variations for a user",
220238
"parameters": [
221239
{
@@ -264,6 +282,9 @@
264282
"produces": [
265283
"application/json"
266284
],
285+
"tags": [
286+
"GO Feature Flag Evaluation API"
287+
],
267288
"summary": "Endpoint to send usage of your flags to be collected",
268289
"parameters": [
269290
{
@@ -312,6 +333,9 @@
312333
"produces": [
313334
"application/json"
314335
],
336+
"tags": [
337+
"GO Feature Flag Evaluation API"
338+
],
315339
"summary": "Evaluate a feature flag",
316340
"parameters": [
317341
{
@@ -362,6 +386,9 @@
362386
"produces": [
363387
"application/json"
364388
],
389+
"tags": [
390+
"GO Feature Flag Evaluation API"
391+
],
365392
"summary": "Websocket endpoint to be notified about flag changes",
366393
"parameters": [
367394
{

cmd/relayproxy/docs/swagger.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ paths:
386386
schema:
387387
$ref: '#/definitions/model.HealthResponse'
388388
summary: Health
389+
tags:
390+
- Monitoring
389391
/info:
390392
get:
391393
description: |-
@@ -402,6 +404,8 @@ paths:
402404
schema:
403405
$ref: '#/definitions/model.InfoResponse'
404406
summary: Info
407+
tags:
408+
- Monitoring
405409
/metrics:
406410
get:
407411
description: This endpoint is providing metrics about the relay proxy in the
@@ -414,6 +418,8 @@ paths:
414418
schema:
415419
type: string
416420
summary: Prometheus endpoint
421+
tags:
422+
- Monitoring
417423
/ofrep/v1/evaluate/flags:
418424
post:
419425
consumes:
@@ -460,6 +466,8 @@ paths:
460466
security:
461467
- ApiKeyAuth: []
462468
summary: Open-Feature Remote Evaluation Protocol bulk evaluation API.
469+
tags:
470+
- OpenFeature Remote Evaluation Protocol (OFREP)
463471
/ofrep/v1/evaluate/flags/{flag_key}:
464472
post:
465473
consumes:
@@ -505,6 +513,8 @@ paths:
505513
security:
506514
- ApiKeyAuth: []
507515
summary: Evaluate a feature flag using the OpenFeature Remote Evaluation Protocol
516+
tags:
517+
- OpenFeature Remote Evaluation Protocol (OFREP)
508518
/v1/allflags:
509519
post:
510520
consumes:
@@ -540,6 +550,8 @@ paths:
540550
security:
541551
- ApiKeyAuth: []
542552
summary: All flags variations for a user
553+
tags:
554+
- GO Feature Flag Evaluation API
543555
/v1/data/collector:
544556
post:
545557
consumes:
@@ -574,6 +586,8 @@ paths:
574586
security:
575587
- ApiKeyAuth: []
576588
summary: Endpoint to send usage of your flags to be collected
589+
tags:
590+
- GO Feature Flag Evaluation API
577591
/v1/feature/{flag_key}/eval:
578592
post:
579593
consumes:
@@ -619,6 +633,8 @@ paths:
619633
security:
620634
- ApiKeyAuth: []
621635
summary: Evaluate a feature flag
636+
tags:
637+
- GO Feature Flag Evaluation API
622638
/ws/v1/flag/change:
623639
post:
624640
consumes:
@@ -647,6 +663,8 @@ paths:
647663
schema:
648664
$ref: '#/definitions/modeldocs.HTTPErrorDoc'
649665
summary: Websocket endpoint to be notified about flag changes
666+
tags:
667+
- GO Feature Flag Evaluation API
650668
securityDefinitions:
651669
ApiKeyAuth:
652670
description: Use configured APIKeys in yaml config as authorization keys, disabled

cmd/relayproxy/model/ofrep_error_response.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package model
22

3-
import "github.com/thomaspoignant/go-feature-flag/internal/flag"
3+
import (
4+
"fmt"
5+
"github.com/thomaspoignant/go-feature-flag/internal/flag"
6+
)
47

58
type OFREPEvaluateErrorResponse struct {
69
OFREPCommonErrorResponse `json:",inline" yaml:",inline" toml:",inline"`
@@ -11,3 +14,7 @@ type OFREPCommonErrorResponse struct {
1114
ErrorCode flag.ErrorCode `json:"errorCode"`
1215
ErrorDetails string `json:"errorDetails"`
1316
}
17+
18+
func (o *OFREPCommonErrorResponse) Error() string {
19+
return fmt.Sprintf("[%s] %s", o.ErrorCode, o.ErrorDetails)
20+
}

cmd/relayproxy/model/ofrep_success_response.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ type OFREPEvaluateSuccessResponse struct {
55
Value any `json:"value"`
66
Reason string `json:"reason"`
77
Variant string `json:"variant"`
8-
Metadata map[string]any `json:"metadata"`
8+
Metadata map[string]any `json:"metadata,omitempty"`
99
}

cmd/relayproxy/modeldocs/metricsController.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "github.com/labstack/echo/v4"
55
// FakeMetricsController is the entry point for the allFlags endpoint
66
//
77
// @Summary Prometheus endpoint
8+
// @Tags Monitoring
89
// @Description This endpoint is providing metrics about the relay proxy in the prometheus format.
910
// @Produce plain
1011
// @Success 200 {object} string

0 commit comments

Comments
 (0)