Skip to content

invalid slice name error should clarify min valid length is 3 #158

@polarathene

Description

@polarathene

This error confused me a bit at first, why was it invalid? Eventually I noticed a length of 3 characters for a slice key was successful. Looked up the source and the restriction appears to be due to a regex pattern constraint.

Perhaps in this case the error message could better indicate the failure was due to a minimum expected length?

$ chisel find --release /opt/chisel-release base-distroless
2024/09/11 04:48:18 Processing /opt/chisel-release release...
error: invalid slice name "cc" in slices/base-distroless.yaml

for sliceName, yamlSlice := range yamlPkg.Slices {
match := snameExp.FindStringSubmatch(sliceName)
if match == nil {
return nil, fmt.Errorf("invalid slice name %q in %s", sliceName, pkgPath)
}

// snameExp matches only the slice name, without the leading package name.
var snameExp = regexp.MustCompile(`^([a-z](?:-?[a-z0-9]){2,})$`)

Metadata

Metadata

Assignees

No one assigned

    Labels

    SimpleNice for a quick look on a minute or two

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions