3030)
3131
3232// NewFormat returns a Format for rendering using a config Context
33+ //
34+ // Deprecated: this function was only used internally and will be removed in the next release.
3335func NewFormat (source string , quiet bool ) formatter.Format {
36+ return newFormat (source , quiet )
37+ }
38+
39+ // newFormat returns a Format for rendering using a configContext.
40+ func newFormat (source string , quiet bool ) formatter.Format {
3441 switch source {
3542 case formatter .PrettyFormatKey :
3643 return configInspectPrettyTemplate
@@ -44,7 +51,14 @@ func NewFormat(source string, quiet bool) formatter.Format {
4451}
4552
4653// FormatWrite writes the context
47- func FormatWrite (ctx formatter.Context , configs []swarm.Config ) error {
54+ //
55+ // Deprecated: this function was only used internally and will be removed in the next release.
56+ func FormatWrite (fmtCtx formatter.Context , configs []swarm.Config ) error {
57+ return formatWrite (fmtCtx , configs )
58+ }
59+
60+ // formatWrite writes the context
61+ func formatWrite (fmtCtx formatter.Context , configs []swarm.Config ) error {
4862 render := func (format func (subContext formatter.SubContext ) error ) error {
4963 for _ , config := range configs {
5064 configCtx := & configContext {c : config }
@@ -54,7 +68,7 @@ func FormatWrite(ctx formatter.Context, configs []swarm.Config) error {
5468 }
5569 return nil
5670 }
57- return ctx .Write (newConfigContext (), render )
71+ return fmtCtx .Write (newConfigContext (), render )
5872}
5973
6074func newConfigContext () * configContext {
@@ -115,9 +129,16 @@ func (c *configContext) Label(name string) string {
115129}
116130
117131// InspectFormatWrite renders the context for a list of configs
118- func InspectFormatWrite (ctx formatter.Context , refs []string , getRef inspect.GetRefFunc ) error {
119- if ctx .Format != configInspectPrettyTemplate {
120- return inspect .Inspect (ctx .Output , refs , string (ctx .Format ), getRef )
132+ //
133+ // Deprecated: this function was only used internally and will be removed in the next release.
134+ func InspectFormatWrite (fmtCtx formatter.Context , refs []string , getRef inspect.GetRefFunc ) error {
135+ return inspectFormatWrite (fmtCtx , refs , getRef )
136+ }
137+
138+ // inspectFormatWrite renders the context for a list of configs
139+ func inspectFormatWrite (fmtCtx formatter.Context , refs []string , getRef inspect.GetRefFunc ) error {
140+ if fmtCtx .Format != configInspectPrettyTemplate {
141+ return inspect .Inspect (fmtCtx .Output , refs , string (fmtCtx .Format ), getRef )
121142 }
122143 render := func (format func (subContext formatter.SubContext ) error ) error {
123144 for _ , ref := range refs {
@@ -135,7 +156,7 @@ func InspectFormatWrite(ctx formatter.Context, refs []string, getRef inspect.Get
135156 }
136157 return nil
137158 }
138- return ctx .Write (& configInspectContext {}, render )
159+ return fmtCtx .Write (& configInspectContext {}, render )
139160}
140161
141162type configInspectContext struct {
0 commit comments