Skip to content

Commit 4ad8ab1

Browse files
Update hypeman-go SDK to e6c2b7b and add swtpm log source
Bumps github.com/kernel/hypeman-go to v0.28.1-0.20260902143136-e6c2b7bc0171, which adds the "swtpm" value to InstanceLogsParamsSource as part of the Windows hypervisor primitives. Teaches `hypeman logs --source` about swtpm and validates the flag up front instead of forwarding an arbitrary string to the API, matching the parseInstanceWaitState / parseSnapshotTargetHypervisor pattern. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b73f664 commit 4ad8ab1

4 files changed

Lines changed: 38 additions & 5 deletions

File tree

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/google/go-containerregistry v0.20.7
1313
github.com/gorilla/websocket v1.5.3
1414
github.com/itchyny/json2yaml v0.1.4
15-
github.com/kernel/hypeman-go v0.28.1-0.20260902045311-0872a65a3733
15+
github.com/kernel/hypeman-go v0.28.1-0.20260902143136-e6c2b7bc0171
1616
github.com/knadh/koanf/parsers/yaml v1.1.0
1717
github.com/knadh/koanf/providers/env v1.1.0
1818
github.com/knadh/koanf/providers/file v1.2.1

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnV
7878
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
7979
github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+k8=
8080
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
81-
github.com/kernel/hypeman-go v0.28.1-0.20260902045311-0872a65a3733 h1:qJLI83DX+7jnEVUgBF8edK5OYwTOwI4OqER0R+bARgY=
82-
github.com/kernel/hypeman-go v0.28.1-0.20260902045311-0872a65a3733/go.mod h1:of8qI/nef2OPLzt0EMlIRbMdJHEvuc4yWG8g/ioNg48=
81+
github.com/kernel/hypeman-go v0.28.1-0.20260902143136-e6c2b7bc0171 h1:psPDtnXBaPABqymQW5lu1o9YOF7gyyxJZeQOCqcuxyo=
82+
github.com/kernel/hypeman-go v0.28.1-0.20260902143136-e6c2b7bc0171/go.mod h1:of8qI/nef2OPLzt0EMlIRbMdJHEvuc4yWG8g/ioNg48=
8383
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
8484
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
8585
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=

‎pkg/cmd/coveragecmd_test.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ func TestParseInstanceWaitState(t *testing.T) {
8181
})
8282
}
8383

84+
func TestParseInstanceLogsSource(t *testing.T) {
85+
t.Run("accepts mixed-case source names", func(t *testing.T) {
86+
source, err := parseInstanceLogsSource("SwTpM")
87+
require.NoError(t, err)
88+
assert.Equal(t, hypeman.InstanceLogsParamsSourceSwtpm, source)
89+
})
90+
91+
t.Run("rejects unsupported source names", func(t *testing.T) {
92+
_, err := parseInstanceLogsSource("kernel")
93+
require.EqualError(t, err, "invalid source: kernel (must be app, vmm, hypeman, or swtpm)")
94+
})
95+
}
96+
8497
func TestParseAutoStandbyPorts(t *testing.T) {
8598
t.Run("parses valid port values", func(t *testing.T) {
8699
ports, err := parseAutoStandbyPorts([]string{"80", " 443 "}, "ignore-destination-port")

‎pkg/cmd/logs.go‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"context"
55
"fmt"
6+
"strings"
67

78
"github.com/kernel/hypeman-go"
89
"github.com/kernel/hypeman-go/option"
@@ -27,7 +28,7 @@ var logsCmd = cli.Command{
2728
&cli.StringFlag{
2829
Name: "source",
2930
Aliases: []string{"s"},
30-
Usage: "Log source: app (default), vmm (Cloud Hypervisor), or hypeman (operations log)",
31+
Usage: "Log source: app (default), vmm (Cloud Hypervisor), hypeman (operations log), or swtpm (software TPM emulator)",
3132
},
3233
},
3334
Action: handleLogs,
@@ -56,7 +57,11 @@ func handleLogs(ctx context.Context, cmd *cli.Command) error {
5657
params.Tail = hypeman.Opt(int64(cmd.Int("tail")))
5758
}
5859
if cmd.IsSet("source") {
59-
params.Source = hypeman.InstanceLogsParamsSource(cmd.String("source"))
60+
source, err := parseInstanceLogsSource(cmd.String("source"))
61+
if err != nil {
62+
return err
63+
}
64+
params.Source = source
6065
}
6166

6267
var opts []option.RequestOption
@@ -78,3 +83,18 @@ func handleLogs(ctx context.Context, cmd *cli.Command) error {
7883

7984
return stream.Err()
8085
}
86+
87+
func parseInstanceLogsSource(raw string) (hypeman.InstanceLogsParamsSource, error) {
88+
switch strings.ToLower(raw) {
89+
case "app":
90+
return hypeman.InstanceLogsParamsSourceApp, nil
91+
case "vmm":
92+
return hypeman.InstanceLogsParamsSourceVmm, nil
93+
case "hypeman":
94+
return hypeman.InstanceLogsParamsSourceHypeman, nil
95+
case "swtpm":
96+
return hypeman.InstanceLogsParamsSourceSwtpm, nil
97+
default:
98+
return "", fmt.Errorf("invalid source: %s (must be app, vmm, hypeman, or swtpm)", raw)
99+
}
100+
}

0 commit comments

Comments
 (0)