Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Add coder envs rebuild and watch-build commands #146

Merged
merged 1 commit into from
Oct 20, 2020
Merged

Conversation

cmoog
Copy link
Contributor

@cmoog cmoog commented Oct 20, 2020

$ coder envs rebuild entdev --follow
Rebuild environment "entdev"? (will destroy any work outside of /home): y█
✅ -- 2020-10-20T00:43:06Z Ensuring private SSH key
✅ -- 2020-10-20T00:43:06Z Deleting old environment
✅ -- 2020-10-20T00:43:50Z Deleting old network isolation policy
✅ -- 2020-10-20T00:43:50Z Deleting old service
✅ -- 2020-10-20T00:43:51Z Getting default user from image
✅ -- 2020-10-20T00:43:56Z Ensuring environment has a home volume
✅ -- 2020-10-20T00:43:56Z Creating network isolation policy
✅ -- 2020-10-20T00:43:56Z Ensuring environment service

Comment on lines +175 to +185
// BuildLogFollowMsg wraps the base BuildLog and adds a field for collecting
// errors that may occur when follow or parsing.
type BuildLogFollowMsg struct {
BuildLog
Err error
}

// FollowEnvironmentBuildLog trails the build log of a Coder environment.
func (c Client) FollowEnvironmentBuildLog(ctx context.Context, envID string) (<-chan BuildLogFollowMsg, error) {
ch := make(chan BuildLogFollowMsg)
ws, err := c.DialEnvironmentBuildLog(ctx, envID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@f0ssel @coadler Any thoughts on this pattern? Seems better to me than having a BuildLogWatcher type with methods for iterating when channels are designed for that.

@cmoog cmoog marked this pull request as ready for review October 20, 2020 00:58
@cmoog cmoog requested a review from fuskovic October 20, 2020 02:49
return l.Err
}
switch l.BuildLog.Type {
case coder.BuildLogTypeStart:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to do anything for this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The FE uses this to reset the UI logs, but since we're just trailing I don't think it makes sense to do anything. Plus we exit after the Done message is sent anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense.

I think that explanation should be plugged in as a comment.

fmt.Print(color.RedString("\t%s", l.BuildLog.Msg))
s = newSpinner()
case coder.BuildLogTypeDone:
s.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that s could be nil here or is it safe to assume we'll always have assigned the return value of newSpinner to s before we get here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good catch. Assuming the build log records are properly formed, this shouldn't be an issue. That said, I'll push a change that better handles the nil case to avoid panics.

@cmoog cmoog force-pushed the envs-rebuild branch 3 times, most recently from 077cfa8 to a14543a Compare October 20, 2020 15:11
@cmoog cmoog merged commit 70615c4 into master Oct 20, 2020
@cmoog cmoog deleted the envs-rebuild branch October 20, 2020 16:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants