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