Skip to content

Commit

Permalink
fix: remove unnecessary nesting in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
micovery committed Apr 11, 2024
1 parent fda37da commit 6925fcd
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 169 deletions.
65 changes: 30 additions & 35 deletions examples/templates/graphql/apiproxy.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
APIProxy:
.revision: 1
.name: {{ $.Values.name }}
.name: {{ $.Values.api_name }}
.@:
DisplayName: {{ $.Values.name }}
DisplayName: {{ $.Values.api_name }}
Description: {{ $.Schema.Description }}
Policies:
#{{- os_copyfile "./policies.yaml" "./policies.yaml" | blank }}
$ref: ./policies.yaml#/
ProxyEndpoints:
- ProxyEndpoint:
.name: default
.@:
PreFlow:
.name: PreFlow
Request:
- Step:
Name: GraphQL-Verify
Flows:
- Flow:
.name: graphQLPost
.@:
Condition: (proxy.pathsuffix MatchesPath "{{ $.Values.base_path }}") and (request.verb = "POST")
- Flow:
.name: graphQLGet
.@:
Condition: (proxy.pathsuffix MatchesPath "{{ $.Values.base_path }}") and (request.verb = "GET")
- Flow:
.name: CatchAll
Request:
- Step:
- Name: RF-CatchAll
HTTPProxyConnection:
BasePath: {{ $.Values.base_path }}
RouteRule:
.name: default
.@:
TargetEndpoint: default
PreFlow:
.name: PreFlow
Request:
- Step:
Name: GraphQL-Verify
Flows:
- Flow:
.name: graphQLPost
Condition: (proxy.pathsuffix MatchesPath "{{ $.Values.base_path }}") and (request.verb = "POST")
- Flow:
.name: graphQLGet
Condition: (proxy.pathsuffix MatchesPath "{{ $.Values.base_path }}") and (request.verb = "GET")
- Flow:
.name: CatchAll
Request:
- Step:
Name: RF-CatchAll
HTTPProxyConnection:
BasePath: {{ $.Values.base_path }}
RouteRule:
.name: default
TargetEndpoint: default
TargetEndpoints:
- TargetEndpoint:
.name: default
.@:
HTTPTargetConnection:
SSLInfo:
Enabled: true
Enforce: true
IgnoreValidationErrors: true
URL: {{ $.Values.target_url }}
HTTPTargetConnection:
SSLInfo:
Enabled: true
Enforce: true
IgnoreValidationErrors: true
URL: {{ $.Values.target_url }}
Resources:
- Resource:
Type: graphql
Expand Down
44 changes: 20 additions & 24 deletions examples/templates/graphql/policies.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
- GraphQL:
.name: GQL-Verify
.@:
Source: request
OperationType: query_mutation
MaxDepth: 4
MaxCount: 4
Action: parse_verify
ResourceURL: graphql://schema.graphql
Source: request
OperationType: query_mutation
MaxDepth: 4
MaxCount: 4
Action: parse_verify
ResourceURL: graphql://schema.graphql
- RaiseFault:
.continueOnError: false
.enabled: true
.name: RF-CatchAll
.@:
DisplayName: RF-CatchAll
Properties: {}
FaultResponse:
Set:
Headers: {}
Payload:
.contentType: application/json
.@: |-
{
"status": 404
"error": "NotFound"
"message": "resource not found"
}
StatusCode: 404
ReasonPhrase: Not found
IgnoreUnresolvedVariables: true
DisplayName: RF-CatchAll
FaultResponse:
Set:
Payload:
.contentType: application/json
.@: |-
{
"status": 404
"error": "NotFound"
"message": "resource not found"
}
StatusCode: 404
ReasonPhrase: Not found
IgnoreUnresolvedVariables: true
54 changes: 25 additions & 29 deletions examples/templates/grpc/apiproxy.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
APIProxy:
.revision: 1
.name: {{ include "get_api_name" $.Proto }}
.@:
DisplayName: {{ include "get_api_name" $.Proto }}
Description: API Proxy generated from proto file
DisplayName: {{ include "get_api_name" $.Proto }}
Description: API Proxy generated from proto file
Policies:
#{{- os_copyfile "./policies.yaml" "./policies.yaml" | blank }}
$ref: ./policies.yaml#/
ProxyEndpoints:
- ProxyEndpoint:
.name: default
.@:
Flows:
#{{- range $i,$service := $.Proto.Service }}
#{{- range $j,$method := $service.Method }}
- Flow:
.name: {{ $method.Name }}
.@:
Condition: (proxy.pathsuffix MatchesPath "/{{ $method.Name }}") and (request.verb = "POST")
#{{- end }}
Flows:
#{{- range $i,$service := $.Proto.Service }}
#{{- range $j,$method := $service.Method }}
- Flow:
.name: {{ $method.Name }}
Condition: (proxy.pathsuffix MatchesPath "/{{ $method.Name }}") and (request.verb = "POST")
#{{- end }}
- Flow:
.name: CatchAll
.@:
- Step:
- Name: RF-CatchAll
HTTPProxyConnection:
BasePath: {{ include "get_basepath" $.Proto }}
RouteRule:
.name: default
.@:
TargetEndpoint: default
#{{- end }}
- Flow:
.name: CatchAll
Request:
- Step:
Name: RF-CatchAll
HTTPProxyConnection:
BasePath: {{ include "get_basepath" $.Proto }}
RouteRule:
.name: default
TargetEndpoint: default
TargetEndpoints:
- TargetEndpoint:
.name: default
.@:
Path: {{ include "get_basepath" $.Proto }}
LoadBalancer:
Servers:
- Server:
.name: {{ $.Values.target_server }}
HTTPTargetConnection:
Path: {{ include "get_basepath" $.Proto }}
LoadBalancer:
Servers:
- Server:
.name: {{ $.Values.target_server }}
31 changes: 14 additions & 17 deletions examples/templates/grpc/policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
.continueOnError: false
.enabled: true
.name: RF-CatchAll
.@:
DisplayName: RF-CatchAll
Properties: {}
FaultResponse:
Set:
Headers: {}
Payload:
.contentType: application/json
.@: |-
{
"status": 404
"error": "NotFound"
"message": "resource not found"
}
StatusCode: 404
ReasonPhrase: Not found
IgnoreUnresolvedVariables: true
DisplayName: RF-CatchAll
FaultResponse:
Set:
Payload:
.contentType: application/json
.@: |-
{
"status": 404
"error": "NotFound"
"message": "resource not found"
}
StatusCode: 404
ReasonPhrase: Not found
IgnoreUnresolvedVariables: true
79 changes: 37 additions & 42 deletions examples/templates/oas3/apiproxy.yaml
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
APIProxy:
.revision: 1
.name: {{ .OAS3 | dig "info" "x-serviceName" .OAS3.info.title }}
.@:
DisplayName: {{ .OAS3.info.title }}
Description: {{ .OAS3.info.description }}
DisplayName: {{ .OAS3.info.title }}
Description: {{ .OAS3.info.description }}
Policies:
#{{- os_copyfile "./policies.yaml" "./policies.yaml" | blank }}
$ref: ./policies.yaml#/
ProxyEndpoints:
- ProxyEndpoint:
.name: default
.@:
PreFlow:
.name: PreFlow
Request:
- Step:
Name: OAS-Validate
Flows:
#{{- range $path, $pathItem := .OAS3.paths }}
#{{- range $verb, $opItem := $pathItem }}
#{{- if eq (include "get_visibility" $opItem) "INTERNAL" }}
#{{- fmt_printf "Skipping internal operation '%s' (%s %s)\n" $opItem.operationId $verb $path }}
#{{- continue }}
#{{- end }}
- Flow:
.name: {{ $opItem.operationId }}
.@:
Condition: (proxy.pathsuffix MatchesPath "{{ regexReplaceAll "{[^}]*}" $path "*" }}") and (request.verb = "{{ $verb | upper }}")
#{{- end }}
PreFlow:
.name: PreFlow
Request:
- Step:
Name: OAS-Validate
Flows:
#{{- range $path, $pathItem := .OAS3.paths }}
#{{- range $verb, $opItem := $pathItem }}
#{{- if eq (include "get_visibility" $opItem) "INTERNAL" }}
#{{- fmt_printf "Skipping internal operation '%s' (%s %s)\n" $opItem.operationId $verb $path }}
#{{- continue }}
#{{- end }}
- Flow:
.name: {{ $opItem.operationId }}
Condition: (proxy.pathsuffix MatchesPath "{{ regexReplaceAll "{[^}]*}" $path "*" }}") and (request.verb = "{{ $verb | upper }}")
#{{- end }}
- Flow:
.name: CatchAll
Request:
- Step:
Name: RF-CatchAll
HTTPProxyConnection:
BasePath: {{ include "get_basepath" (index .OAS3.servers 0 "url") }}
RouteRule:
.name: default
.@:
TargetEndpoint: default
#{{- end }}
- Flow:
.name: CatchAll
Request:
- Step:
Name: RF-CatchAll
HTTPProxyConnection:
BasePath: {{ include "get_basepath" (index .OAS3.servers 0 "url") }}
RouteRule:
.name: default
TargetEndpoint: default
TargetEndpoints:
- TargetEndpoint:
.name: default
.@:
HTTPTargetConnection:
#{{- $scheme := include "get_scheme" (index .OAS3.servers 0 "url") }}
#{{- if eq $scheme "https" }}
SSLInfo:
Enabled: true
Enforce: true
IgnoreValidationErrors: true
#{{- end }}
URL: {{ include "get_target_url" .OAS3.servers }}
HTTPTargetConnection:
#{{- $scheme := include "get_scheme" (index .OAS3.servers 0 "url") }}
#{{- if eq $scheme "https" }}
SSLInfo:
Enabled: true
Enforce: true
IgnoreValidationErrors: true
#{{- end }}
URL: {{ include "get_target_url" .OAS3.servers }}
Resources:
- Resource:
Type: oas
Expand Down
39 changes: 17 additions & 22 deletions examples/templates/oas3/policies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@
.continueOnError: false
.enabled: true
.name: OAS-Validate
.@:
DisplayName: OAS-Validate
Properties: {}
Source: request
OASResource: oas://spec.yaml
DisplayName: OAS-Validate
Source: request
OASResource: oas://spec.yaml
- RaiseFault:
.continueOnError: false
.enabled: true
.name: RF-CatchAll
.@:
DisplayName: RF-CatchAll
Properties: {}
FaultResponse:
Set:
Headers: {}
Payload:
.contentType: application/json
.@: |-
{
"status": 404
"error": "NotFound"
"message": "resource not found"
}
StatusCode: 404
ReasonPhrase: Not found
IgnoreUnresolvedVariables: true
DisplayName: RF-CatchAll
FaultResponse:
Set:
Payload:
.contentType: application/json
.@: |-
{
"status": 404
"error": "NotFound"
"message": "resource not found"
}
StatusCode: 404
ReasonPhrase: Not found
IgnoreUnresolvedVariables: true

0 comments on commit 6925fcd

Please sign in to comment.