Skip to content

Commit

Permalink
feat: add debug-goproxy option
Browse files Browse the repository at this point in the history
Signed-off-by: Rintaro Okamura <[email protected]>
  • Loading branch information
rinx committed Jul 10, 2024
1 parent 4efd66e commit 359c0b8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
serverPort string
defaultAudience string
tokenSourceCacheDuration string
debugGoproxy bool
)

func main() {
Expand All @@ -36,6 +37,7 @@ func main() {
cmd.Flags().StringVar(&serverHost, "host", "0.0.0.0", "server host")
cmd.Flags().StringVar(&serverPort, "port", "8100", "server port")
cmd.Flags().StringVar(&tokenSourceCacheDuration, "token-source-cache-duration", "30m", "token source cache duration")
cmd.Flags().BoolVar(&debugGoproxy, "debug-goproxy", false, "verbose logging about elazarl/goproxy")

if err := cmd.Execute(); err != nil {
slog.Error("error occurred", "error", err)
Expand All @@ -49,6 +51,7 @@ func run(cmd *cobra.Command, args []string) error {
ServerPort: serverPort,
DefaultAudience: defaultAudience,
TokenSourceCacheDuration: tokenSourceCacheDuration,
DebugGoproxy: debugGoproxy,
}

r, err := runner.New(cfg)
Expand Down
1 change: 1 addition & 0 deletions pkg/runner/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (p *proc) Start(ctx context.Context) (_ <-chan error, err error) {
p.idtoken, err = idtoken.New(
idtoken.WithDefaultAudience(p.DefaultAudience),
idtoken.WithTokenSourceCacheDuration(p.TokenSourceCacheDuration),
idtoken.WithDebugGoproxy(p.DebugGoproxy),
)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Config struct {
ServerPort string
DefaultAudience string
TokenSourceCacheDuration string
DebugGoproxy bool
}

// Runner represents main routine interface
Expand Down
12 changes: 12 additions & 0 deletions pkg/service/google/idtoken/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@ func (o tsCacheDurationOption) Apply(s *server) error {
func WithTokenSourceCacheDuration(dur string) tsCacheDurationOption {
return tsCacheDurationOption(dur)
}

type debugGoproxyOption bool

func (o debugGoproxyOption) Apply(s *server) error {
s.proxy.Verbose = bool(o)

return nil
}

func WithDebugGoproxy(b bool) debugGoproxyOption {
return debugGoproxyOption(b)
}

0 comments on commit 359c0b8

Please sign in to comment.