mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-22 15:38:06 +00:00
Remove secret from previous step
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -27,3 +28,26 @@ func Run(name string, args ...string) (string, error) {
|
||||
|
||||
return string(output), nil
|
||||
}
|
||||
|
||||
func GetProjectRoot() (string, error) {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for {
|
||||
// check if go.mod exists in current dir
|
||||
modFile := filepath.Join(dir, "go.mod")
|
||||
if _, err := os.Stat(modFile); err == nil {
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
// move one level up
|
||||
parent := filepath.Dir(dir)
|
||||
if parent == dir {
|
||||
// reached filesystem root
|
||||
return "", fmt.Errorf("project root not found (no go.mod)")
|
||||
}
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
|
@@ -48,6 +48,7 @@ var _ = Describe("Onepassword Operator e2e", Ordered, func() {
|
||||
Context("Use the operator with Service Account", func() {
|
||||
BeforeAll(func() {
|
||||
kube.PatchOperatorToUseServiceAccount()
|
||||
kube.DeleteSecret("login") // remove secret crated in previous test
|
||||
})
|
||||
|
||||
runCommonTestCases()
|
||||
|
@@ -40,8 +40,8 @@ func CreateOpCredentialsSecret() {
|
||||
CreateSecretFromFile("op-session", "op-credentials")
|
||||
}
|
||||
|
||||
func Delete(kind, name string) {
|
||||
_, err := cmd.Run("kubectl", "delete", kind, name, "--ignore-not-found=true")
|
||||
func DeleteSecret(name string) {
|
||||
_, err := cmd.Run("kubectl", "delete", "secret", name, "--ignore-not-found=true")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/1Password/onepassword-operator/test/cmd"
|
||||
"github.com/1Password/onepassword-operator/test/testhelper/kube"
|
||||
)
|
||||
|
||||
func BuildOperatorImage() {
|
||||
@@ -34,12 +33,3 @@ func DeployOperator() {
|
||||
g.Expect(output).To(ContainSubstring("Running"))
|
||||
}, 30*time.Second, 1*time.Second).Should(Succeed())
|
||||
}
|
||||
|
||||
func UndeployOperator() {
|
||||
kube.Delete("secret", "onepassword-connect-token")
|
||||
kube.Delete("secret", "onepassword-service-account-token")
|
||||
|
||||
By("undeploying the operator")
|
||||
_, err := cmd.Run("make", "undeploy", "ignore-not-found")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
Reference in New Issue
Block a user