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

feat(coderd): add support for external agents to API's and provisioner#19286

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kacpersaw merged 14 commits intomainfromkacpersaw/feat-coder-attach-api
Aug 19, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
60dc330
feat: add support for external agents to API's and provisioner
kacpersawAug 11, 2025
10fc9fe
generate api model
kacpersawAug 11, 2025
5f344a1
move /external-agent/{agent}/credentials endpoint to enterprise
kacpersawAug 11, 2025
28243e3
add Content-Digest header to init script response
kacpersawAug 11, 2025
d560e5c
implement license checks for external agents in workspace builds and …
kacpersawAug 12, 2025
732bc1d
Update license_test.go
kacpersawAug 12, 2025
5ca172e
Apply review suggestions
kacpersawAug 13, 2025
10e6853
Add HasExternalAgent to TemplateVersion response
kacpersawAug 13, 2025
760de9a
Update tests
kacpersawAug 13, 2025
3e2288b
add HasLicense field to Options and update UsageChecker
kacpersawAug 13, 2025
ee58237
remove HasLicense field from Options and implement HasLicense method …
kacpersawAug 13, 2025
b91397d
return 404 if external_agent is not associated with agent
kacpersawAug 13, 2025
fb7bc71
update external agent handling in workspace agents and adjust Terrafo…
kacpersawAug 13, 2025
0baf2b3
Remove test
kacpersawAug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletioncli/testdata/coder_list_--output_json.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,8 @@
"most_recently_seen": null
},
"template_version_preset_id": null,
"has_ai_task": false
"has_ai_task": false,
"has_external_agent": false
},
"latest_app_status": null,
"outdated": false,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@
"last_seen_at": "====[timestamp]=====",
"name": "test-daemon",
"version": "v0.0.0-devel",
"api_version": "1.8",
"api_version": "1.9",
"provisioners": [
"echo"
],
Expand Down
94 changes: 93 additions & 1 deletioncoderd/apidoc/docs.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

86 changes: 85 additions & 1 deletioncoderd/apidoc/swagger.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

3 changes: 3 additions & 0 deletionscoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1566,6 +1566,9 @@ func New(options *Options) *API {
r.Use(apiKeyMiddleware)
r.Get("/", api.tailnetRPCConn)
})
r.Route("/init-script", func(r chi.Router) {
r.Get("/{os}/{arch}", api.initScript)
})
})

if options.SwaggerEndpoint {
Expand Down
6 changes: 4 additions & 2 deletionscoderd/coderdtest/swaggerparser.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -310,7 +310,8 @@ func assertSecurityDefined(t *testing.T, comment SwaggerComment) {
comment.router == "/" ||
comment.router == "/users/login" ||
comment.router == "/users/otp/request" ||
comment.router == "/users/otp/change-password" {
comment.router == "/users/otp/change-password" ||
comment.router == "/init-script/{os}/{arch}" {
return // endpoints do not require authorization
}
assert.Containsf(t, authorizedSecurityTags, comment.security, "@Security must be either of these options: %v", authorizedSecurityTags)
Expand DownExpand Up@@ -361,7 +362,8 @@ func assertProduce(t *testing.T, comment SwaggerComment) {
(comment.router == "/licenses/{id}" && comment.method == "delete") ||
(comment.router == "/debug/coordinator" && comment.method == "get") ||
(comment.router == "/debug/tailnet" && comment.method == "get") ||
(comment.router == "/workspaces/{workspace}/acl" && comment.method == "patch") {
(comment.router == "/workspaces/{workspace}/acl" && comment.method == "patch") ||
(comment.router == "/init-script/{os}/{arch}" && comment.method == "get") {
return // Exception: HTTP 200 is returned without response entity
}

Expand Down
6 changes: 6 additions & 0 deletionscoderd/entitlements/entitlements.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,3 +161,9 @@ func (l *Set) Errors() []string {
defer l.entitlementsMu.RUnlock()
return slices.Clone(l.entitlements.Errors)
}

func (l *Set) HasLicense() bool {
l.entitlementsMu.RLock()
defer l.entitlementsMu.RUnlock()
return l.entitlements.HasLicense
}
45 changes: 45 additions & 0 deletionscoderd/initscript.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
package coderd

import (
"crypto/sha256"
"encoding/base64"
"fmt"
"net/http"
"strings"

"github.com/go-chi/chi/v5"

"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisionersdk"
)

// @Summary Get agent init script
// @ID get-agent-init-script
// @Produce text/plain
// @Tags InitScript
// @Param os path string true "Operating system"
// @Param arch path string true "Architecture"
// @Success 200 "Success"
// @Router /init-script/{os}/{arch} [get]
func (api *API) initScript(rw http.ResponseWriter, r *http.Request) {
os := strings.ToLower(chi.URLParam(r, "os"))
arch := strings.ToLower(chi.URLParam(r, "arch"))

script, exists := provisionersdk.AgentScriptEnv()[fmt.Sprintf("CODER_AGENT_SCRIPT_%s_%s", os, arch)]
if !exists {
httpapi.Write(r.Context(), rw, http.StatusBadRequest, codersdk.Response{
Message: fmt.Sprintf("Unknown os/arch: %s/%s", os, arch),
})
return
}
script = strings.ReplaceAll(script, "${ACCESS_URL}", api.AccessURL.String()+"/")
script = strings.ReplaceAll(script, "${AUTH_TYPE}", "token")

scriptBytes := []byte(script)
hash := sha256.Sum256(scriptBytes)
rw.Header().Set("Content-Digest", fmt.Sprintf("sha256:%x", base64.StdEncoding.EncodeToString(hash[:])))
rw.Header().Set("Content-Type", "text/plain; charset=utf-8")
rw.WriteHeader(http.StatusOK)
_, _ = rw.Write(scriptBytes)
}
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp