Skip to content

limactl validate fails to validate lima.yml that use Go template in mount location #5670

Open

Description

@SethFalco

Description

I have a lima.yaml config that looks like this:

mounts:
  - location: "{{.Param.SshHostKeysDir}}"
    mountPoint: "/etc/ssh/ssh_host_keys"
    writable: false

param:
  SshHostKeyDir:

SshHostKeyDir is intentionally blank as it's only intended to be populated via CLI with --param "SshHostKeyDir=$(realpath .agent-devenv/ssh_host_keys)".

I generate the SSH host keys on the host, and mount them to the VM. That way I can rebuild the VM freely without disrupting known_hosts.

Change set with more context: https://git.falco.fun/ai/agent-devenv/pulls/15

However, limactl validate complains about this:

time="2026-10-21T23:31:15Z" level=fatal msg="failed to validate YAML file `lima/agent-devenv-debian-13.yml`: field `mounts[0].location` must be an absolute path, got `.`"

Potential solutions in my order of preference:

  1. The validate command should probably ignore the fields if it starts with a Go template.
  2. Alternatively, it could allow us to pass --param so that we can specify example values.
  3. Or both! (Ignore by default, or validate with specific --param values if passed to CLI.)

Activity

  1. jandubois commented on Oct 23, 2026

    @jandubois
    Member

    Potential solutions in my order of preference:

    1. The validate command should probably ignore the fields if it starts with a Go template.

    I don't see how this would work. The go templates are already evaluated by the time the lima template is validated.

    1. Alternatively, it could allow us to pass --param so that we can specify example values

    Yes, I think both limactl template validate and limactl template copy should support --set and --param options.

  2. self-assigned this
    on Oct 23, 2026
  3. SethFalco commented on Oct 23, 2026

    @SethFalco
    ContributorAuthor

    Thanks for chiming in! Yeah, I realized my first idea doesn't really fit. Sorry, my original proposal was from a user's perspective as it was before I looked at the code!

    I can see you've self-assigned this, so I'll just leave what I'd established/wrote so far anyway. Your choice if you do anything with it!

    Don't be afraid to pester though if you'd like me to handle it!


    WIP test case (doesn't handle/pass the equivalent of --param yet):

    pkg/limayaml/validate_test.go

    func TestValidateGoTemplateInLocation(t *testing.T) {
    	yamlWithGoTemplateInLocation := `
    images:
      - location: /
    mounts:
      - location: "{{.Param.AbsolutePathPassedViaCli}}"
    param:
      AbsolutePathPassedViaCli:
    `
    
    	y, err := Load(t.Context(), []byte(yamlWithGoTemplateInLocation), "template-in-location.yaml")
    	assert.NilError(t, err)
    	err = Validate(y, false)
    	assert.NilError(t, err)
    }

    The "issue" is that the Go templates are interpolated in Load. Validate doesn't have the context of which properties are dynamic or not.

    So indeed, an easier fix would probably be to make it possible to have limactl validate support args the same way other commands can.

  4. jandubois commented on Oct 23, 2026

    @jandubois
    Member

    @SethFalco Please see #5672. I'm going to leave it as a draft until I have time to properly review it; it is completely AI generated so far. I hope it does what you are looking for.

  5. added a commit that references this issue on Oct 23, 2026
    2b36b10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions