Skip to content

Commit b313e1b

Browse files
hi-leiclaude
andcommitted
fix: apply template description and improve description default
- Apply template description to VM when deploying from template - Description default now matches web UI: image-type + instance-type joined with dashes instead of duplicating hostname Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1f75209 commit b313e1b

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

internal/verda-cli/cmd/vm/template_apply.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ func applyTemplate(tmpl *template.Template, opts *createOptions) {
154154
if tmpl.HostnamePattern != "" && opts.Hostname == "" {
155155
opts.Hostname = template.ExpandHostnamePattern(tmpl.HostnamePattern, opts.LocationCode)
156156
}
157+
if tmpl.Description != "" && opts.Description == "" {
158+
opts.Description = tmpl.Description
159+
}
157160
// SSH keys and startup script are handled by resolveTemplateNames, not here.
158161
}
159162

internal/verda-cli/cmd/vm/wizard.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,17 @@ func stepDescription(opts *createOptions) wizard.Step {
777777
Prompt: wizard.TextInputPrompt,
778778
Required: false,
779779
DependsOn: []string{"hostname"},
780-
Default: func(c map[string]any) any {
781-
if h, ok := c["hostname"].(string); ok && h != "" {
782-
return h
780+
Default: func(_ map[string]any) any {
781+
// Match web UI: image-type + instance-type joined with dash.
782+
parts := make([]string, 0, 2)
783+
if opts.Image != "" {
784+
parts = append(parts, strings.ReplaceAll(opts.Image, ".", "-"))
785+
}
786+
if opts.InstanceType != "" {
787+
parts = append(parts, strings.ReplaceAll(opts.InstanceType, ".", "-"))
788+
}
789+
if len(parts) > 0 {
790+
return strings.Join(parts, "-")
783791
}
784792
return ""
785793
},

internal/verda-cli/cmd/vm/wizard_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ func TestBuildCreateFlowHappyPath(t *testing.T) {
5858
if opts.IsSpot {
5959
t.Error("expected IsSpot=false for on-demand")
6060
}
61-
if opts.Description != "my-gpu" {
62-
t.Errorf("expected description=my-gpu (defaulted from hostname), got %q", opts.Description)
61+
// Description defaults to image-type + instance-type joined with dashes.
62+
expectedDesc := "ubuntu-24-04-cuda-12-8-open-docker-1V100-6V"
63+
if opts.Description != expectedDesc {
64+
t.Errorf("expected description=%q, got %q", expectedDesc, opts.Description)
6365
}
6466
}
6567

0 commit comments

Comments
 (0)