Commit be0a7893 authored by Geoff Simmons's avatar Geoff Simmons

Add Admin.VCLInline().

parent 5bd1e168
......@@ -35,6 +35,12 @@ import (
"time"
)
const (
// The same "nonsense" string used by varnishtest (as of 6.1)
// as the delimiter for vcl.inline commands used to run tests.
nonsense = "%XJEIFLH|)Xspa8P"
)
// Pong represents the response to the "ping" command.
type Pong struct {
Time time.Time
......@@ -189,6 +195,30 @@ func (adm *Admin) VCLLoad(config string, path string) error {
return nil
}
// VCLInline encapsulates the "vcl.inline" command. error is non-nil
// when the response was not OK. In that case, the error is an
// UnexpectedResponse, which wraps the response from Varnish.
//
// As with VCLLoad, Varnish will typically return status 106 (Param)
// when the VCL source cannot be compiled, and the error message is in
// the wrapped Response.Msg.
//
// config is the configuration name under which the VCL instance can
// be referenced afterward. The name may not be already in use. src is
// a string containing a literal VCL source.
func (adm *Admin) VCLInline(config string, src string) error {
hereSrc := "<< " + nonsense + "\n" + src + "\n" + nonsense
resp, err := adm.Command("vcl.inline", config, hereSrc)
if err != nil {
return err
}
if resp.Code != OK {
badResp := UnexpectedResponse{Response: resp}
return badResp
}
return nil
}
// VCLUse encapsulates the "vcl.use" command. error is non-nil when
// the response was not OK. In that case, the error is an
// UnexpectedResponse, which wraps the response from Varnish.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment