Skip to content

Commit 68a5612

Browse files
authored
use spf13/pflag instead of Go's standard flag package (#1979)
Signed-off-by: Etai Lev Ran <[email protected]>
1 parent 9e1aca2 commit 68a5612

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

cmd/epp/runner/runner.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"crypto/tls"
2222
"errors"
23-
"flag"
23+
goflag "flag"
2424
"fmt"
2525
"net/http"
2626
"net/http/pprof"
@@ -34,6 +34,7 @@ import (
3434

3535
"github.com/go-logr/logr"
3636
"github.com/prometheus/client_golang/prometheus"
37+
flag "github.com/spf13/pflag"
3738
uberzap "go.uber.org/zap"
3839
"go.uber.org/zap/zapcore"
3940
"google.golang.org/grpc"
@@ -200,7 +201,9 @@ func (r *Runner) Run(ctx context.Context) error {
200201
opts := zap.Options{
201202
Development: true,
202203
}
203-
opts.BindFlags(flag.CommandLine)
204+
gfs := goflag.NewFlagSet("zap", goflag.ExitOnError)
205+
opts.BindFlags(gfs) // zap expects a standard Go FlagSet and pflag.FlagSet is not compatible.
206+
flag.CommandLine.AddGoFlagSet(gfs)
204207
flag.Parse()
205208
initLogging(&opts)
206209

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ require (
4242
sigs.k8s.io/yaml v1.6.0
4343
)
4444

45-
require github.com/go-logr/zapr v1.3.0
45+
require (
46+
github.com/go-logr/zapr v1.3.0
47+
github.com/spf13/pflag v1.0.7
48+
)
4649

4750
require (
4851
cel.dev/expr v0.24.0 // indirect
@@ -95,7 +98,6 @@ require (
9598
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
9699
github.com/prometheus/procfs v0.17.0 // indirect
97100
github.com/spf13/cobra v1.9.1 // indirect
98-
github.com/spf13/pflag v1.0.7 // indirect
99101
github.com/stoewer/go-strcase v1.3.0 // indirect
100102
github.com/x448/float16 v0.8.4 // indirect
101103
go.opentelemetry.io/auto/sdk v1.2.1 // indirect

pkg/epp/datalayer/metrics/factories.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ package metrics
1818

1919
import (
2020
"encoding/json"
21-
"flag"
2221
"fmt"
2322
"strconv"
2423

24+
flag "github.com/spf13/pflag"
25+
2526
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
2627
)
2728

0 commit comments

Comments
 (0)