Extract setting context namespace to standalone function SetContextNamespace

This commit is contained in:
Volodymyr Zotov
2025-08-20 14:57:47 -05:00
parent 882d8e951d
commit 299689fe13
3 changed files with 15 additions and 200 deletions

View File

@@ -22,10 +22,8 @@ const (
var _ = Describe("Onepassword Operator e2e", Ordered, func() {
BeforeAll(func() {
By("Set namespace to default")
_, _ = system.Run("kubectl", "config", "set-context", "--current", "--namespace=default")
kube.SetContextNamespace("default")
By("Build the operator image")
operator.BuildOperatorImage()
kind.LoadImageToKind(operatorImageName)

View File

@@ -48,6 +48,12 @@ func DeleteSecret(name string) {
Expect(err).NotTo(HaveOccurred())
}
func SetContextNamespace(namespace string) {
By("Set namespace to " + namespace)
_, err := system.Run("kubectl", "config", "set-context", "--current", "--namespace="+namespace)
Expect(err).NotTo(HaveOccurred())
}
// PatchOperatorToUseServiceAccount sets `OP_SERVICE_ACCOUNT_TOKEN` env variable
var PatchOperatorToUseServiceAccount = WithOperatorRestart(func() {
By("patching the operator deployment with service account token")