Create kube package that abstracts interactions with kubernetes cluster

This commit is contained in:
Volodymyr Zotov
2025-08-19 11:52:28 -05:00
parent d504e5ef35
commit 5630d788a2
3 changed files with 101 additions and 19 deletions

21
test/kube/kube.go Normal file
View File

@@ -0,0 +1,21 @@
package kube
import (
"os"
. "github.com/onsi/gomega"
"github.com/1Password/onepassword-operator/test/cmd"
)
func CreateSecretFromEnvVar(envVar, secretName string) {
serviceAccountTokenToken, _ := os.LookupEnv(envVar)
Expect(serviceAccountTokenToken).NotTo(BeEmpty())
_, err := cmd.Run("kubectl", "create", "secret", "generic", secretName, "--from-literal=token="+serviceAccountTokenToken)
Expect(err).NotTo(HaveOccurred())
}
func Delete(kind, name string) {
_, err := cmd.Run("kubectl", "delete", kind, name, "--ignore-not-found=true")
Expect(err).NotTo(HaveOccurred())
}