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

Removing tf show output when streaming logs #104

Merged
merged 6 commits into from
Sep 16, 2021

Conversation

Aayyush
Copy link

@Aayyush Aayyush commented Sep 13, 2021

No description provided.

@Aayyush
Copy link
Author

Aayyush commented Sep 13, 2021

/ptal @nishkrishnan @msarvar

@Aayyush
Copy link
Author

Aayyush commented Sep 13, 2021

/ptal #orchestration

outCh <- Line{Line: message}
c.projectCmdOutputHandler.Send(ctx, message)
// Don't stream terraform show output to outCh
cmds := strings.Split(tfCmd, " ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to actually only allow plan and apply specifically instead of just having a deny list?

Upstream has support for using terraform version. and we might want to eventually support terraform import.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I think it makes sense to have an allow list for better control over what's being streamed to the web UI. I've added a LogStreamingValidCmds with init, plan, and apply commands for now. We can add more commands as we go :)

Copy link

@msarvar msarvar left a comment

Choose a reason for hiding this comment

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

looks good, there is one change that we need to make. I left a comment

s := bufio.NewScanner(stdout)
for s.Scan() {
message := s.Text()
outCh <- Line{Line: message}
Copy link

Choose a reason for hiding this comment

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

This needs to always run. outCh is used to display the terraform command output on the PR. isValidCommand is only relevant for c.projectCmdOutputHandler.Send(ctx, message)

Copy link
Author

@Aayyush Aayyush Sep 15, 2021

Choose a reason for hiding this comment

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

True! Thanks for the catch :) I've made the change you suggested.

@msarvar
Copy link

msarvar commented Sep 15, 2021

@Aayyush one more thing :) You need to add the same check for stderr. In case the command fails

s := bufio.NewScanner(stderr)
for s.Scan() {
message := s.Text()
outCh <- Line{Line: message}
c.projectCmdOutputHandler.Send(ctx, message)
}

@Aayyush Aayyush merged commit e29d7ef into release-v0.17.1-lyft.1 Sep 16, 2021
@Aayyush Aayyush deleted the aayush/remove-tf-show-output branch September 16, 2021 17:07
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.

3 participants