mirror of
https://github.com/ko-build/ko.git
synced 2025-07-15 23:54:17 +02:00
Implement "strict mode"
When ko is invoked in this mode, import paths must have the `ko://` prefix. If a human marks an import path with `ko://` and ko can't resolve the resulting import path, it fails. In "loose mode", such an import path would be silently ignored and passed on to the resolved YAML, often resulting in invalid image names (e.g., `image: github.com/foo/bar`) In loose mode, `ko://` prefixes are always ignored for backward-compatibility.
This commit is contained in:
@ -24,13 +24,13 @@ import (
|
||||
|
||||
// addResolve augments our CLI surface with resolve.
|
||||
func addResolve(topLevel *cobra.Command) {
|
||||
|
||||
lo := &options.LocalOptions{}
|
||||
no := &options.NameOptions{}
|
||||
fo := &options.FilenameOptions{}
|
||||
ta := &options.TagsOptions{}
|
||||
do := &options.DebugOptions{}
|
||||
so := &options.SelectorOptions{}
|
||||
sto := &options.StrictOptions{}
|
||||
|
||||
resolve := &cobra.Command{
|
||||
Use: "resolve -f FILENAME",
|
||||
@ -58,7 +58,7 @@ func addResolve(topLevel *cobra.Command) {
|
||||
ko resolve --local -f config/`,
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
builder, err := makeBuilder(do)
|
||||
builder, err := makeBuilder(do, sto)
|
||||
if err != nil {
|
||||
log.Fatalf("error creating builder: %v", err)
|
||||
}
|
||||
@ -66,7 +66,7 @@ func addResolve(topLevel *cobra.Command) {
|
||||
if err != nil {
|
||||
log.Fatalf("error creating publisher: %v", err)
|
||||
}
|
||||
resolveFilesToWriter(builder, publisher, fo, so, os.Stdout)
|
||||
resolveFilesToWriter(builder, publisher, fo, so, sto, os.Stdout)
|
||||
},
|
||||
}
|
||||
options.AddLocalArg(resolve, lo)
|
||||
@ -75,5 +75,6 @@ func addResolve(topLevel *cobra.Command) {
|
||||
options.AddTagsArg(resolve, ta)
|
||||
options.AddDebugArg(resolve, do)
|
||||
options.AddSelectorArg(resolve, so)
|
||||
options.AddStrictArg(resolve, sto)
|
||||
topLevel.AddCommand(resolve)
|
||||
}
|
||||
|
Reference in New Issue
Block a user