Skip to content

Instantly share code, notes, and snippets.

@daghf
Created January 16, 2014 11:33
Show Gist options
  • Save daghf/8453440 to your computer and use it in GitHub Desktop.
Save daghf/8453440 to your computer and use it in GitHub Desktop.
List VCL variable availability for 4.0
#!/usr/bin/env python
# Simple script that outputs all available VCL variables
# available in the various functions in 4.0 VCL.
#
# Execute this from the lib/libvcc directory of the varnish-cache
# master branch
from collections import defaultdict
from generate import sp_variables, returns
def printvars(vars):
if len(vars['r']) > 0:
print " R:"
print " ",
print "\n ".join(vars['r'])
if len(vars['w']) > 0:
print " W:"
print " ",
print "\n ".join(vars['w'])
print ""
def dict_factory():
return {'r': [], 'w': []}
vcl_funcvars = defaultdict(dict_factory)
for var in sp_variables:
for func in var[2]:
vcl_funcvars[func]['r'].append(var[0])
for func in var[3]:
vcl_funcvars[func]['w'].append(var[0])
funcs = [ { 'name': x[0], 'class': x[1] } for x in returns ]
for x in [ 'all', 'client', 'backend' ]:
print x
printvars(vcl_funcvars[x])
for func in funcs:
print "%s: %s" % (func['name'], func['class'])
printvars(vcl_funcvars[func['name']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment