Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions changelog.d/added-18516-remote-write-identity-settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Settings → Repos → Reference repos: owner-only "Post on other projects as" control (Hive bot, falling back to me / Hive bot only / Me) for `project.remote_write_identity`, a per-repo line saying which identity posts there and why, `PUT /api/config/reference-repos/write-identity`, and the docs (#18516).
103 changes: 103 additions & 0 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6505,6 +6505,18 @@
"items": {
"type": "string"
}
},
"write_identity": {
"type": "string"
},
"write_identities": {
"type": "array",
"items": {
"type": "string"
}
},
"bot_login": {
"type": "string"
}
}
}
Expand Down Expand Up @@ -6559,6 +6571,18 @@
"items": {
"type": "string"
}
},
"write_identity": {
"type": "string"
},
"write_identities": {
"type": "array",
"items": {
"type": "string"
}
},
"bot_login": {
"type": "string"
}
}
}
Expand All @@ -6577,6 +6601,85 @@
}
}
},
"/api/config/reference-repos/write-identity": {
"put": {
"tags": [
"System"
],
"summary": "Set the remote write identity",
"description": "Sets project.remote_write_identity: whose name the hive's writes to granted reference repos carry (bot: the App bot where the repo's owner installed the App, else the owner's connected account; bot_only: the App bot or read-only; owner: the owner's connected account). Refused when a hand-written write entry would have no credential under the new value. Re-resolves the reference repos before answering. Owner only.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"write_identity"
],
"properties": {
"write_identity": {
"type": "string",
"enum": [
"bot",
"bot_only",
"owner"
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "Current reference repos, resolved under the new value (same body as GET /api/config/reference-repos)",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"reference_repos": {
"type": "array",
"items": {
"type": "object"
}
},
"write_kinds": {
"type": "array",
"items": {
"type": "string"
}
},
"write_identity": {
"type": "string"
},
"write_identities": {
"type": "array",
"items": {
"type": "string"
}
},
"bot_login": {
"type": "string"
}
}
}
}
}
},
"400": {
"description": "Unknown value, or a hand-written write entry would have no credential; nothing was stored"
},
"403": {
"description": "Owner role required"
},
"500": {
"description": "The config file could not be written; the setting is unchanged"
}
}
}
},
"/api/config/stat-sources": {
"get": {
"tags": [
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,8 @@ func (b *boot) wireBootClosures() {
OwnerIdentity: b.ownerIdentityStore(),
OwnerIdentityChanged: b.ownerIdentityChanged,
RepoAgents: b.repoAgents,
CheckRemoteWriteIdentity: b.checkRemoteWriteIdentity,
RemoteWriteIdentityChanged: b.remoteWriteIdentityChanged,
ReviewConfigApplied: func(rc config.ReviewConfig) {
if b.ghClient == nil {
return
Expand Down
34 changes: 34 additions & 0 deletions src/cmd/hive/reference_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,37 @@ func (b *boot) ownerIdentityStore() *github.OwnerIdentityStore {
}
return b.ownerIdentity
}

// checkRemoteWriteIdentity is the dashboard's dry run for a
// project.remote_write_identity change (hivecommons/hive#18516): the
// hand-written reference repos are resolved under setting with the live
// seams, and the error a hand-written write entry would stop the next boot
// with is returned so the change is refused instead. Nothing is installed.
func (b *boot) checkRemoteWriteIdentity(ctx context.Context, setting string) error {
if b.githubProxy == nil || b.cfg == nil {
return nil
}
if err := config.ValidateRemoteWriteIdentity(setting); err != nil {
return err
}
rt := b.referenceRepos
if rt == nil {
rt = b.newReferenceRepoRuntime()
}
deps := rt.deps
deps.writeIdentity = func() string { return setting }
_, err := buildReferenceRepoPolicies(ctx, config.HandWrittenReferenceRepos(b.cfg.Project.ReferenceRepos), deps, b.logger)
return err
}

// remoteWriteIdentityChanged is the dashboard's hook after the setting was
// saved: one full pass (derive, resolve, install) so the next write already
// carries the new identity and the Settings page reloads the resolved state.
// It runs on the boot context, not the request's, because the pass starts
// background work (the read-only notice, the own-item follow-up).
func (b *boot) remoteWriteIdentityChanged() {
if b.referenceRepos == nil || b.ctx == nil {
return
}
b.rederiveReferenceRepos(b.ctx)
}
Loading
Loading