Skip to content

Commit bc93c5a

Browse files
CLI: Update hypeman SDK to 0adb0e3 and add new flags (#38)
Update hypeman-go SDK to v0.10.0 (0adb0e3cc613f8f889d2d600ff06f1158de29b1c). New flags: - --entrypoint on `hypeman run` for InstanceNewParams.Entrypoint - --cmd on `hypeman run` for InstanceNewParams.Cmd - --metadata on `hypeman run` for InstanceNewParams.Metadata - --entrypoint on `hypeman start` for InstanceStartParams.Entrypoint - --cmd on `hypeman start` for InstanceStartParams.Cmd Fix: `hypeman start` now passes InstanceStartParams as required by the updated SDK signature. Co-authored-by: kernel-internal[bot] <260533166+kernel-internal[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a3ea271 commit bc93c5a

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/google/go-containerregistry v0.20.7
1111
github.com/gorilla/websocket v1.5.3
1212
github.com/itchyny/json2yaml v0.1.4
13-
github.com/kernel/hypeman-go v0.9.8
13+
github.com/kernel/hypeman-go v0.10.0
1414
github.com/muesli/reflow v0.3.0
1515
github.com/stretchr/testify v1.11.1
1616
github.com/tidwall/gjson v1.18.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnV
7272
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
7373
github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+k8=
7474
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
75-
github.com/kernel/hypeman-go v0.9.8 h1:DGx3em3Bzu/MR3mgVgu7sCe8NZxujlEUGVctnrzopXA=
76-
github.com/kernel/hypeman-go v0.9.8/go.mod h1:guRrhyP9QW/ebUS1UcZ0uZLLJeGAAhDNzSi68U4M9hI=
75+
github.com/kernel/hypeman-go v0.10.0 h1:terBKYBwHAtDic425oUrb3RZMo0Q0DrXjPiVNmDXblE=
76+
github.com/kernel/hypeman-go v0.10.0/go.mod h1:guRrhyP9QW/ebUS1UcZ0uZLLJeGAAhDNzSi68U4M9hI=
7777
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
7878
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
7979
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=

pkg/cmd/lifecycle.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ var stopCmd = cli.Command{
1919
}
2020

2121
var startCmd = cli.Command{
22-
Name: "start",
23-
Usage: "Start a stopped instance",
24-
ArgsUsage: "<instance>",
22+
Name: "start",
23+
Usage: "Start a stopped instance",
24+
ArgsUsage: "<instance>",
25+
Flags: []cli.Flag{
26+
&cli.StringSliceFlag{
27+
Name: "entrypoint",
28+
Usage: "Override image entrypoint for this run (can be repeated for multiple args)",
29+
},
30+
&cli.StringSliceFlag{
31+
Name: "cmd",
32+
Usage: "Override image CMD for this run (can be repeated for multiple args)",
33+
},
34+
},
2535
Action: handleStart,
2636
HideHelpCommand: true,
2737
}
@@ -89,9 +99,18 @@ func handleStart(ctx context.Context, cmd *cli.Command) error {
8999
opts = append(opts, debugMiddlewareOption)
90100
}
91101

102+
params := hypeman.InstanceStartParams{}
103+
104+
if entrypoint := cmd.StringSlice("entrypoint"); len(entrypoint) > 0 {
105+
params.Entrypoint = entrypoint
106+
}
107+
if cmdArgs := cmd.StringSlice("cmd"); len(cmdArgs) > 0 {
108+
params.Cmd = cmdArgs
109+
}
110+
92111
fmt.Fprintf(os.Stderr, "Starting %s...\n", args[0])
93112

94-
instance, err := client.Instances.Start(ctx, instanceID, opts...)
113+
instance, err := client.Instances.Start(ctx, instanceID, params, opts...)
95114
if err != nil {
96115
return err
97116
}

pkg/cmd/run.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ Examples:
108108
Name: "skip-kernel-headers",
109109
Usage: "Skip kernel headers installation during boot for faster startup (DKMS will not work)",
110110
},
111+
// Entrypoint and CMD overrides
112+
&cli.StringSliceFlag{
113+
Name: "entrypoint",
114+
Usage: "Override image entrypoint (can be repeated for multiple args)",
115+
},
116+
&cli.StringSliceFlag{
117+
Name: "cmd",
118+
Usage: "Override image CMD (can be repeated for multiple args)",
119+
},
120+
// Metadata flags
121+
&cli.StringSliceFlag{
122+
Name: "metadata",
123+
Aliases: []string{"l"},
124+
Usage: "Set metadata key-value pair (KEY=VALUE, can be repeated)",
125+
},
111126
// Volume mount flags
112127
&cli.StringSliceFlag{
113128
Name: "volume",
@@ -244,6 +259,29 @@ func handleRun(ctx context.Context, cmd *cli.Command) error {
244259
params.SkipKernelHeaders = hypeman.Opt(cmd.Bool("skip-kernel-headers"))
245260
}
246261

262+
// Entrypoint and CMD overrides
263+
if entrypoint := cmd.StringSlice("entrypoint"); len(entrypoint) > 0 {
264+
params.Entrypoint = entrypoint
265+
}
266+
if cmdArgs := cmd.StringSlice("cmd"); len(cmdArgs) > 0 {
267+
params.Cmd = cmdArgs
268+
}
269+
270+
// Metadata
271+
metadataSpecs := cmd.StringSlice("metadata")
272+
if len(metadataSpecs) > 0 {
273+
metadata := make(map[string]string)
274+
for _, m := range metadataSpecs {
275+
parts := strings.SplitN(m, "=", 2)
276+
if len(parts) == 2 {
277+
metadata[parts[0]] = parts[1]
278+
} else {
279+
fmt.Fprintf(os.Stderr, "Warning: ignoring malformed metadata: %s\n", m)
280+
}
281+
}
282+
params.Metadata = metadata
283+
}
284+
247285
// Volume mounts
248286
volumeSpecs := cmd.StringSlice("volume")
249287
if len(volumeSpecs) > 0 {

0 commit comments

Comments
 (0)