Skip to content

Commit

Permalink
Decode gpg secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirakis committed Aug 24, 2023
1 parent 08f6dab commit 4e46a1e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions containers/base_rpm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package containers

import "dagger.io/dagger"
import (
"dagger.io/dagger"
"encoding/base64"
)

const RPMMacros = `
%_signature gpg
Expand All @@ -21,8 +24,13 @@ func RPMContainer(d *dagger.Client, opts *GPGOpts) *dagger.Container {
if !opts.Sign {
return container
}
gpgPublicKeyBase64Secret := d.SetSecret("gpg-public-key-base64", opts.GPGPublicKeyBase64)
gpgPrivateKeyBase64Secret := d.SetSecret("gpg-private-key-base64", opts.GPGPrivateKeyBase64)
var gpgPublicKeyBase64Secret, gpgPrivateKeyBase64Secret *dagger.Secret
if decodedGPGPublicKeyBase64Secret, err := base64.StdEncoding.DecodeString(opts.GPGPublicKeyBase64); err != nil {
gpgPublicKeyBase64Secret = d.SetSecret("gpg-public-key-base64", string(decodedGPGPublicKeyBase64Secret))
}
if decodedGPGPrivateKeyBase64Secret, err := base64.StdEncoding.DecodeString(opts.GPGPrivateKeyBase64); err != nil {
gpgPrivateKeyBase64Secret = d.SetSecret("gpg-private-key-base64", string(decodedGPGPrivateKeyBase64Secret))
}
gpgPassphraseBase64Secret := d.SetSecret("gpg-passphrase-base64", opts.GPGPassphraseBase64)
return container.
WithSecretVariable("GPG_PUBLIC_KEY_BASE64", gpgPublicKeyBase64Secret).
Expand Down

0 comments on commit 4e46a1e

Please sign in to comment.