Skip to content

Commit

Permalink
Add support to conformance/gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Nov 7, 2024
1 parent effcb98 commit 945354a
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions cmd/conformance/gcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,33 @@ import (
)

var (
bucket = flag.String("bucket", "", "Bucket to use for storing log")
listen = flag.String("listen", ":2024", "Address:port to listen on")
project = flag.String("project", os.Getenv("GOOGLE_CLOUD_PROJECT"), "GCP Project, take from env if unset")
spanner = flag.String("spanner", "", "Spanner resource URI ('projects/.../...')")
signer = flag.String("signer", "", "Note signer to use to sign checkpoints")
verifier = flag.String("verifier", "", "Note verifier corresponding to --signer")
origin = flag.String("origin", "", "Log origin string")
bucket = flag.String("bucket", "", "Bucket to use for storing log")
listen = flag.String("listen", ":2024", "Address:port to listen on")
project = flag.String("project", os.Getenv("GOOGLE_CLOUD_PROJECT"), "GCP Project, take from env if unset")
spanner = flag.String("spanner", "", "Spanner resource URI ('projects/.../...')")
signer = flag.String("signer", "", "Note signer to use to sign checkpoints")
verifier = flag.String("verifier", "", "Note verifier corresponding to --signer")
additionalSigners = []string{}
)

func init() {
flag.Func("additional_signer", "Additional note signer for checkpoints, may be specified multiple times", func(s string) error {
additionalSigners = append(additionalSigners, s)
return nil
})
}

func main() {
klog.InitFlags(nil)
flag.Parse()
ctx := context.Background()

if *origin == "" {
klog.Exit("Must supply --origin")
}

s, v := signerFromFlags()
s, v, a := signerFromFlags()

// Create our Tessera storage backend:
gcpCfg := storageConfigFromFlags()
storage, err := gcp.New(ctx, gcpCfg,
tessera.WithCheckpointSignerVerifier(s, v),
tessera.WithCheckpointSignerVerifier(s, v, a...),
tessera.WithBatching(1024, time.Second),
tessera.WithPushback(10*4096),
)
Expand Down Expand Up @@ -120,7 +123,7 @@ func storageConfigFromFlags() gcp.Config {
}
}

func signerFromFlags() (note.Signer, note.Verifier) {
func signerFromFlags() (note.Signer, note.Verifier, []note.Signer) {
s, err := note.NewSigner(*signer)
if err != nil {
klog.Exitf("Failed to create new signer: %v", err)
Expand All @@ -131,5 +134,14 @@ func signerFromFlags() (note.Signer, note.Verifier) {
klog.Exitf("Failed to create new verifier: %v", err)
}

return s, v
var a []note.Signer
for _, as := range additionalSigners {
s, err := note.NewSigner(as)
if err != nil {
klog.Exitf("Failed to create additional signer: %v", err)
}
a = append(a, s)
}

return s, v, a
}

0 comments on commit 945354a

Please sign in to comment.