-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft accept wasm pull secret as env var
add a unit test and doc update Signed-off-by: craig <[email protected]> rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
- Loading branch information
Showing
5 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//go:build unit | ||
|
||
package controllers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kuadrant/kuadrant-operator/pkg/wasm" | ||
"github.com/kuadrant/policy-machinery/machinery" | ||
istioclientgoextensionv1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
v1 "sigs.k8s.io/gateway-api/apis/v1" | ||
) | ||
|
||
func Test_buildIstioWasmPluginForGateway(t *testing.T) { | ||
var imagePullSecret = "testsecret" | ||
var testGateway = &machinery.Gateway{ | ||
Gateway: &v1.Gateway{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test", | ||
Namespace: "test", | ||
}, | ||
}, | ||
} | ||
var testWasmConfig = wasm.Config{ | ||
ActionSets: []wasm.ActionSet{ | ||
{ | ||
Name: "test", | ||
}, | ||
}, | ||
} | ||
testCases := []struct { | ||
Name string | ||
Gateway *machinery.Gateway | ||
WasmConfig wasm.Config | ||
ImagePullSecret string | ||
Assert func(t *testing.T, plugin *istioclientgoextensionv1alpha1.WasmPlugin) | ||
}{ | ||
{ | ||
Name: "ensure image pull secret is set in wasmPlugin", | ||
Gateway: testGateway, | ||
WasmConfig: testWasmConfig, | ||
ImagePullSecret: imagePullSecret, | ||
Assert: func(t *testing.T, plugin *istioclientgoextensionv1alpha1.WasmPlugin) { | ||
if plugin == nil { | ||
t.Fatalf("Expected a wasmplugin") | ||
} | ||
if plugin.Spec.ImagePullSecret != imagePullSecret { | ||
t.Fatalf("Expected wasm plugin to have imagePullSecret %s but got %s", imagePullSecret, plugin.Spec.ImagePullSecret) | ||
} | ||
}, | ||
}, | ||
{ | ||
Name: "ensure image pull secret is NOT set in wasmPlugin", | ||
Gateway: testGateway, | ||
WasmConfig: testWasmConfig, | ||
Assert: func(t *testing.T, plugin *istioclientgoextensionv1alpha1.WasmPlugin) { | ||
if plugin == nil { | ||
t.Fatalf("Expected a wasmplugin") | ||
} | ||
if plugin.Spec.ImagePullSecret != "" { | ||
t.Fatalf("Expected wasm plugin to have not imagePullSecret %s", plugin.Spec.ImagePullSecret) | ||
} | ||
}, | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.Name, func(t *testing.T) { | ||
plugin := buildIstioWasmPluginForGateway(testCase.Gateway, testCase.WasmConfig, testCase.ImagePullSecret) | ||
testCase.Assert(t, plugin) | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters