Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
caddy
Commits
3a795de8
Commit
3a795de8
authored
Jun 09, 2015
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #117 from zmb3/errorfmt
Update error strings (start with lowercase letters)
parents
cde60ed6
3aff1677
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
27 additions
and
27 deletions
+27
-27
app/app.go
app/app.go
+2
-2
config/config.go
config/config.go
+2
-2
config/setup/browse.go
config/setup/browse.go
+1
-1
config/setup/git.go
config/setup/git.go
+3
-3
middleware/commands.go
middleware/commands.go
+2
-2
middleware/git/git.go
middleware/git/git.go
+5
-5
middleware/git/git_test.go
middleware/git/git_test.go
+1
-1
middleware/git/webhook/github_hook.go
middleware/git/webhook/github_hook.go
+5
-5
middleware/markdown/metadata.go
middleware/markdown/metadata.go
+2
-2
middleware/proxy/proxy.go
middleware/proxy/proxy.go
+1
-1
middleware/rewrite/rewrite.go
middleware/rewrite/rewrite.go
+1
-1
server/server.go
server/server.go
+2
-2
No files found.
app/app.go
View file @
3a795de8
...
...
@@ -54,7 +54,7 @@ func SetCPU(cpu string) error {
pctStr
:=
cpu
[
:
len
(
cpu
)
-
1
]
pctInt
,
err
:=
strconv
.
Atoi
(
pctStr
)
if
err
!=
nil
||
pctInt
<
1
||
pctInt
>
100
{
return
errors
.
New
(
"
I
nvalid CPU value: percentage must be between 1-100"
)
return
errors
.
New
(
"
i
nvalid CPU value: percentage must be between 1-100"
)
}
percent
=
float32
(
pctInt
)
/
100
numCPU
=
int
(
float32
(
availCPU
)
*
percent
)
...
...
@@ -62,7 +62,7 @@ func SetCPU(cpu string) error {
// Number
num
,
err
:=
strconv
.
Atoi
(
cpu
)
if
err
!=
nil
||
num
<
1
{
return
errors
.
New
(
"
I
nvalid CPU value: provide a number or percent greater than 0"
)
return
errors
.
New
(
"
i
nvalid CPU value: provide a number or percent greater than 0"
)
}
numCPU
=
num
}
...
...
config/config.go
View file @
3a795de8
...
...
@@ -100,7 +100,7 @@ func ArrangeBindings(allConfigs []server.Config) (map[*net.TCPAddr][]server.Conf
for
_
,
conf
:=
range
allConfigs
{
newAddr
,
err
:=
net
.
ResolveTCPAddr
(
"tcp"
,
conf
.
Address
())
if
err
!=
nil
{
return
addresses
,
errors
.
New
(
"
C
ould not serve "
+
conf
.
Address
()
+
" - "
+
err
.
Error
())
return
addresses
,
errors
.
New
(
"
c
ould not serve "
+
conf
.
Address
()
+
" - "
+
err
.
Error
())
}
// Make sure to compare the string representation of the address,
...
...
@@ -130,7 +130,7 @@ func ArrangeBindings(allConfigs []server.Config) (map[*net.TCPAddr][]server.Conf
if
configs
[
0
]
.
TLS
.
Enabled
{
otherConfigProto
=
"HTTPS"
}
return
addresses
,
fmt
.
Errorf
(
"
C
onfiguration error: Cannot multiplex %s (%s) and %s (%s) on same address"
,
return
addresses
,
fmt
.
Errorf
(
"
c
onfiguration error: Cannot multiplex %s (%s) and %s (%s) on same address"
,
configs
[
0
]
.
Address
(),
otherConfigProto
,
config
.
Address
(),
thisConfigProto
)
}
}
...
...
config/setup/browse.go
View file @
3a795de8
...
...
@@ -33,7 +33,7 @@ func browseParse(c *Controller) ([]browse.Config, error) {
appendCfg
:=
func
(
bc
browse
.
Config
)
error
{
for
_
,
c
:=
range
configs
{
if
c
.
PathScope
==
bc
.
PathScope
{
return
fmt
.
Errorf
(
"
D
uplicate browsing config for %s"
,
c
.
PathScope
)
return
fmt
.
Errorf
(
"
d
uplicate browsing config for %s"
,
c
.
PathScope
)
}
}
configs
=
append
(
configs
,
bc
)
...
...
config/setup/git.go
View file @
3a795de8
...
...
@@ -132,7 +132,7 @@ func gitParse(c *Controller) (*git.Repo, error) {
repo
.
URL
,
repo
.
Host
,
err
=
sanitizeGit
(
repo
.
URL
)
// TODO add Windows support for private repos
if
runtime
.
GOOS
==
"windows"
{
return
nil
,
fmt
.
Errorf
(
"
P
rivate repository not yet supported on Windows"
)
return
nil
,
fmt
.
Errorf
(
"
p
rivate repository not yet supported on Windows"
)
}
}
...
...
@@ -162,7 +162,7 @@ func sanitizeHTTP(repoURL string) (string, string, error) {
url
.
Path
=
url
.
Path
[
len
(
"git@"
)
:
]
i
:=
strings
.
Index
(
url
.
Path
,
":"
)
if
i
<
0
{
return
""
,
""
,
fmt
.
Errorf
(
"
I
nvalid git url %s"
,
repoURL
)
return
""
,
""
,
fmt
.
Errorf
(
"
i
nvalid git url %s"
,
repoURL
)
}
url
.
Host
=
url
.
Path
[
:
i
]
url
.
Path
=
"/"
+
url
.
Path
[
i
+
1
:
]
...
...
@@ -191,7 +191,7 @@ func sanitizeGit(repoURL string) (string, string, error) {
if
url
,
err
:=
url
.
Parse
(
repoURL
);
err
==
nil
&&
strings
.
HasPrefix
(
url
.
Scheme
,
"http"
)
{
repoURL
=
fmt
.
Sprintf
(
"git@%v:%v"
,
url
.
Host
,
url
.
Path
[
1
:
])
}
else
{
return
""
,
""
,
fmt
.
Errorf
(
"
I
nvalid git url %s"
,
repoURL
)
return
""
,
""
,
fmt
.
Errorf
(
"
i
nvalid git url %s"
,
repoURL
)
}
}
hostURL
:=
repoURL
[
len
(
"git@"
)
:
]
...
...
middleware/commands.go
View file @
3a795de8
...
...
@@ -11,10 +11,10 @@ import (
func
SplitCommandAndArgs
(
command
string
)
(
cmd
string
,
args
[]
string
,
err
error
)
{
parts
,
err
:=
shlex
.
Split
(
command
)
if
err
!=
nil
{
err
=
errors
.
New
(
"
E
rror parsing command: "
+
err
.
Error
())
err
=
errors
.
New
(
"
e
rror parsing command: "
+
err
.
Error
())
return
}
else
if
len
(
parts
)
==
0
{
err
=
errors
.
New
(
"
N
o command contained in '"
+
command
+
"'"
)
err
=
errors
.
New
(
"
n
o command contained in '"
+
command
+
"'"
)
return
}
...
...
middleware/git/git.go
View file @
3a795de8
...
...
@@ -189,11 +189,11 @@ func (r *Repo) Prepare() error {
}
}
if
err
!=
nil
{
return
fmt
.
Errorf
(
"
C
annot retrieve repo url for %v Error: %v"
,
r
.
Path
,
err
)
return
fmt
.
Errorf
(
"
c
annot retrieve repo url for %v Error: %v"
,
r
.
Path
,
err
)
}
return
fmt
.
Errorf
(
"
A
nother git repo '%v' exists at %v"
,
repoURL
,
r
.
Path
)
return
fmt
.
Errorf
(
"
a
nother git repo '%v' exists at %v"
,
repoURL
,
r
.
Path
)
}
return
fmt
.
Errorf
(
"
C
annot git clone into %v, directory not empty."
,
r
.
Path
)
return
fmt
.
Errorf
(
"
c
annot git clone into %v, directory not empty."
,
r
.
Path
)
}
// getMostRecentCommit gets the hash of the most recent commit to the
...
...
@@ -250,7 +250,7 @@ func Init() error {
// locate git binary in path
var
err
error
if
gitBinary
,
err
=
gos
.
LookPath
(
"git"
);
err
!=
nil
{
return
fmt
.
Errorf
(
"
G
it middleware requires git installed. Cannot find git binary in PATH"
)
return
fmt
.
Errorf
(
"
g
it middleware requires git installed. Cannot find git binary in PATH"
)
}
// locate bash in PATH. If not found, fallback to sh.
...
...
@@ -259,7 +259,7 @@ func Init() error {
if
_
,
err
=
gos
.
LookPath
(
"bash"
);
err
!=
nil
{
shell
=
"sh"
if
_
,
err
=
gos
.
LookPath
(
"sh"
);
err
!=
nil
{
return
fmt
.
Errorf
(
"
G
it middleware requires either bash or sh."
)
return
fmt
.
Errorf
(
"
g
it middleware requires either bash or sh."
)
}
}
return
nil
...
...
middleware/git/git_test.go
View file @
3a795de8
...
...
@@ -133,7 +133,7 @@ Command echo Hello successful.
continue
}
expected
:=
"
A
nother git repo 'git@github.com:u1/repo.git' exists at gitdir"
expected
:=
"
a
nother git repo 'git@github.com:u1/repo.git' exists at gitdir"
if
expected
!=
err
.
Error
()
{
t
.
Errorf
(
"Pull with Error %v: Expected %v found %v"
,
i
,
expected
,
err
.
Error
())
}
...
...
middleware/git/webhook/github_hook.go
View file @
3a795de8
...
...
@@ -45,7 +45,7 @@ func (g GithubHook) DoesHandle(h http.Header) bool {
func
(
g
GithubHook
)
Handle
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
repo
*
git
.
Repo
)
(
int
,
error
)
{
if
r
.
Method
!=
"POST"
{
return
http
.
StatusMethodNotAllowed
,
errors
.
New
(
"
T
he request had an invalid method."
)
return
http
.
StatusMethodNotAllowed
,
errors
.
New
(
"
t
he request had an invalid method."
)
}
// read full body - required for signature
...
...
@@ -58,7 +58,7 @@ func (g GithubHook) Handle(w http.ResponseWriter, r *http.Request, repo *git.Rep
event
:=
r
.
Header
.
Get
(
"X-Github-Event"
)
if
event
==
""
{
return
http
.
StatusBadRequest
,
errors
.
New
(
"
T
he 'X-Github-Event' header is required but was missing."
)
return
http
.
StatusBadRequest
,
errors
.
New
(
"
t
he 'X-Github-Event' header is required but was missing."
)
}
switch
event
{
...
...
@@ -98,7 +98,7 @@ func (g GithubHook) handleSignature(r *http.Request, body []byte, secret string)
expectedMac
:=
hex
.
EncodeToString
(
mac
.
Sum
(
nil
))
if
signature
[
5
:
]
!=
expectedMac
{
return
errors
.
New
(
"
C
ould not verify request signature. The signature is invalid!"
)
return
errors
.
New
(
"
c
ould not verify request signature. The signature is invalid!"
)
}
}
}
...
...
@@ -118,7 +118,7 @@ func (g GithubHook) handlePush(body []byte, repo *git.Repo) error {
// and if it matches with our locally tracked one, pull.
refSlice
:=
strings
.
Split
(
push
.
Ref
,
"/"
)
if
len
(
refSlice
)
!=
3
{
return
errors
.
New
(
"
T
he push request contained an invalid reference string."
)
return
errors
.
New
(
"
t
he push request contained an invalid reference string."
)
}
branch
:=
refSlice
[
2
]
...
...
@@ -139,7 +139,7 @@ func (g GithubHook) handleRelease(body []byte, repo *git.Repo) error {
}
if
release
.
Release
.
TagName
==
""
{
return
errors
.
New
(
"
T
he release request contained an invalid TagName."
)
return
errors
.
New
(
"
t
he release request contained an invalid TagName."
)
}
logger
()
.
Printf
(
"Received new release '%s'. -> Updating local repository to this release.
\n
"
,
release
.
Release
.
Name
)
...
...
middleware/markdown/metadata.go
View file @
3a795de8
...
...
@@ -205,7 +205,7 @@ func extractMetadata(parser MetadataParser, b []byte) (metadata []byte, markdown
line
:=
bytes
.
TrimSpace
(
scanner
.
Bytes
())
if
!
bytes
.
Equal
(
line
,
parser
.
Opening
())
{
return
nil
,
b
,
fmt
.
Errorf
(
"
W
rong identifier"
)
return
nil
,
b
,
fmt
.
Errorf
(
"
w
rong identifier"
)
}
// buffer for metadata contents
...
...
@@ -232,7 +232,7 @@ func extractMetadata(parser MetadataParser, b []byte) (metadata []byte, markdown
}
// closing identifier not found
return
buf
.
Bytes
(),
nil
,
fmt
.
Errorf
(
"
M
etadata not closed. '%v' not found"
,
string
(
parser
.
Closing
()))
return
buf
.
Bytes
(),
nil
,
fmt
.
Errorf
(
"
m
etadata not closed. '%v' not found"
,
string
(
parser
.
Closing
()))
}
// findParser finds the parser using line that contains opening identifier
...
...
middleware/proxy/proxy.go
View file @
3a795de8
...
...
@@ -11,7 +11,7 @@ import (
"github.com/mholt/caddy/middleware"
)
var
errUnreachable
=
errors
.
New
(
"
U
nreachable backend"
)
var
errUnreachable
=
errors
.
New
(
"
u
nreachable backend"
)
// Proxy represents a middleware instance that can proxy requests.
type
Proxy
struct
{
...
...
middleware/rewrite/rewrite.go
View file @
3a795de8
...
...
@@ -83,7 +83,7 @@ func NewRegexpRule(base, pattern, to string, ext []string) (*RegexpRule, error)
if
len
(
v
)
<
2
||
(
len
(
v
)
<
3
&&
v
[
0
]
==
'!'
)
{
// check if no extension is specified
if
v
!=
"/"
&&
v
!=
"!/"
{
return
nil
,
fmt
.
Errorf
(
"
I
nvalid extension %v"
,
v
)
return
nil
,
fmt
.
Errorf
(
"
i
nvalid extension %v"
,
v
)
}
}
}
...
...
server/server.go
View file @
3a795de8
...
...
@@ -38,7 +38,7 @@ func New(addr string, configs []Config, tls bool) (*Server, error) {
for
_
,
conf
:=
range
configs
{
if
_
,
exists
:=
s
.
vhosts
[
conf
.
Host
];
exists
{
return
nil
,
fmt
.
Errorf
(
"
C
annot serve %s - host already defined for address %s"
,
conf
.
Address
(),
s
.
address
)
return
nil
,
fmt
.
Errorf
(
"
c
annot serve %s - host already defined for address %s"
,
conf
.
Address
(),
s
.
address
)
}
vh
:=
virtualHost
{
config
:
conf
}
...
...
@@ -175,7 +175,7 @@ func setupClientAuth(tlsConfigs []TLSConfig, config *tls.Config) error {
return
err
}
if
!
pool
.
AppendCertsFromPEM
(
caCrt
)
{
return
fmt
.
Errorf
(
"
E
rror loading client certificate '%s': no certificates were successfully parsed"
,
caFile
)
return
fmt
.
Errorf
(
"
e
rror loading client certificate '%s': no certificates were successfully parsed"
,
caFile
)
}
}
}
...
...
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