github.com/argoproj/argo-cd@v1.8.7/test/e2e/fixture/gpgkeys/gpgkeys.go (about)

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