carlosabalde/libvmod-cfg

Failed to parse remote

amoghyermalkar123 opened this issue · 3 comments

sub vcl_init {
        new env = cfg.env();

        if (env.is_set("VCL_SETTINGS")) {
                new settings = cfg.file(env.get("VCL_SETTINGS"));
        }

        new settings_two = cfg.file("http://127.0.0.1:2015/config.json");
}

settings is where i try to read and parse a local json file and settings_two is where i read and parse a remote json file.

Both of these operations fail with the same error:

[CFG][file_parse_ini:152] Failed to parse remote (file=settings, location=file:///etc/varnish/config.json, is_backup=0, format=ini,>

[CFG][file_parse_ini:152] Failed to parse remote (file=settings_two, location=http://127.0.0.1:2015/config.json, is_backup=0, ...

Why would this not be working?

My versions:
varnish : 6.2.1
cfg vmod : 6.2-archived

This is how I set VCL_SETTINGS Environment variable:

I edit the varnish.service file to have :

Environment="VCL_SETTINGS=file:///etc/varnish/config.json"

I now see the error msg more closely the file name is file_parse_ini does this mean it only takes INI files?

If so, what is the correct way to read and parse JSON files with this VMOD?

You need to specify the format when reading the file: format=json.