Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit89752df

Browse files
committed
Add build log types
1 parent77d3e64 commit89752df

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

‎coder-sdk/env.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package coder
22

33
import (
44
"context"
5-
"fmt"
65
"net/http"
76
"time"
87

98
"cdr.dev/coder-cli/internal/x/xjson"
9+
"golang.org/x/xerrors"
1010
"nhooyr.io/websocket"
1111
"nhooyr.io/websocket/wsjson"
1212
)
@@ -138,25 +138,45 @@ func (c Client) DialResourceLoad(ctx context.Context, envID string) (*websocket.
138138
returnc.dialWs(ctx,"/api/environments/"+envID+"/watch-resource-load")
139139
}
140140

141+
// BuildLogType describes the type of an event.
142+
typeBuildLogTypestring
143+
144+
const (
145+
// BuildLogTypeStart signals that a new build log has begun.
146+
BuildLogTypeStartBuildLogType="start"
147+
// BuildLogTypeStage is a stage-level event for an environment.
148+
// It can be thought of as a major step in the environment's
149+
// lifecycle.
150+
BuildLogTypeStageBuildLogType="stage"
151+
// BuildLogTypeError describes an error that has occurred.
152+
BuildLogTypeErrorBuildLogType="error"
153+
// BuildLogTypeSubstage describes a subevent that occurs as
154+
// part of a stage. This can be the output from a user's
155+
// personalization script, or a long running command.
156+
BuildLogTypeSubstageBuildLogType="substage"
157+
// BuildLogTypeDone signals that the build has completed.
158+
BuildLogTypeDoneBuildLogType="done"
159+
)
160+
141161
typebuildLogMsgstruct {
142-
Typestring`json:"type"`
162+
TypeBuildLogType`json:"type"`
143163
}
144164

145165
// WaitForEnvironmentReady will watch the build log and return when done
146166
func (cClient)WaitForEnvironmentReady(ctx context.Context,env*Environment)error {
147167
conn,err:=c.DialEnvironmentBuildLog(ctx,env.ID)
148168
iferr!=nil {
149-
returnfmt.Errorf("%s: dial build log: %w",env.Name,err)
169+
returnxerrors.Errorf("%s: dial build log: %w",env.Name,err)
150170
}
151171

152172
for {
153173
msg:=buildLogMsg{}
154174
err:=wsjson.Read(ctx,conn,&msg)
155175
iferr!=nil {
156-
returnfmt.Errorf("%s: reading build log msg: %w",env.Name,err)
176+
returnxerrors.Errorf("%s: reading build log msg: %w",env.Name,err)
157177
}
158178

159-
ifmsg.Type=="done" {
179+
ifmsg.Type==BuildLogTypeDone {
160180
returnnil
161181
}
162182
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp