@@ -5,6 +5,8 @@ package preview
5
5
6
6
import (
7
7
"context"
8
+ "fmt"
9
+ "strings"
8
10
9
11
"github.com/spf13/cobra"
10
12
"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -44,6 +46,8 @@ func GetPreviewRunner(provider provider.Provider, ioStreams genericclioptions.IO
44
46
cmd .Flags ().BoolVar (& noPrune , "no-prune" , noPrune , "If true, do not prune previously applied objects." )
45
47
cmd .Flags ().BoolVar (& serverDryRun , "server-side" , serverDryRun , "If true, preview runs in the server instead of the client." )
46
48
cmd .Flags ().BoolVar (& previewDestroy , "destroy" , previewDestroy , "If true, preview of destroy operations will be displayed." )
49
+ cmd .Flags ().StringVar (& r .output , "output" , printers .DefaultPrinter (),
50
+ fmt .Sprintf ("Output format, must be one of %s" , strings .Join (printers .SupportedPrinters (), "," )))
47
51
48
52
r .Command = cmd
49
53
return r
@@ -62,6 +66,8 @@ type PreviewRunner struct {
62
66
Applier * apply.Applier
63
67
Destroyer * apply.Destroyer
64
68
provider provider.Provider
69
+
70
+ output string
65
71
}
66
72
67
73
// RunE is the function run from the cobra command.
@@ -133,6 +139,6 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
133
139
134
140
// The printer will print updates from the channel. It will block
135
141
// until the channel is closed.
136
- printer := printers .GetPrinter (printers . EventsPrinter , r .ioStreams )
142
+ printer := printers .GetPrinter (r . output , r .ioStreams )
137
143
return printer .Print (ch , drs )
138
144
}
0 commit comments