Add version validation to install commands

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
pull/3024/head
Stefan Prodan 2 years ago
parent c56f338b12
commit 8a0fd6ddf9
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF

@ -18,6 +18,7 @@ package main
import (
"fmt"
"strings"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/manifestgen/install"
@ -28,6 +29,10 @@ func getVersion(input string) (string, error) {
return rootArgs.defaults.Version, nil
}
if input != install.MakeDefaultOptions().Version && !strings.HasPrefix(input, "v") {
return "", fmt.Errorf("targeted version '%s' must be prefixed with 'v'", input)
}
if isEmbeddedVersion(input) {
return input, nil
}

Loading…
Cancel
Save