[master] 92e2e3d5e mgt_vcl: Move vcl.deps to the VTE API

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Aug 21 20:52:08 UTC 2023


commit 92e2e3d5ecfbefcb7f00718e67b9f95effcedbd6
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Aug 17 15:28:57 2023 +0200

    mgt_vcl: Move vcl.deps to the VTE API

diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 69b35371e..2b46db352 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -46,6 +46,7 @@
 #include "vcli_serve.h"
 #include "vct.h"
 #include "vev.h"
+#include "vte.h"
 #include "vtim.h"
 
 struct vclstate {
@@ -1012,23 +1013,25 @@ mcf_vcl_deps(struct cli *cli, const char * const *av, void *priv)
 {
 	struct vclprog *vp;
 	struct vcldep *vd;
-	struct vsb *vsb;
+	struct vte *vte;
 
 	(void)av;
 	(void)priv;
 
-	vsb = VSB_new_auto();
-	AN(vsb);
+	vte = VTE_new(2, 80);
+	AN(vte);
 
 	VTAILQ_FOREACH(vp, &vclhead, list) {
 		if (VTAILQ_EMPTY(&vp->dfrom)) {
-			VSB_printf(vsb, "%s\n", vp->name);
+			VTE_printf(vte, "%s\n", vp->name);
 			continue;
 		}
 		VTAILQ_FOREACH(vd, &vp->dfrom, lfrom)
-			VSB_printf(vsb, "%s\t%s\n", vp->name, vd->to->name);
+			VTE_printf(vte, "%s\t%s\n", vp->name, vd->to->name);
 	}
-	VCLI_VTE(cli, &vsb, 80);
+	AZ(VTE_finish(vte));
+	AZ(VTE_format(vte, VCLI_VTE_format, cli));
+	VTE_destroy(&vte);
 }
 
 static void v_matchproto_(cli_func_t)
diff --git a/bin/varnishtest/tests/s00005.vtc b/bin/varnishtest/tests/s00005.vtc
index 3ed6c0193..a0780cd93 100644
--- a/bin/varnishtest/tests/s00005.vtc
+++ b/bin/varnishtest/tests/s00005.vtc
@@ -132,3 +132,16 @@ varnish v1 -cliexpect \
 	{would create a loop} \
 	{vcl.label lblA vcl5}
 
+# omitting ^vcl1 line to only get aligned fields
+varnish v1 -cliexpect {
+vcl2
+label1           vcl1
+label2           vcl1
+label3           vcl1
+slartibartfast   vcl1
+vcl3
+lblA             vcl3
+vcl4             lblA
+lblB             vcl4
+vcl5             lblB
+} vcl.deps


More information about the varnish-commit mailing list