Skip to content

Commit

Permalink
feat(go): support go 1.23 and delve 1.23.1
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymcconville committed Nov 25, 2024
1 parent ce64064 commit a006f77
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 242 deletions.
6 changes: 3 additions & 3 deletions go/helper-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ARG GOVERSION=1.20
FROM --platform=$BUILDPLATFORM golang:${GOVERSION} as delve
ARG GOVERSION=1.23
FROM --platform=$BUILDPLATFORM golang:${GOVERSION} AS delve
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ARG DELVE_VERSION=1.20.1
ARG DELVE_VERSION=1.23.1

# Patch delve to make defaults for --check-go-version and --only-same-user
# to be set at build time. We must install patch(1) to apply the patch.
Expand Down
39 changes: 23 additions & 16 deletions go/helper-image/delve-as-options.patch
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
diff --git cmd/dlv/cmds/commands.go cmd/dlv/cmds/commands.go
index 15df5f6..f145330 100644
index b5b7662c..dcdae257 100644
--- cmd/dlv/cmds/commands.go
+++ cmd/dlv/cmds/commands.go
@@ -46,6 +46,10 @@ var (
apiVersion int
// acceptMulti allows multiple clients to connect to the same server
acceptMulti bool
+ // checkGoVersionDefault sets default for --check-go-version
+ checkGoVersionDefault = "true"
@@ -61,6 +61,8 @@ var (
// checkLocalConnUser is true if the debugger should check that local
// connections come from the same user that started the headless server
checkLocalConnUser bool
+ // checkLocalConnUserDefault sets default for --only-same-user
+ checkLocalConnUserDefault = "true"
// addr is the debugging server listen address.
addr string
// initFile is the path to initialization file.
@@ -139,8 +143,8 @@ func New(docCall bool) *cobra.Command {
rootCommand.PersistentFlags().StringVar(&initFile, "init", "", "Init file, executed by the terminal client.")
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\"")
// tty is used to provide an alternate TTY for the program you wish to debug.
tty string
// disableASLR is used to disable ASLR
@@ -78,6 +80,8 @@ var (
// used to compile the executable and refuse to work on incompatible
// versions.
checkGoVersion bool
+ // checkGoVersionDefault sets default for --check-go-version
+ checkGoVersionDefault = "true"

// rootCommand is the root of the command tree.
rootCommand *cobra.Command
@@ -158,8 +162,8 @@ func New(docCall bool) *cobra.Command {
must(rootCommand.RegisterFlagCompletionFunc("build-flags", cobra.NoFileCompletions))
rootCommand.PersistentFlags().StringVar(&workingDir, "wd", "", "Working directory for running the program.")
must(rootCommand.MarkPersistentFlagDirname("wd"))
- 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.")
- rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", true, "Only connections from the same user that started this instance of Delve are allowed to connect.")
+ 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.")
+ 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.")
rootCommand.PersistentFlags().StringVar(&backend, "backend", "default", `Backend selection (see 'dlv help backend').`)
must(rootCommand.RegisterFlagCompletionFunc("backend", cobra.FixedCompletions([]string{"default", "native", "lldb", "rr"}, cobra.ShellCompDirectiveNoFileComp)))
rootCommand.PersistentFlags().StringArrayVarP(&redirects, "redirect", "r", []string{}, "Specifies redirect rules for target process (see 'dlv help redirect')")
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")
@@ -1020,3 +1024,14 @@ func parseRedirects(redirects []string) ([3]string, error) {
@@ -1250,3 +1254,14 @@ func must(err error) {
log.Fatal(err)
}
return r, nil
}
+
+// parseBool parses a boolean value represented by a string, and panics if there is an error.
Expand Down
32 changes: 30 additions & 2 deletions go/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ profiles:
context: test/goapp
docker:
buildArgs:
GOVERSION: 1.18
GOVERSION: '1.18'
- op: add
path: /build/artifacts/-
value:
image: go119app
context: test/goapp
docker:
buildArgs:
GOVERSION: 1.19
GOVERSION: '1.19'
- op: add
path: /build/artifacts/-
value:
Expand All @@ -62,12 +62,40 @@ profiles:
docker:
buildArgs:
GOVERSION: '1.20'
- op: add
path: /build/artifacts/-
value:
image: go121app
context: test/goapp
docker:
buildArgs:
GOVERSION: '1.21'
- op: add
path: /build/artifacts/-
value:
image: go122app
context: test/goapp
docker:
buildArgs:
GOVERSION: '1.22'
- op: add
path: /build/artifacts/-
value:
image: go123app
context: test/goapp
docker:
buildArgs:
GOVERSION: '1.23'

deploy:
kubectl:
manifests:
- test/k8s-test-go118.yaml
- test/k8s-test-go119.yaml
- test/k8s-test-go120.yaml
- test/k8s-test-go121.yaml
- test/k8s-test-go122.yaml
- test/k8s-test-go123.yaml

# release: pushes images to production with :latest
- name: release
Expand Down
91 changes: 0 additions & 91 deletions go/test/k8s-test-go116.yaml

This file was deleted.

91 changes: 0 additions & 91 deletions go/test/k8s-test-go117.yaml

This file was deleted.

24 changes: 11 additions & 13 deletions go/test/k8s-test-go113.yaml → go/test/k8s-test-go121.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
apiVersion: v1
kind: Pod
metadata:
name: go113pod
name: go121pod
labels:
app: hello
protocol: dlv
runtime: go113
runtime: go121
spec:
containers:
- name: go113app
image: go113app
- name: go121app
image: go121app
args:
- /dbg/go/bin/dlv
- exec
Expand Down Expand Up @@ -48,7 +48,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: hello-dlv-go113
name: hello-dlv-go121
spec:
ports:
- name: http
Expand All @@ -60,13 +60,13 @@ spec:
selector:
app: hello
protocol: dlv
runtime: go113
runtime: go121

---
apiVersion: batch/v1
kind: Job
metadata:
name: connect-to-go113
name: connect-to-go121
labels:
project: container-debug-support
type: integration-test
Expand All @@ -77,15 +77,13 @@ spec:
spec:
restartPolicy: Never
initContainers:
- name: wait-for-go113pod
- name: wait-for-go121
image: kubectl
command: [sh, -c, "while ! curl -s hello-dlv-go113:8080 2>/dev/null; do echo waiting for app; sleep 1; done"]
command: [sh, -c, "while ! curl -s hello-dlv-go121:8080 2>/dev/null; do echo waiting for app; sleep 1; done"]
containers:
- name: dlv-to-go113
- name: dlv-to-go121
image: skaffold-debug-go
command: [sh, -c, '
(echo bt; echo exit -c) > init.txt;
set -x;
/duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go113:56286']


/duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go121:56286']
Loading

0 comments on commit a006f77

Please sign in to comment.