Skip to content
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

feat: Server side logs #31

Merged
merged 8 commits into from
Feb 20, 2023
Merged

Conversation

adityathebe
Copy link
Member

Addresses #30

@CLAassistant
Copy link

CLAassistant commented Jan 17, 2023

CLA assistant check
All committers have signed the CLA.

@moshloop
Copy link
Member

@adityathebe can you add an integration test for this ?

@adityathebe
Copy link
Member Author

@moshloop I've added integration test.

for scanner.Scan() {
fileContents[path] = append(fileContents[path], logs.Result{
Time: fInfo.ModTime().Format(time.RFC3339),
// Labels: , all the records will have the same labels. Is it necessary to add it here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should also add the filename

for _, path := range paths {
fInfo, err := os.Stat(path)
if err != nil {
return nil, fmt.Errorf("error get file stat. path=%s; %w", path, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be an error, just returning an empty result

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified this. On error, it'll continue reading other files

@adityathebe
Copy link
Member Author

@moshloop should be good now

func readFilesLines(paths []string, labelsToAttach map[string]string) logsPerFile {
fileContents := make(logsPerFile, len(paths))
for _, path := range paths {
fInfo, err := os.Stat(path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add support for globs ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support

pkg/files/search.go Outdated Show resolved Hide resolved

// MergeMap will merge map b into a.
// On key collision, map b takes precedence.
func MergeMap(a, b map[string]string) map[string]string {
Copy link
Member Author

@adityathebe adityathebe Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moshloop Do we have a common go pkg with small helper funcs like this one? Don't want this in here. I could create pkg/helper and move it there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moshloop moshloop merged commit 014f42f into flanksource:main Feb 20, 2023
@github-actions
Copy link

🎉 This PR is included in version 0.0.21 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants