Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
a8f38271
Commit
a8f38271
authored
Jan 25, 2016
by
vaikas-google
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address CR comments
parent
0f8b3f77
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
47 deletions
+34
-47
deployments.go
manager/deployments.go
+29
-46
registryprovider.go
registry/registryprovider.go
+5
-1
No files found.
manager/deployments.go
View file @
a8f38271
...
...
@@ -246,30 +246,9 @@ func getPathVariable(w http.ResponseWriter, r *http.Request, variable, handler s
func
getTemplate
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
handler
string
)
*
common
.
Template
{
util
.
LogHandlerEntry
(
handler
,
r
)
b
:=
io
.
LimitReader
(
r
.
Body
,
*
maxLength
*
1024
)
y
,
err
:=
ioutil
.
ReadAll
(
b
)
if
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
err
,
w
)
return
nil
}
// Reject the input if it exceeded the length limit,
// since we may not have read all of it into the buffer.
if
_
,
err
=
b
.
Read
(
make
([]
byte
,
0
,
1
));
err
!=
io
.
EOF
{
e
:=
fmt
.
Errorf
(
"template exceeds maximum length of %d KB"
,
*
maxLength
)
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
e
,
w
)
return
nil
}
if
err
:=
r
.
Body
.
Close
();
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusInternalServerError
,
err
,
w
)
return
nil
}
j
,
err
:=
getJsonFromRequest
(
w
,
r
,
handler
)
j
,
err
:=
yaml
.
YAMLToJSON
(
y
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"%v
\n
%v"
,
err
,
string
(
y
))
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
e
,
w
)
return
nil
}
...
...
@@ -450,30 +429,8 @@ func getDownloadURLsHandlerFunc(w http.ResponseWriter, r *http.Request) {
func
getCredential
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
handler
string
)
*
common
.
RegistryCredential
{
util
.
LogHandlerEntry
(
handler
,
r
)
b
:=
io
.
LimitReader
(
r
.
Body
,
*
maxLength
*
1024
)
y
,
err
:=
ioutil
.
ReadAll
(
b
)
j
,
err
:=
getJsonFromRequest
(
w
,
r
,
handler
)
if
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
err
,
w
)
return
nil
}
// Reject the input if it exceeded the length limit,
// since we may not have read all of it into the buffer.
if
_
,
err
=
b
.
Read
(
make
([]
byte
,
0
,
1
));
err
!=
io
.
EOF
{
e
:=
fmt
.
Errorf
(
"template exceeds maximum length of %d KB"
,
*
maxLength
)
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
e
,
w
)
return
nil
}
if
err
:=
r
.
Body
.
Close
();
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusInternalServerError
,
err
,
w
)
return
nil
}
j
,
err
:=
yaml
.
YAMLToJSON
(
y
)
if
err
!=
nil
{
e
:=
fmt
.
Errorf
(
"%v
\n
%v"
,
err
,
string
(
y
))
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
e
,
w
)
return
nil
}
...
...
@@ -497,12 +454,13 @@ func createCredentialHandlerFunc(w http.ResponseWriter, r *http.Request) {
}
c
:=
getCredential
(
w
,
r
,
handler
)
if
c
!=
nil
{
err
=
backend
.
CreateCredential
(
credentialName
,
c
)
if
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
err
,
w
)
return
}
}
util
.
LogHandlerExitWithJSON
(
handler
,
w
,
c
,
http
.
StatusOK
)
}
...
...
@@ -523,3 +481,28 @@ func getCredentialHandlerFunc(w http.ResponseWriter, r *http.Request) {
util
.
LogHandlerExitWithJSON
(
handler
,
w
,
c
,
http
.
StatusOK
)
}
func
getJsonFromRequest
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
handler
string
)
([]
byte
,
error
)
{
util
.
LogHandlerEntry
(
handler
,
r
)
b
:=
io
.
LimitReader
(
r
.
Body
,
*
maxLength
*
1024
)
y
,
err
:=
ioutil
.
ReadAll
(
b
)
if
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
err
,
w
)
return
[]
byte
{},
err
}
// Reject the input if it exceeded the length limit,
// since we may not have read all of it into the buffer.
if
_
,
err
=
b
.
Read
(
make
([]
byte
,
0
,
1
));
err
!=
io
.
EOF
{
e
:=
fmt
.
Errorf
(
"template exceeds maximum length of %d KB"
,
*
maxLength
)
util
.
LogAndReturnError
(
handler
,
http
.
StatusBadRequest
,
e
,
w
)
return
[]
byte
{},
err
}
if
err
:=
r
.
Body
.
Close
();
err
!=
nil
{
util
.
LogAndReturnError
(
handler
,
http
.
StatusInternalServerError
,
err
,
w
)
return
[]
byte
{},
err
}
return
yaml
.
YAMLToJSON
(
y
)
}
registry/registryprovider.go
View file @
a8f38271
...
...
@@ -169,7 +169,11 @@ func (grp githubRegistryProvider) createGithubClient(credentialName string) (*gi
return
github
.
NewClient
(
tc
),
nil
}
if
c
.
BasicAuth
.
Username
!=
""
&&
c
.
BasicAuth
.
Password
!=
""
{
tp
:=
github
.
BasicAuthTransport
{
Username
:
c
.
BasicAuth
.
Username
,
Password
:
c
.
BasicAuth
.
Password
,
}
return
github
.
NewClient
(
tp
.
Client
()),
nil
}
}
...
...
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