1 Commits
Author SHA1 Message Date
Michael WesemannandClaude Opus 5 ae936420e0 [mike@mwxm4]
The address question comes up with "auto" in it.

A site with an address tool hands addresses out from it — that is what the tool
is configured for — so typing the word every time was asking somebody to
confirm the ordinary case by hand. It stands in the line now, and Enter is the
whole answer:

    address for web05, "auto" for one from dns, empty for DHCP: auto

Offered rather than made the meaning of the empty line. Every answer keeps the
meaning it had: erased back to nothing it is DHCP again, or whatever the chosen
specification says, and an address typed by hand is still typed by hand. Enter
commits nothing either — what is fetched here is handed straight back when the
deployment is not confirmed.

The prefilled line is input's own doing (inputWith), with the cursor at the end
of it, so it is a default that can be seen. One that cannot be seen is a
question answered by what was not typed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 14:53:42 +02:00
5 changed files with 47 additions and 7 deletions
+9 -2
View File
@@ -571,9 +571,16 @@ when it will not say.
gvm new --from ubuntu-tpl --name web05 --ip auto
Where the site has a tool that hands addresses out, `--ip auto` asks it instead
of making you look one up first. In the list the same word does it:
of making you look one up first. In the list the same word does it, and it is
already standing in the line — a site with a tool hands addresses out from it,
so that is the answer Enter gives:
address for web05, "auto" for one from dns, empty for DHCP:
address for web05, "auto" for one from dns, empty for DHCP: auto
It is offered rather than made the meaning of the empty line, so every answer
keeps the meaning it had: erased back to nothing it is DHCP again, or whatever
the chosen specification says. And Enter commits nothing — an address fetched
here is handed straight back when the deployment is not confirmed.
It shells out to `dns`, the Infoblox helper — found on the path by that name, or
named as `dnstool` in `~/.gvmrc` where it lives somewhere else. Everything it
+17 -2
View File
@@ -711,7 +711,9 @@ func (b *browser) deploy(r vmRow) {
//
// Empty is an answer: it leaves whatever the specification says, which is
// usually DHCP, and that is the ordinary case on a network that hands out
// addresses.
// addresses. Where the site has a tool of its own, the ordinary case is the
// other one — so "auto" is in the line when the question appears, and Enter
// takes it.
func (b *browser) deployAddress(r vmRow, src deploySource, t deployTarget, name string, opts deployOpts) {
// Empty is an answer, and it means two different things: with gvm's own
// specification it leaves the adapter on DHCP, and with one of the
@@ -728,11 +730,24 @@ func (b *browser) deployAddress(r vmRow, src deploySource, t deployTarget, name
leave = "empty to leave it to " + opts.spec
}
ask := SF("address for %s, %s: ", name, leave)
// And where there is a tool, its word is standing in the line already, so
// Enter is the whole answer. That is what the tool is configured for: a
// site that has one hands out addresses from it, and typing "auto" every
// time is asking somebody to confirm the ordinary case by hand.
//
// Offered rather than made the meaning of the empty line, so that every
// answer keeps the meaning it had: erased back to nothing it is DHCP again,
// or whatever the specification says. Nor does pressing Enter commit
// anything — an address fetched here is handed straight back where the
// deployment is not confirmed (deployStep.giveBack).
preset := ""
if opts.dns.there() {
ask = SF("address for %s, %q for one from dns, %s: ", name, autoIP, leave)
preset = autoIP
}
ip, ok := b.input(ask)
ip, ok := b.inputWith(ask, preset)
if !ok {
b.setStatus(colDim, "nothing done")
return
+12 -2
View File
@@ -1300,8 +1300,18 @@ func (e *editor) key(k key) (finished, accepted bool) {
// input reads one line in the status area and reports whether it was finished
// rather than abandoned. It has its own key loop, so nothing that is typed here
// reaches the filter.
func (b *browser) input(label string) (string, bool) {
b.edit = &editor{label: label}
func (b *browser) input(label string) (string, bool) { return b.inputWith(label, "") }
// inputWith is the same with an answer already standing in the line, for a
// question that has one ordinary answer worth offering: Enter takes it, and
// Backspace is how it is refused. It is a default one can see — which is the
// only kind worth having, since a question whose answer is decided by what was
// not typed is one nobody knows they have agreed to.
//
// The cursor sits at the end of it, so typing carries on from the answer rather
// than into the middle of it.
func (b *browser) inputWith(label, preset string) (string, bool) {
b.edit = &editor{label: label, runes: []rune(preset), cursor: len([]rune(preset))}
defer func() { b.edit = nil }()
for {
+8
View File
@@ -581,6 +581,8 @@ func TestTheAddressQuestionReadsAsASentence(t *testing.T) {
t.Setenv("COLUMNS", "100")
t.Setenv("LINES", "24")
tool, _ := fakeInfoblox(t) // for its there(), not for its answers
for _, c := range []struct {
what string
opts deployOpts
@@ -589,6 +591,12 @@ func TestTheAddressQuestionReadsAsASentence(t *testing.T) {
{"gvm's own specification", deployOpts{how: customSite, st: testSite()}, "empty for DHCP"},
{"one the vCenter holds", deployOpts{how: customSpec, spec: "linux-static"},
"leave it to linux-static"},
// With an address tool, the answer it would give is standing in the
// line already: that is what the tool is there for, and the question
// still has to say what the other two answers mean.
{"a site with an address tool",
deployOpts{how: customSite, st: testSite(), dns: tool},
`"auto" for one from dns, empty for DHCP: auto`},
} {
r := templateRow("ubuntu-tpl")
b := &browser{rows: []vmRow{r}, view: []int{0}}
+1 -1
View File
@@ -1 +1 @@
1.3.8
1.3.9