Skip to content

Commit 7f89283

Browse files
authored
feat: update Delve to 1.7.3 (#106)
1 parent c9af5dc commit 7f89283

File tree

4 files changed

+52
-137
lines changed

4 files changed

+52
-137
lines changed

go/helper-image/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@ ARG BUILDPLATFORM
44
ARG TARGETOS
55
ARG TARGETARCH
66

7-
ARG DELVE_VERSION=1.7.2
7+
ARG DELVE_VERSION=1.7.3
88

9-
# Patch delve to change default for --only-same-user to false
10-
# Required as `kubectl port-forward` to dlv port is refused.
11-
# We must install patch(1) to apply the patch.
9+
# Patch delve to make defaults for --check-go-version and --only-same-user
10+
# to be set at build time. We must install patch(1) to apply the patch.
11+
#
12+
# We default --check-go-version to false to support binaries compiled
13+
# with unsupported versions of Go. Delve issues a prominent warning.
14+
#
15+
# We default --only-same-user to false as `kubectl port-forward`
16+
# to dlv port is refused otherwise.
1217
RUN apt-get update && apt-get install -y --no-install-recommends \
1318
patch
1419
RUN curl --location --output delve.tar.gz https://github.com/go-delve/delve/archive/v$DELVE_VERSION.tar.gz \
1520
&& tar xzf delve.tar.gz \
1621
&& mv delve-$DELVE_VERSION delve-source
1722
COPY delve-*.patch .
18-
RUN patch -p0 -d delve-source < delve-only-same-user.patch \
19-
&& patch -p0 -d delve-source < delve-pr2684.patch
23+
RUN patch -p0 -d delve-source < delve-as-options.patch
2024

2125
# Produce an as-static-as-possible dlv binary to work on musl and glibc
2226
RUN cd delve-source \
23-
&& CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /go/dlv -ldflags '-s -w -extldflags "-static"' ./cmd/dlv/
27+
&& CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /go/dlv -ldflags '-s -w -X github.com/go-delve/delve/cmd/dlv/cmds.checkGoVersionDefault=false -X github.com/go-delve/delve/cmd/dlv/cmds.checkLocalConnUserDefault=false -extldflags "-static"' ./cmd/dlv/
2428

2529
# Now populate the duct-tape image with the language runtime debugging support files
2630
# The debian image is about 95MB bigger
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git cmd/dlv/cmds/commands.go cmd/dlv/cmds/commands.go
2+
index 15df5f6..f145330 100644
3+
--- cmd/dlv/cmds/commands.go
4+
+++ cmd/dlv/cmds/commands.go
5+
@@ -46,6 +46,10 @@ var (
6+
apiVersion int
7+
// acceptMulti allows multiple clients to connect to the same server
8+
acceptMulti bool
9+
+ // checkGoVersionDefault sets default for --check-go-version
10+
+ checkGoVersionDefault = "true"
11+
+ // checkLocalConnUserDefault sets default for --only-same-user
12+
+ checkLocalConnUserDefault = "true"
13+
// addr is the debugging server listen address.
14+
addr string
15+
// initFile is the path to initialization file.
16+
@@ -139,8 +143,8 @@ func New(docCall bool) *cobra.Command {
17+
rootCommand.PersistentFlags().StringVar(&initFile, "init", "", "Init file, executed by the terminal client.")
18+
rootCommand.PersistentFlags().StringVar(&buildFlags, "build-flags", buildFlagsDefault, "Build flags, to be passed to the compiler. For example: --build-flags=\"-tags=integration -mod=vendor -cover -v\"")
19+
rootCommand.PersistentFlags().StringVar(&workingDir, "wd", "", "Working directory for running the program.")
20+
- rootCommand.PersistentFlags().BoolVarP(&checkGoVersion, "check-go-version", "", true, "Exits if the version of Go in use is not compatible (too old or too new) with the version of Delve.")
21+
- rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", true, "Only connections from the same user that started this instance of Delve are allowed to connect.")
22+
+ rootCommand.PersistentFlags().BoolVarP(&checkGoVersion, "check-go-version", "", parseBool(checkGoVersionDefault), "Exits if the version of Go in use is not compatible (too old or too new) with the version of Delve.")
23+
+ rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", parseBool(checkLocalConnUserDefault), "Only connections from the same user that started this instance of Delve are allowed to connect.")
24+
rootCommand.PersistentFlags().StringVar(&backend, "backend", "default", `Backend selection (see 'dlv help backend').`)
25+
rootCommand.PersistentFlags().StringArrayVarP(&redirects, "redirect", "r", []string{}, "Specifies redirect rules for target process (see 'dlv help redirect')")
26+
rootCommand.PersistentFlags().BoolVar(&allowNonTerminalInteractive, "allow-non-terminal-interactive", false, "Allows interactive sessions of Delve that don't have a terminal as stdin, stdout and stderr")
27+
@@ -1020,3 +1024,14 @@ func parseRedirects(redirects []string) ([3]string, error) {
28+
}
29+
return r, nil
30+
}
31+
+
32+
+// parseBool parses a boolean value represented by a string, and panics if there is an error.
33+
+// It is intended for boolean build-time constants that are set with 'go build -ldflags=-X xxx=bool'
34+
+// and should only be a valid value.
35+
+func parseBool(value string) bool {
36+
+ b, err := strconv.ParseBool(value)
37+
+ if err != nil {
38+
+ panic(err)
39+
+ }
40+
+ return b
41+
+}

go/helper-image/delve-only-same-user.patch

Lines changed: 0 additions & 19 deletions
This file was deleted.

go/helper-image/delve-pr2684.patch

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)