mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(secrets): secrets and variables UI and env mapping in trust review
Add a Secrets manager for global values (Settings > Secrets and variables) and
repo values (Secrets tool panel and dialog), with environment scoping,
write-only secrets and copyable ${{ }} references. The trust review for
.ocm/project.json lists the environment and each mapped variable with the
expression it resolves from.
This commit is contained in:
1 parent
e0331b43bf
commit
2884e68a69
18 files changed
+911
-25
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import type { SecretKind, SecretListResponse, SetSecretRequest } from '@opencode-manager/shared/schemas'
|
||||
import { fetchWrapper, fetchWrapperVoid } from './fetchWrapper'
|
||||
|
||||
export type SecretScope = { scope: 'global' } | { scope: 'repo'; repoId: number }
|
||||
|
||||
const KIND_SEGMENT: Record<SecretKind, string> = {
|
||||
secret: 'secrets',
|
||||
variable: 'variables',
|
||||
}
|
||||
|
||||
function secretsPath(scope: SecretScope, kind: SecretKind): string {
|
||||
const segment = KIND_SEGMENT[kind]
|
||||
return scope.scope === 'global'
|
||||
? `${API_BASE_URL}/api/${segment}`
|
||||
: `${API_BASE_URL}/api/repos/${scope.repoId}/${segment}`
|
||||
}
|
||||
|
||||
export async function listSecrets(scope: SecretScope, kind: SecretKind): Promise<SecretListResponse> {
|
||||
return fetchWrapper(secretsPath(scope, kind))
|
||||
}
|
||||
|
||||
export async function setSecret(
|
||||
scope: SecretScope,
|
||||
kind: SecretKind,
|
||||
name: string,
|
||||
request: SetSecretRequest,
|
||||
): Promise<void> {
|
||||
return fetchWrapperVoid(`${secretsPath(scope, kind)}/${encodeURIComponent(name)}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(request),
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteSecret(
|
||||
scope: SecretScope,
|
||||
kind: SecretKind,
|
||||
name: string,
|
||||
environment?: string,
|
||||
): Promise<void> {
|
||||
return fetchWrapperVoid(`${secretsPath(scope, kind)}/${encodeURIComponent(name)}`, {
|
||||
method: 'DELETE',
|
||||
...(environment ? { params: { environment } } : {}),
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user