@@ -74,23 +74,23 @@ func TestNodeContextWrite(t *testing.T) {
7474 },
7575 // Table format
7676 {
77- context : formatter.Context {Format : NewFormat ("table" , false )},
77+ context : formatter.Context {Format : newFormat ("table" , false )},
7878 expected : `ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
7979nodeID1 foobar_baz Foo Drain Leader 18.03.0-ce
8080nodeID2 foobar_bar Bar Active Reachable 1.2.3
8181nodeID3 foobar_boo Boo Active ` + "\n " , // (to preserve whitespace)
8282 clusterInfo : swarm.ClusterInfo {TLSInfo : swarm.TLSInfo {TrustRoot : "hi" }},
8383 },
8484 {
85- context : formatter.Context {Format : NewFormat ("table" , true )},
85+ context : formatter.Context {Format : newFormat ("table" , true )},
8686 expected : `nodeID1
8787nodeID2
8888nodeID3
8989` ,
9090 clusterInfo : swarm.ClusterInfo {TLSInfo : swarm.TLSInfo {TrustRoot : "hi" }},
9191 },
9292 {
93- context : formatter.Context {Format : NewFormat ("table {{.Hostname}}" , false )},
93+ context : formatter.Context {Format : newFormat ("table {{.Hostname}}" , false )},
9494 expected : `HOSTNAME
9595foobar_baz
9696foobar_bar
@@ -99,7 +99,7 @@ foobar_boo
9999 clusterInfo : swarm.ClusterInfo {TLSInfo : swarm.TLSInfo {TrustRoot : "hi" }},
100100 },
101101 {
102- context : formatter.Context {Format : NewFormat ("table {{.Hostname}}" , true )},
102+ context : formatter.Context {Format : newFormat ("table {{.Hostname}}" , true )},
103103 expected : `HOSTNAME
104104foobar_baz
105105foobar_bar
@@ -108,7 +108,7 @@ foobar_boo
108108 clusterInfo : swarm.ClusterInfo {TLSInfo : swarm.TLSInfo {TrustRoot : "hi" }},
109109 },
110110 {
111- context : formatter.Context {Format : NewFormat ("table {{.ID}}\t {{.Hostname}}\t {{.TLSStatus}}" , false )},
111+ context : formatter.Context {Format : newFormat ("table {{.ID}}\t {{.Hostname}}\t {{.TLSStatus}}" , false )},
112112 expected : `ID HOSTNAME TLS STATUS
113113nodeID1 foobar_baz Needs Rotation
114114nodeID2 foobar_bar Ready
@@ -117,7 +117,7 @@ nodeID3 foobar_boo Unknown
117117 clusterInfo : swarm.ClusterInfo {TLSInfo : swarm.TLSInfo {TrustRoot : "hi" }},
118118 },
119119 { // no cluster TLS status info, TLS status for all nodes is unknown
120- context : formatter.Context {Format : NewFormat ("table {{.ID}}\t {{.Hostname}}\t {{.TLSStatus}}" , false )},
120+ context : formatter.Context {Format : newFormat ("table {{.ID}}\t {{.Hostname}}\t {{.TLSStatus}}" , false )},
121121 expected : `ID HOSTNAME TLS STATUS
122122nodeID1 foobar_baz Unknown
123123nodeID2 foobar_bar Unknown
@@ -127,7 +127,7 @@ nodeID3 foobar_boo Unknown
127127 },
128128 // Raw Format
129129 {
130- context : formatter.Context {Format : NewFormat ("raw" , false )},
130+ context : formatter.Context {Format : newFormat ("raw" , false )},
131131 expected : `node_id: nodeID1
132132hostname: foobar_baz
133133status: Foo
@@ -148,7 +148,7 @@ manager_status: ` + "\n\n", // to preserve whitespace
148148 clusterInfo : swarm.ClusterInfo {TLSInfo : swarm.TLSInfo {TrustRoot : "hi" }},
149149 },
150150 {
151- context : formatter.Context {Format : NewFormat ("raw" , true )},
151+ context : formatter.Context {Format : newFormat ("raw" , true )},
152152 expected : `node_id: nodeID1
153153node_id: nodeID2
154154node_id: nodeID3
@@ -157,7 +157,7 @@ node_id: nodeID3
157157 },
158158 // Custom Format
159159 {
160- context : formatter.Context {Format : NewFormat ("{{.Hostname}} {{.TLSStatus}}" , false )},
160+ context : formatter.Context {Format : newFormat ("{{.Hostname}} {{.TLSStatus}}" , false )},
161161 expected : `foobar_baz Needs Rotation
162162foobar_bar Ready
163163foobar_boo Unknown
@@ -205,7 +205,7 @@ foobar_boo Unknown
205205 var out bytes.Buffer
206206 tc .context .Output = & out
207207
208- err := FormatWrite (tc .context , nodes , system.Info {Swarm : swarm.Info {Cluster : & tc .clusterInfo }})
208+ err := formatWrite (tc .context , nodes , system.Info {Swarm : swarm.Info {Cluster : & tc .clusterInfo }})
209209 if err != nil {
210210 assert .Error (t , err , tc .expected )
211211 } else {
@@ -252,7 +252,7 @@ func TestNodeContextWriteJSON(t *testing.T) {
252252 {ID : "nodeID3" , Description : swarm.NodeDescription {Hostname : "foobar_boo" , Engine : swarm.EngineDescription {EngineVersion : "18.03.0-ce" }}},
253253 }
254254 out := bytes .NewBufferString ("" )
255- err := FormatWrite (formatter.Context {Format : "{{json .}}" , Output : out }, nodes , testcase .info )
255+ err := formatWrite (formatter.Context {Format : "{{json .}}" , Output : out }, nodes , testcase .info )
256256 if err != nil {
257257 t .Fatal (err )
258258 }
@@ -272,7 +272,7 @@ func TestNodeContextWriteJSONField(t *testing.T) {
272272 {ID : "nodeID2" , Description : swarm.NodeDescription {Hostname : "foobar_bar" }},
273273 }
274274 out := bytes .NewBufferString ("" )
275- err := FormatWrite (formatter.Context {Format : "{{json .ID}}" , Output : out }, nodes , system.Info {})
275+ err := formatWrite (formatter.Context {Format : "{{json .ID}}" , Output : out }, nodes , system.Info {})
276276 if err != nil {
277277 t .Fatal (err )
278278 }
@@ -317,10 +317,10 @@ func TestNodeInspectWriteContext(t *testing.T) {
317317 }
318318 out := bytes .NewBufferString ("" )
319319 context := formatter.Context {
320- Format : NewFormat ("pretty" , false ),
320+ Format : newFormat ("pretty" , false ),
321321 Output : out ,
322322 }
323- err := InspectFormatWrite (context , []string {"nodeID1" }, func (string ) (any , []byte , error ) {
323+ err := inspectFormatWrite (context , []string {"nodeID1" }, func (string ) (any , []byte , error ) {
324324 return node , nil , nil
325325 })
326326 if err != nil {
0 commit comments