-
Notifications
You must be signed in to change notification settings - Fork 129
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
Log endpoint uses multipart form #1228
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c19d44e
Log endpoint uses multipart form
jameskerr 7f09529
Update zealot tests
jameskerr faf8f35
Make jest root src
jameskerr 051fc79
Added UploadProgress to ZealotPayloads type
jameskerr 2321212
Extract parse method and NEW_LINE const
jameskerr f793636
Create an iterator that can have values pushed into it
jameskerr f390600
Add an upload method to the fetcher
jameskerr 82faa76
Test for upload method
jameskerr a10c4aa
Use the UploadProgress in the ingest file flow
jameskerr 16097cd
Fix type error
jameskerr a8dcc03
Check warnings before iterating
jameskerr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import {FileListData} from "./fileList" | ||
import detectFileType from "./detectFileType" | ||
|
||
export default function(paths: string[]): Promise<FileListData> { | ||
export default function(files: File[]): Promise<FileListData> { | ||
return Promise.all( | ||
paths.map(async (path) => { | ||
const type = await detectFileType(path) | ||
return {type, path} | ||
files.map(async (file) => { | ||
const type = await detectFileType(file.path) | ||
return {type, file} | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,52 @@ | ||
import {IngestFileType} from "./detectFileType" | ||
import lib from "../../lib" | ||
|
||
export type FileListData = {type: IngestFileType; path: string}[] | ||
export type FileListData = {type: IngestFileType; file: File}[] | ||
|
||
export default function fileList(files: FileListData) { | ||
export default function fileList(list: FileListData) { | ||
return { | ||
first() { | ||
return files[0] | ||
return list[0] | ||
}, | ||
|
||
oneFile() { | ||
return files.length === 1 | ||
return list.length === 1 | ||
}, | ||
|
||
multiple() { | ||
return files.length > 1 | ||
return list.length > 1 | ||
}, | ||
|
||
paths(): string[] { | ||
return files.map((f) => f.path) | ||
return list.map((f) => f.file.path) | ||
}, | ||
|
||
files(): File[] { | ||
return list.map((f) => f.file) | ||
}, | ||
|
||
any(type: string) { | ||
return !!files.find((f) => f.type === type) | ||
return !!list.find((f) => f.type === type) | ||
}, | ||
|
||
allPcap() { | ||
return files.every((f) => f.type === "pcap") | ||
return list.every((f) => f.type === "pcap") | ||
}, | ||
|
||
mixed() { | ||
return !files.every((f) => f.type === files[0].type) | ||
return !list.every((f) => f.type === list[0].type) | ||
}, | ||
|
||
inSameDir() { | ||
return files.every( | ||
(f) => lib.file(f.path).dirName() === lib.file(files[0].path).dirName() | ||
return list.every( | ||
(item) => | ||
lib.file(item.file.path).dirName() === | ||
lib.file(list[0].file.path).dirName() | ||
) | ||
}, | ||
|
||
dirName() { | ||
return lib.file(files[0].path).dirName() | ||
return lib.file(list[0].file.path).dirName() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
not sure if you considered extending the
File
interface by annotating it with the newtype
field? would save all the extra.file.
s since it would be flattened, just a thought!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.
Yeah true, I usually try to stay away from extending things like that. "Compose rather than inherit" mindset I guess. Is this something that is done conventionally in go?
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 think the composition vs inheritance dilemma is the same in go. I do agree with the compose > inheritance mindset, but thought that in this case with just these two types, and one always depending on the other, extending would grant the small bonus of less typing as you access the imbedded File interface. I have no strong feelings in this case at all though!