cli/command/plugin: deprecate NewFormat, FormatWrite
It's part of the presentation logic of the cli, and only used internally. We can consider providing utilities for these, but better as part of separate packages. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -21,7 +21,14 @@ enabled: {{.Enabled}}
|
||||
)
|
||||
|
||||
// NewFormat returns a Format for rendering using a plugin Context
|
||||
//
|
||||
// Deprecated: this function was only used internally and will be removed in the next release.
|
||||
func NewFormat(source string, quiet bool) formatter.Format {
|
||||
return newFormat(source, quiet)
|
||||
}
|
||||
|
||||
// newFormat returns a Format for rendering using a pluginContext.
|
||||
func newFormat(source string, quiet bool) formatter.Format {
|
||||
switch source {
|
||||
case formatter.TableFormatKey:
|
||||
if quiet {
|
||||
@ -38,10 +45,17 @@ func NewFormat(source string, quiet bool) formatter.Format {
|
||||
}
|
||||
|
||||
// FormatWrite writes the context
|
||||
func FormatWrite(ctx formatter.Context, plugins []*plugin.Plugin) error {
|
||||
//
|
||||
// Deprecated: this function was only used internally and will be removed in the next release.
|
||||
func FormatWrite(fmtCtx formatter.Context, plugins []*plugin.Plugin) error {
|
||||
return formatWrite(fmtCtx, plugins)
|
||||
}
|
||||
|
||||
// formatWrite writes the context
|
||||
func formatWrite(fmtCtx formatter.Context, plugins []*plugin.Plugin) error {
|
||||
render := func(format func(subContext formatter.SubContext) error) error {
|
||||
for _, p := range plugins {
|
||||
pluginCtx := &pluginContext{trunc: ctx.Trunc, p: *p}
|
||||
pluginCtx := &pluginContext{trunc: fmtCtx.Trunc, p: *p}
|
||||
if err := format(pluginCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -56,7 +70,7 @@ func FormatWrite(ctx formatter.Context, plugins []*plugin.Plugin) error {
|
||||
"Enabled": enabledHeader,
|
||||
"PluginReference": formatter.ImageHeader,
|
||||
}
|
||||
return ctx.Write(&pluginCtx, render)
|
||||
return fmtCtx.Write(&pluginCtx, render)
|
||||
}
|
||||
|
||||
type pluginContext struct {
|
||||
|
||||
Reference in New Issue
Block a user