Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle secret manipulation programmatically #133

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions containers/base_rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ func RPMContainer(d *dagger.Client, opts *GPGOpts) *dagger.Container {
log.Printf("gpg-private-key-base64 cannot be decoded %s", err.Error())
}

if sec, err := base64.StdEncoding.DecodeString(opts.GPGPassphraseBase64); err == nil {
gpgPassphraseSecret = d.SetSecret("gpg-passphrase-base64", string(sec))
} else {
log.Printf("gpg-private-key-base64 cannot be decoded %s", err.Error())
}
gpgPassphraseSecret = d.SetSecret("gpg-passphrase-base64", opts.GPGPassphraseBase64)

return container.
WithExec([]string{"apt-get", "install", "-yq", "gnupg2"}).
Expand Down
6 changes: 4 additions & 2 deletions containers/opts_gpg.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package containers

import (
"strings"

"github.com/grafana/grafana-build/cliutil"
)

Expand All @@ -14,8 +16,8 @@ type GPGOpts struct {
func GPGOptsFromFlags(c cliutil.CLIContext) *GPGOpts {
return &GPGOpts{
Sign: c.Bool("sign"),
GPGPrivateKeyBase64: c.String("gpg-private-key-base64"),
GPGPublicKeyBase64: c.String("gpg-public-key-base64"),
GPGPrivateKeyBase64: strings.ReplaceAll(c.String("gpg-private-key-base64"), "\n", ""),
GPGPublicKeyBase64: strings.ReplaceAll(c.String("gpg-public-key-base64"), "\n", ""),
GPGPassphraseBase64: c.String("gpg-passphrase-base64"),
}
}
6 changes: 3 additions & 3 deletions scripts/drone_publish_tag_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ dagger run go run ./cmd rpm \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} \
--sign=false \
--gpg-private-key-base64=$(echo $GPG_PRIVATE_KEY | base64 -w 0) \
--gpg-public-key-base64=$(echo $GPG_PUBLIC_KEY | base64 -w 0) \
--gpg-passphrase-base64=$(echo $GPG_PASSPHRASE | base64 -w 0) > rpms.txt &
--gpg-private-key-base64=${$GPG_PRIVATE_KEY} \
--gpg-public-key-base64=${$GPG_PUBLIC_KEY} \
--gpg-passphrase-base64=${$GPG_PASSPHRASE} > rpms.txt &

# For Windows we distribute zips and exes
dagger run go run ./cmd zip \
Expand Down
6 changes: 3 additions & 3 deletions scripts/drone_publish_tag_enterprise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ dagger run go run ./cmd rpm \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} \
--sign=true \
--gpg-private-key-base64=$(echo "${GPG_PRIVATE_KEY}" | tr -d '\n') \
--gpg-public-key-base64=$(echo "${GPG_PUBLIC_KEY}" | tr -d '\n') \
--gpg-passphrase-base64=$(echo "${GPG_PASSPHRASE}" | base64 -w 0) > rpms.txt
--gpg-private-key-base64=${GPG_PRIVATE_KEY} \
--gpg-public-key-base64=${GPG_PUBLIC_KEY} \
--gpg-passphrase-base64=${GPG_PASSPHRASE} > rpms.txt

# For Windows we distribute zips and exes
dagger run go run ./cmd zip \
Expand Down
6 changes: 3 additions & 3 deletions scripts/drone_publish_tag_grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ dagger run --silent go run ./cmd rpm \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} \
--sign=true \
--gpg-private-key-base64=$(echo "${GPG_PRIVATE_KEY}" | tr -d '\n') \
--gpg-public-key-base64=$(echo "${GPG_PUBLIC_KEY}" | tr -d '\n') \
--gpg-passphrase-base64=$(echo "${GPG_PASSPHRASE}" | base64 -w 0) > rpms.txt
--gpg-private-key-base64=${GPG_PRIVATE_KEY} \
--gpg-public-key-base64=${GPG_PUBLIC_KEY} \
--gpg-passphrase-base64=${GPG_PASSPHRASE} > rpms.txt

# For Windows we distribute zips and exes
dagger run --silent go run ./cmd zip \
Expand Down
Loading