Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishapi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishapi
Commits
be0a7893
Commit
be0a7893
authored
Nov 29, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Admin.VCLInline().
parent
5bd1e168
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
cli.go
pkg/admin/cli.go
+30
-0
No files found.
pkg/admin/cli.go
View file @
be0a7893
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment