Skip to content

Commit d57a80f

Browse files
kate-osbornsalonichf5
authored andcommitted
Apply configuration of SnippetsFilters to NGINX (#2604)
Problem: As a user of NGF, I want my SnippetsFilters configuration applied to NGF's data plane, so that I can leverage NGINX features not yet available in NGF. Solution: Apply configuration of valid SnippetsFilters referenced in HTTPRoutes and GRPCRoutes to the appropriate contexts in the NGINX config. If the SnippetsFilter referenced is invalid (wrong group or kind), the routing rule is not configured. If the SnippetsFilter cannot be resolved, the routing rule is configured, but the route will return a 500.
1 parent 0f2d400 commit d57a80f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

internal/mode/static/state/dataplane/configuration_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,42 @@ func TestBuildConfiguration(t *testing.T) {
23642364
}),
23652365
msg: "SnippetsFilters with main and http snippet",
23662366
},
2367+
{
2368+
graph: getModifiedGraph(func(g *graph.Graph) *graph.Graph {
2369+
g.SnippetsFilters = map[types.NamespacedName]*graph.SnippetsFilter{
2370+
client.ObjectKeyFromObject(sf1.Source): sf1,
2371+
client.ObjectKeyFromObject(sfNotReferenced.Source): sfNotReferenced,
2372+
}
2373+
2374+
return g
2375+
}),
2376+
expConf: getModifiedExpectedConfiguration(func(conf Configuration) Configuration {
2377+
conf.MainSnippets = []Snippet{
2378+
{
2379+
Name: createSnippetName(
2380+
ngfAPI.NginxContextMain,
2381+
client.ObjectKeyFromObject(sf1.Source),
2382+
),
2383+
Contents: "main snippet",
2384+
},
2385+
}
2386+
conf.BaseHTTPConfig.Snippets = []Snippet{
2387+
{
2388+
Name: createSnippetName(
2389+
ngfAPI.NginxContextHTTP,
2390+
client.ObjectKeyFromObject(sf1.Source),
2391+
),
2392+
Contents: "http snippet",
2393+
},
2394+
}
2395+
conf.HTTPServers = []VirtualServer{}
2396+
conf.SSLServers = []VirtualServer{}
2397+
conf.SSLKeyPairs = map[SSLKeyPairID]SSLKeyPair{}
2398+
2399+
return conf
2400+
}),
2401+
msg: "SnippetsFilters with main and http snippet",
2402+
},
23672403
}
23682404

23692405
for _, test := range tests {

0 commit comments

Comments
 (0)