@@ -200,7 +200,7 @@ func TestRunFunctionSimple(t *testing.T) {
200200 },
201201 },
202202 },
203- "ExtraResourcesClusterScoped " : {
203+ "ExtraResources " : {
204204 reason : "The Function should return the desired composite with extra resources." ,
205205 args : args {
206206 req : & fnv1.RunFunctionRequest {
@@ -211,11 +211,11 @@ func TestRunFunctionSimple(t *testing.T) {
211211 "metadata": {
212212 "name": "basic"
213213 },
214- "spec": {
215- "target": "Default",
216- "source": "items = [\n{\n apiVersion: \"meta.krm.kcl.dev/v1alpha1\"\n kind: \"ExtraResources\"\n requirements = {\n \"cool-extra-resource\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchName: \"cool-extra-resource\"\n }\n }\n},\n{\n apiVersion: \"meta.krm.kcl.dev/v1alpha1\"\n kind: \"ExtraResources\"\n requirements = {\n \"another-cool-extra-resource\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchLabels = {\n key: \"value\"\n }\n }\n \"yet-another-cool-extra-resource\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchName: \"foo\"\n }\n }\n},\n{\n apiVersion: \"meta.krm.kcl.dev/v1alpha1\"\n kind: \"ExtraResources\"\n requirements = {\n \"all-cool-resources\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchLabels = {}\n }\n }\n}\n]\n"
217- }
218- }` ),
214+ "spec": {
215+ "target": "Default",
216+ "source": "items = [\n{\n apiVersion: \"meta.krm.kcl.dev/v1alpha1\"\n kind: \"ExtraResources\"\n requirements = {\n \"cool-extra-resource\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchName: \"cool-extra-resource\"\n }\n }\n},\n{\n apiVersion: \"meta.krm.kcl.dev/v1alpha1\"\n kind: \"ExtraResources\"\n requirements = {\n \"another-cool-extra-resource\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchLabels = {\n key: \"value\"\n }\n }\n \"yet-another-cool-extra-resource\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchName: \"foo\"\n }\n }\n},\n{\n apiVersion: \"meta.krm.kcl.dev/v1alpha1\"\n kind: \"ExtraResources\"\n requirements = {\n \"all-cool-resources\" = {\n apiVersion: \"example.org/v1\"\n kind: \"CoolExtraResource\"\n matchLabels = {}\n }\n }\n}\n]\n"
217+ }
218+ }` ),
219219 Observed : & fnv1.State {
220220 Composite : & fnv1.Resource {
221221 Resource : resource .MustStructJSON (xr ),
@@ -326,27 +326,6 @@ func TestRunFunctionSimple(t *testing.T) {
326326 },
327327 },
328328 },
329- "ExtraResourcesNamespacedWithLabels" : {
330- reason : "The Function should pass with a single extra resource with matchLabels and matchNamespace" ,
331- args : args {
332- req : & fnv1.RunFunctionRequest {
333- Meta : & fnv1.RequestMeta {Tag : "extra-resources-namespace-labels" },
334- Input : resource .MustStructJSON (`{
335- "apiVersion":"krm.kcl.dev/v1alpha1","kind":"KCLInput","metadata":{"name":"basic"},"spec":{"target":"Default","source":"items=[{ apiVersion:\"meta.krm.kcl.dev/v1alpha1\", kind:\"ExtraResources\", requirements={ \"cool-resource-match-ns-match-labels\"={ apiVersion:\"example.org/v1\", kind:\"CoolExtraResource\", matchNamespace:\"cool-ns\", matchLabels={\"cool-key\":\"cool-value\"} }}}]"}
336- }` ),
337- Observed : & fnv1.State {Composite : & fnv1.Resource {Resource : resource .MustStructJSON (xr )}},
338- },
339- },
340- want : want {
341- rsp : & fnv1.RunFunctionResponse {
342- Meta : & fnv1.ResponseMeta {Tag : "extra-resources-namespace-labels" , Ttl : durationpb .New (response .DefaultTTL )},
343- Requirements : & fnv1.Requirements {ExtraResources : map [string ]* fnv1.ResourceSelector {
344- "cool-resource-match-ns-match-labels" : {ApiVersion : "example.org/v1" , Kind : "CoolExtraResource" , Namespace : ptr.To [string ]("cool-ns" ), Match : & fnv1.ResourceSelector_MatchLabels {MatchLabels : & fnv1.MatchLabels {Labels : map [string ]string {"cool-key" : "cool-value" }}}},
345- }},
346- Desired : & fnv1.State {Composite : & fnv1.Resource {Resource : resource .MustStructJSON (`{"apiVersion":"example.org/v1","kind":"XR"}` )}},
347- },
348- },
349- },
350329 "ExtraResourcesIn" : {
351330 reason : "The Function should return the extra resources from the request." ,
352331 args : args {
0 commit comments