Skip to content

Commit

Permalink
feat(OFREP): return unsupported types field (#1846)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspoignant committed Aug 16, 2024
1 parent 241564c commit 86bc58f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
14 changes: 14 additions & 0 deletions cmd/relayproxy/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@ const docTemplate = `{
"properties": {
"cacheInvalidation": {
"$ref": "#/definitions/model.OFREPConfigCapabilitiesCacheInvalidation"
},
"flagEvaluation": {
"$ref": "#/definitions/model.OFREPConfigCapabilitiesFlagEvaluation"
}
}
},
Expand All @@ -757,6 +760,17 @@ const docTemplate = `{
}
}
},
"model.OFREPConfigCapabilitiesFlagEvaluation": {
"type": "object",
"properties": {
"unsupportedTypes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"model.OFREPConfiguration": {
"type": "object",
"properties": {
Expand Down
14 changes: 14 additions & 0 deletions cmd/relayproxy/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@
"properties": {
"cacheInvalidation": {
"$ref": "#/definitions/model.OFREPConfigCapabilitiesCacheInvalidation"
},
"flagEvaluation": {
"$ref": "#/definitions/model.OFREPConfigCapabilitiesFlagEvaluation"
}
}
},
Expand All @@ -749,6 +752,17 @@
}
}
},
"model.OFREPConfigCapabilitiesFlagEvaluation": {
"type": "object",
"properties": {
"unsupportedTypes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"model.OFREPConfiguration": {
"type": "object",
"properties": {
Expand Down
9 changes: 9 additions & 0 deletions cmd/relayproxy/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ definitions:
properties:
cacheInvalidation:
$ref: '#/definitions/model.OFREPConfigCapabilitiesCacheInvalidation'
flagEvaluation:
$ref: '#/definitions/model.OFREPConfigCapabilitiesFlagEvaluation'
type: object
model.OFREPConfigCapabilitiesCacheInvalidation:
properties:
Expand All @@ -203,6 +205,13 @@ definitions:
minPollingInterval:
type: integer
type: object
model.OFREPConfigCapabilitiesFlagEvaluation:
properties:
unsupportedTypes:
items:
type: string
type: array
type: object
model.OFREPConfiguration:
properties:
capabilities:
Expand Down
4 changes: 4 additions & 0 deletions cmd/relayproxy/model/ofrep_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ type OFREPConfiguration struct {

type OFREPConfigCapabilities struct {
CacheInvalidation OFREPConfigCapabilitiesCacheInvalidation `json:"cacheInvalidation,omitempty"`
FlagEvaluation OFREPConfigCapabilitiesFlagEvaluation `json:"flagEvaluation,omitempty"`
}

type OFREPConfigCapabilitiesCacheInvalidation struct {
Polling OFREPConfigCapabilitiesCacheInvalidationPolling `json:"polling,omitempty"`
}
type OFREPConfigCapabilitiesFlagEvaluation struct {
UnsupportedTypes []string `json:"unsupportedTypes"`
}

type OFREPConfigCapabilitiesCacheInvalidationPolling struct {
Enabled bool `json:"enabled,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions cmd/relayproxy/ofrep/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (h *EvaluateCtrl) Configuration(c echo.Context) error {
MinPollingInterval: h.goFF.GetPollingInterval(),
},
},
FlagEvaluation: model.OFREPConfigCapabilitiesFlagEvaluation{UnsupportedTypes: []string{}},
},
}
return c.JSON(http.StatusOK, response)
Expand Down
4 changes: 2 additions & 2 deletions cmd/relayproxy/ofrep/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ func Test_Configuration(t *testing.T) {
goffPolling: 10 * time.Second,
want: want{
httpCode: http.StatusOK,
response: "{\"name\":\"GO Feature Flag\",\"capabilities\":{\"cacheInvalidation\":{\"polling\":{\"enabled\":true,\"minPollingInterval\":10000}}}}",
response: "{\"name\":\"GO Feature Flag\",\"capabilities\":{\"cacheInvalidation\":{\"polling\":{\"enabled\":true,\"minPollingInterval\":10000}},\"flagEvaluation\":{\"unsupportedTypes\":[]}}}",
},
},
{
name: "configuration 10 minute",
goffPolling: 10 * time.Minute,
want: want{
httpCode: http.StatusOK,
response: "{\"name\":\"GO Feature Flag\",\"capabilities\":{\"cacheInvalidation\":{\"polling\":{\"enabled\":true,\"minPollingInterval\":600000}}}}",
response: "{\"name\":\"GO Feature Flag\",\"capabilities\":{\"cacheInvalidation\":{\"polling\":{\"enabled\":true,\"minPollingInterval\":600000}},\"flagEvaluation\":{\"unsupportedTypes\":[]}}}",
},
},
}
Expand Down

0 comments on commit 86bc58f

Please sign in to comment.