-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicitly extract tar.gz files from plugins that upload them #47
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,13 +153,15 @@ func (s *Server) nodeResultsHandler(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
// Parse the path into the node name and the type | ||
node, resultType := parts[0], parts[1] | ||
// Parse the path into the node name, result type, and extension | ||
node, file := parts[0], parts[1] | ||
resultType, extension := parseFileName(file) | ||
|
||
glog.Infof("got %v result from %v\n", resultType, node) | ||
|
||
result := &plugin.Result{ | ||
ResultType: resultType, | ||
Extension: extension, | ||
NodeName: node, | ||
Body: r.Body, | ||
} | ||
|
@@ -183,7 +185,6 @@ func (s *Server) globalResultsHandler(w http.ResponseWriter, r *http.Request) { | |
http.NotFound(w, r) | ||
return | ||
} | ||
resultType := parts[0] | ||
|
||
// We accept PUT because the client is specifying the resource identifier via | ||
// the HTTP path. (As opposed to POST, where typically the clients would post | ||
|
@@ -198,11 +199,13 @@ func (s *Server) globalResultsHandler(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
resultType, extension := parseFileName(parts[0]) | ||
glog.Infof("got %v result\n", resultType) | ||
|
||
result := &plugin.Result{ | ||
NodeName: "", | ||
ResultType: resultType, | ||
Extension: extension, | ||
Body: r.Body, | ||
} | ||
|
||
|
@@ -212,3 +215,16 @@ func (s *Server) globalResultsHandler(w http.ResponseWriter, r *http.Request) { | |
s.ResultsCallback(result, w) | ||
r.Body.Close() | ||
} | ||
|
||
// given an uploaded filename, parse it into its base name and extension. If | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use https://golang.org/pkg/path/filepath/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL. But looks like |
||
// there are no "." characters, the extension will be blank and the name will | ||
// be set to the filename as-is | ||
func parseFileName(file string) (name string, extension string) { | ||
filenameParts := strings.SplitN(file, ".", 2) | ||
|
||
if len(filenameParts) == 2 { | ||
return filenameParts[0], "." + filenameParts[1] | ||
} | ||
|
||
return file, "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could switch case this as we'll likely have other file options to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we can cross that bridge when we get there... it's possible we'll want to something more intelligent like some full post-processing logic that lives somewhere else, etc.