1
0
mirror of https://github.com/ko-build/ko.git synced 2025-07-12 23:50:31 +02:00

Use cobra's RunE wherever possible (#343)

This commit is contained in:
Jason Hall
2021-04-22 12:37:42 -04:00
committed by GitHub
parent 75ab99123d
commit 29cd8e09e9
6 changed files with 41 additions and 49 deletions

View File

@ -15,7 +15,7 @@
package commands
import (
"log"
"fmt"
"os"
"github.com/google/ko/pkg/commands/options"
@ -54,20 +54,18 @@ func addResolve(topLevel *cobra.Command) {
# This always preserves import paths.
ko resolve --local -f config/`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
ctx := createCancellableContext()
builder, err := makeBuilder(ctx, bo)
if err != nil {
log.Fatalf("error creating builder: %v", err)
return fmt.Errorf("error creating builder: %v", err)
}
publisher, err := makePublisher(po)
if err != nil {
log.Fatalf("error creating publisher: %v", err)
return fmt.Errorf("error creating publisher: %v", err)
}
defer publisher.Close()
if err := resolveFilesToWriter(ctx, builder, publisher, fo, so, os.Stdout); err != nil {
log.Fatal(err)
}
return resolveFilesToWriter(ctx, builder, publisher, fo, so, os.Stdout)
},
}
options.AddPublishArg(resolve, po)