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

Refactor Log Parsing #255

Merged
merged 1 commit into from
Sep 4, 2019
Merged

Refactor Log Parsing #255

merged 1 commit into from
Sep 4, 2019

Conversation

tdmanv
Copy link
Contributor

@tdmanv tdmanv commented Aug 29, 2019

Change Overview

  • Makes log handling synchronous
  • Adds parse function to output package

Pull request type

Please check the type of change your PR introduces:

  • Work in Progress
  • Refactoring (no functional changes, no api changes)
  • Trival/Minor
  • Bugfix
  • Feature
  • Documentation

Issues

Test Plan

[09:59:15]tom@tom-XPS-13-9360: (refactor-pod-runner)~/src/kanister/ make shell
launching a shell in the containerized build environment
/go/src/github.com/kanisterio/kanister # go test -v ./pkg/function -check.v -check.f TestKubeTask
=== RUN   Test
time="2019-08-29T17:00:15Z" level=info msg="Out: ###Phase-output###: {\"key\":\"version\",\"value\":\"0.21.0\"}"
time="2019-08-29T17:00:30Z" level=info msg="Out: Tick: 1"
time="2019-08-29T17:00:30Z" level=info msg="Out: Tick: 2"
time="2019-08-29T17:00:31Z" level=info msg="Out: Tick: 3"
PASS: kube_task_test.go:122: KubeTaskSuite.TestKubeTask 44.716s
OK: 1 passed
--- PASS: Test (44.74s)
PASS
ok      github.com/kanisterio/kanister/pkg/function     44.759s
  • Manual
  • Unit test
  • E2E

func LogAndParse(ctx context.Context, r io.ReadCloser) (map[string]interface{}, error) {
out := make(map[string]interface{})
err := splitLines(ctx, r, func(ctx context.Context, l string) error {
log.Info("Pod Out:", l)
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor] after Out:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

log.Info automatically inserts a space between items


func Log(ctx context.Context, r io.ReadCloser) error {
err := splitLines(ctx, r, func(ctx context.Context, l string) error {
log.Info("Pod Out:", l)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@tdmanv tdmanv merged commit 42d113d into master Sep 4, 2019
@tdmanv tdmanv deleted the refactor-log-parsing branch September 4, 2019 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants