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

Commitb4a7ef8

Browse files
committed
Merge branch 'master' into minor-cleanup-tidy-up
Signed-off-by: Guillaume J. Charmes <guillaume@coder.com>
2 parentsa89511e +04a201f commitb4a7ef8

File tree

2 files changed

+75
-9
lines changed

2 files changed

+75
-9
lines changed

‎ci/steps/build.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ popd() { builtin popd >/dev/null; }
77
set -euo pipefail
88
cd"$(dirname"$0")"
99

10-
export GOARCH=amd64
1110
tag=$(git describe --tags)
1211

1312
build() {
13+
echo"Building coder-cli for$GOOS-$GOARCH..."
14+
1415
tmpdir=$(mktemp -d)
1516
go build -ldflags"-X main.version=${tag}" -o"$tmpdir/coder" ../../cmd/coder
1617

@@ -33,12 +34,11 @@ build() {
3334
# Darwin builds do not work from Linux, so only try to build them from Darwin.
3435
# See: https://github.com/cdr/coder-cli/issues/20
3536
if [["$(uname)"=="Darwin" ]];then
36-
GOOS=linux build
37-
CGO_ENABLED=1 GOOS=darwin build
38-
GOOS=windows GOARCH=386 build
39-
exit 0
37+
CGO_ENABLED=1GOOS=darwin GOARCH=amd64 build
38+
else
39+
echo"Warning: Darwin builds don't work on Linux."
40+
echo"Please use an OSX machine to build Darwin tars."
4041
fi
4142

42-
echo"Warning: Darwin builds don't work on Linux."
43-
echo"Please use an OSX machine to build Darwin tars."
44-
GOOS=linux build
43+
GOOS=linux GOARCH=amd64 build
44+
GOOS=windows GOARCH=386 build

‎coder-sdk/env.go

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"time"
77

88
"cdr.dev/coder-cli/internal/x/xjson"
9+
"golang.org/x/xerrors"
910
"nhooyr.io/websocket"
11+
"nhooyr.io/websocket/wsjson"
1012
)
1113

1214
// Environment describes a Coder environment
@@ -85,10 +87,20 @@ type CreateEnvironmentRequest struct {
8587
// CreateEnvironment sends a request to create an environment.
8688
func (cClient)CreateEnvironment(ctx context.Context,orgIDstring,reqCreateEnvironmentRequest) (*Environment,error) {
8789
varenvEnvironment
90+
<<<<<<<HEAD
8891
iferr:=c.requestBody(ctx,http.MethodPost,"/api/orgs/"+orgID+"/environments",req,&env);err!=nil {
8992
returnnil,err
9093
}
9194
return&env,nil
95+
=======
96+
err:=c.requestBody(
97+
ctx,
98+
http.MethodPost,"/api/orgs/"+orgID+"/environments",
99+
req,
100+
&env,
101+
)
102+
return&env,err
103+
>>>>>>>master
92104
}
93105

94106
// EnvironmentsByOrganization gets the list of environments owned by the given user.
@@ -111,7 +123,12 @@ func (c Client) DialWsep(ctx context.Context, env *Environment) (*websocket.Conn
111123
returnc.dialWebsocket(ctx,"/proxy/environments/"+env.ID+"/wsep")
112124
}
113125

114-
// DialEnvironmentBuildLog opens a websocket connection for the environment build log messages.
126+
// DialIDEStatus opens a websocket connection for cpu load metrics on the environment
127+
func (cClient)DialIDEStatus(ctx context.Context,envIDstring) (*websocket.Conn,error) {
128+
returnc.dialWs(ctx,"/proxy/environments/"+envID+"/ide/api/status")
129+
}
130+
131+
// DialEnvironmentBuildLog opens a websocket connection for the environment build log messages
115132
func (cClient)DialEnvironmentBuildLog(ctx context.Context,envIDstring) (*websocket.Conn,error) {
116133
returnc.dialWebsocket(ctx,"/api/environments/"+envID+"/watch-update")
117134
}
@@ -120,3 +137,52 @@ func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*web
120137
func (cClient)DialEnvironmentStats(ctx context.Context,envIDstring) (*websocket.Conn,error) {
121138
returnc.dialWebsocket(ctx,"/api/environments/"+envID+"/watch-stats")
122139
}
140+
141+
// DialResourceLoad opens a websocket connection for cpu load metrics on the environment
142+
func (cClient)DialResourceLoad(ctx context.Context,envIDstring) (*websocket.Conn,error) {
143+
returnc.dialWs(ctx,"/api/environments/"+envID+"/watch-resource-load")
144+
}
145+
146+
// BuildLogType describes the type of an event.
147+
typeBuildLogTypestring
148+
149+
const (
150+
// BuildLogTypeStart signals that a new build log has begun.
151+
BuildLogTypeStartBuildLogType="start"
152+
// BuildLogTypeStage is a stage-level event for an environment.
153+
// It can be thought of as a major step in the environment's
154+
// lifecycle.
155+
BuildLogTypeStageBuildLogType="stage"
156+
// BuildLogTypeError describes an error that has occurred.
157+
BuildLogTypeErrorBuildLogType="error"
158+
// BuildLogTypeSubstage describes a subevent that occurs as
159+
// part of a stage. This can be the output from a user's
160+
// personalization script, or a long running command.
161+
BuildLogTypeSubstageBuildLogType="substage"
162+
// BuildLogTypeDone signals that the build has completed.
163+
BuildLogTypeDoneBuildLogType="done"
164+
)
165+
166+
typebuildLogMsgstruct {
167+
TypeBuildLogType`json:"type"`
168+
}
169+
170+
// WaitForEnvironmentReady will watch the build log and return when done
171+
func (cClient)WaitForEnvironmentReady(ctx context.Context,env*Environment)error {
172+
conn,err:=c.DialEnvironmentBuildLog(ctx,env.ID)
173+
iferr!=nil {
174+
returnxerrors.Errorf("%s: dial build log: %w",env.Name,err)
175+
}
176+
177+
for {
178+
msg:=buildLogMsg{}
179+
err:=wsjson.Read(ctx,conn,&msg)
180+
iferr!=nil {
181+
returnxerrors.Errorf("%s: reading build log msg: %w",env.Name,err)
182+
}
183+
184+
ifmsg.Type==BuildLogTypeDone {
185+
returnnil
186+
}
187+
}
188+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp