Skip to content

source.variant vs image.variant confusion #916

@nbuwe

Description

@nbuwe

There seems to be some confusion w.r.t. source.variant and image.variant and I think I've ended up getting it wrong while working on PR-#904, but I think that's b/c I looked at the wrong selection of examples. The notes below are a bit all over the place - apologies if the narration falls apart, but I hope they demonstrate the problem.

source.md documents source.variant as:

The variant field is only used in a few distributions and defaults to default.

image.md documents image.variant as:

The variant field can be anything and is used in the Incus metadata as well as for filtering.

However note, that shared/definition.go sets the image's variant to "default":

// Set default variant
if d.Image.Variant == "" {
d.Image.Variant = "default"
}

And different sources look at different "variant"s. E.g. Ubuntu checks the one from the image:

switch strings.ToLower(s.definition.Image.Variant) {
case "default":
baseURL = fmt.Sprintf("%s/releases/%s/release/", s.definition.Source.URL,
s.definition.Image.Release)

while apertis-http.go seems to use both source:

baseURL = fmt.Sprintf("%s/%s/%s",
s.definition.Source.URL, s.definition.Source.Variant, release)

and (a few lines down) image:

baseURL = fmt.Sprintf("%s/%s/%s/%s/",
baseURL, exactRelease, s.definition.Image.ArchitectureMapped, s.definition.Image.Variant)
fname := fmt.Sprintf("ospack_%s-%s-%s_%s.tar.gz",
release, s.definition.Image.ArchitectureMapped, s.definition.Image.Variant, exactRelease)

I looked at the Ubuntu example, so I used image in my Alpaquita PR, but aside from the above all other sources use source.variant (which defaults to an empty string, despite what docs claim - see above) e.g.:

if s.definition.Source.Variant != "" {
args = append(args, "--variant", s.definition.Source.Variant)
}

At least all the filtering code consistently use image.variant for variants filters. apertis seems to be confused, and only ubuntu faces potential issues when the same variant (image.variant) value is used both for source selection and for filtering and there's a risk of breaking existing configs that currently happen to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions