github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/fixture/gpgkeys/gpgkeys.go (about) 1 package gpgkeys 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 8 "github.com/argoproj/argo-cd/v2/test/e2e/fixture" 9 "github.com/argoproj/argo-cd/v2/util/errors" 10 ) 11 12 // Add GPG public key via API and create appropriate file where the ConfigMap mount would de it as well 13 func AddGPGPublicKey() { 14 keyPath, err := filepath.Abs(fmt.Sprintf("../fixture/gpg/%s", fixture.GpgGoodKeyID)) 15 errors.CheckError(err) 16 args := []string{"gpg", "add", "--from", keyPath} 17 errors.FailOnErr(fixture.RunCli(args...)) 18 19 if fixture.IsLocal() { 20 keyData, err := os.ReadFile(keyPath) 21 errors.CheckError(err) 22 err = os.WriteFile(fmt.Sprintf("%s/app/config/gpg/source/%s", fixture.TmpDir, fixture.GpgGoodKeyID), keyData, 0644) 23 errors.CheckError(err) 24 } else { 25 fixture.RestartRepoServer() 26 } 27 } 28 29 func DeleteGPGPublicKey() { 30 args := []string{"gpg", "rm", fixture.GpgGoodKeyID} 31 errors.FailOnErr(fixture.RunCli(args...)) 32 if fixture.IsLocal() { 33 errors.CheckError(os.Remove(fmt.Sprintf("%s/app/config/gpg/source/%s", fixture.TmpDir, fixture.GpgGoodKeyID))) 34 } else { 35 fixture.RestartRepoServer() 36 } 37 }