feat(daemon): execute and verify organisation repository connections
This commit is contained in:
1 parent
32642af4a9
commit
05987f04e2
45 files changed
+1600
-284
No files matched your search
@@ -270,6 +270,8 @@ export const api = {
|
||||
body: { enabled },
|
||||
parse: false,
|
||||
}),
|
||||
checkRepository: <T = unknown>(input: { owner: string; repository: string; identity_id: string }) => request<T>("/api/control-plane/resources/repository-policies/check", { method: "POST", body: input, timeoutMs: 35000 }),
|
||||
repositories: <T = unknown>() => request<T>("/api/repositories"),
|
||||
workRequest: <T = unknown>(workRequest: Payload) =>
|
||||
request<T>("/api/work-requests", { method: "POST", body: workRequest }),
|
||||
skills: <T = unknown>() => request<T>("/api/skills"),
|
||||
|
||||
+1
-2
@@ -37,7 +37,7 @@ const orgSpecs: NavSpec[] = [
|
||||
},
|
||||
{
|
||||
label: "Connections & models",
|
||||
paths: ["/org/connections", "/org/credential-bindings", "/org/models", "/org/soul"],
|
||||
paths: ["/org/connections", "/org/repositories", "/org/credential-bindings", "/org/models", "/org/soul"],
|
||||
},
|
||||
{
|
||||
label: "Automation",
|
||||
@@ -67,7 +67,6 @@ const settings: NavSpec = {
|
||||
label: "Connections & channels",
|
||||
paths: [
|
||||
"/settings/channels",
|
||||
"/settings/repositories",
|
||||
"/settings/tools",
|
||||
"/settings/extensions",
|
||||
"/settings/plugins",
|
||||
|
||||
@@ -25,7 +25,7 @@ const error = ref("");
|
||||
|
||||
// Policies and models act on the caller's own org server-side, so an instance
|
||||
// admin looking at another org is sent back rather than editing the wrong one.
|
||||
const OWN_ORG_ONLY = ["/org/policies", "/org/models"];
|
||||
const OWN_ORG_ONLY = ["/org/policies", "/org/models", "/org/connections", "/org/repositories"];
|
||||
const away = computed(() => !!org.value && org.value.id !== homeOrg.value);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
+8
-13
@@ -182,19 +182,7 @@ const routes = [
|
||||
section: "settings",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/repositories",
|
||||
name: "system-repos",
|
||||
component: SystemReposPage,
|
||||
meta: {
|
||||
navPath: "/settings",
|
||||
settings: true,
|
||||
label: "Repositories",
|
||||
description:
|
||||
"Watched repositories and gate overrides.",
|
||||
section: "settings",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
path: "/org",
|
||||
component: OrgShell,
|
||||
@@ -235,6 +223,12 @@ const routes = [
|
||||
component: OrgAccessPage,
|
||||
meta: { label: "Policies", navPath: "/org" },
|
||||
},
|
||||
{
|
||||
path: "repositories",
|
||||
name: "org-repositories",
|
||||
component: SystemReposPage,
|
||||
meta: { label: "Repositories", navPath: "/org", description: "Repository connections, access checks and execution policies." },
|
||||
},
|
||||
{
|
||||
path: "connections",
|
||||
name: "org-connections",
|
||||
@@ -286,6 +280,7 @@ const routes = [
|
||||
"/settings/identities": "/org/agents",
|
||||
"/settings/access-policies": "/org/policies",
|
||||
"/settings/connections": "/org/connections",
|
||||
"/settings/repositories":"/org/repositories",
|
||||
"/settings/credential-bindings": "/org/credential-bindings",
|
||||
"/settings/soul": "/org/soul",
|
||||
"/settings/schedules": "/org/schedules",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
@@ -8,6 +8,8 @@ import { Plus } from "@lucide/vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { api } from "@/lib/api";
|
||||
import { useOrgStore, type Identity } from "@/stores/org";
|
||||
import {
|
||||
NumberField,
|
||||
NumberFieldContent,
|
||||
@@ -40,6 +42,7 @@ import HistoryLink from "./HistoryLink.vue";
|
||||
const KIND = "repository-policies";
|
||||
|
||||
interface Repo {
|
||||
connection: string;
|
||||
owner: string;
|
||||
name: string;
|
||||
base: string;
|
||||
@@ -55,11 +58,22 @@ interface Repo {
|
||||
|
||||
const store = useSettingsStore();
|
||||
const { catalog, catalogError } = storeToRefs(store);
|
||||
onMounted(store.load);
|
||||
const organisation = useOrgStore();
|
||||
const agents=ref<Identity[]>([]);
|
||||
const agentError=ref("");
|
||||
onMounted(async()=>{
|
||||
void store.load();
|
||||
try {
|
||||
await organisation.loadOrg();
|
||||
const response=await api.orgAgents<{agents:Identity[]}>(organisation.homeOrg);
|
||||
agents.value=response.agents.filter((agent)=>agent.lifecycle==="active");
|
||||
} catch(cause) {agentError.value=String((cause as Error).message || cause)}
|
||||
});
|
||||
|
||||
const resources = computed(() => resourcesForPage(catalog.value, "repositories"));
|
||||
const draft = computed(() => store.drafts[KIND]);
|
||||
const repos = computed(() => (draft.value?.value ?? []) as Repo[]);
|
||||
const connections = computed(() => (store.drafts["forge-connections"]?.value ?? []) as { id: string; name: string }[]);
|
||||
const error = computed(() => store.pageErrorFor(KIND));
|
||||
|
||||
const ecosystems = ["go", "python", "node", "rust", "custom"];
|
||||
@@ -72,13 +86,32 @@ function addRepo() {
|
||||
if (!draft.value || !owner || !name) return;
|
||||
draft.value.value ??= [];
|
||||
(draft.value.value as Repo[]).push({
|
||||
owner, name, base: "main", ecosystem: "go", gate: [], preflight: null, protect: null,
|
||||
owner, name, connection: "", base: "main", ecosystem: "go", gate: [], preflight: null, protect: null,
|
||||
test_glob: "", persistent_storage: false, max_retries: 0, allow_concurrent: false,
|
||||
});
|
||||
newRepo.value = "";
|
||||
open.value = String((draft.value.value as Repo[]).length - 1);
|
||||
}
|
||||
const protectOf = (repo: Repo) => repo.protect ?? [];
|
||||
interface AccessCheck { verified?: boolean; account?: string; base_branch?: string; message: string }
|
||||
const checkAgent=ref("");
|
||||
const checking=ref("");
|
||||
const results=ref<Record<string,AccessCheck>>({});
|
||||
watch([checkAgent,()=>JSON.stringify(repos.value)],()=>{results.value={}});
|
||||
async function checkAccess(repo:Repo):Promise<void>{
|
||||
if(unsaved.value || !checkAgent.value || checking.value)return;
|
||||
const key=`${repo.owner}/${repo.name}`;
|
||||
const input=JSON.stringify([repo,checkAgent.value]);
|
||||
checking.value=key;
|
||||
delete results.value[key];
|
||||
try {
|
||||
const result=await api.checkRepository<AccessCheck>({owner:repo.owner,repository:repo.name,identity_id:checkAgent.value});
|
||||
if(input===JSON.stringify([repo,checkAgent.value]))results.value[key]=result;
|
||||
}catch(cause){
|
||||
if(input===JSON.stringify([repo,checkAgent.value]))results.value[key]={message:String((cause as Error).message || cause)};
|
||||
}finally{checking.value=""}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -93,6 +126,30 @@ const protectOf = (repo: Repo) => repo.protect ?? [];
|
||||
<template v-if="draft">
|
||||
<CardAccordion v-model:open="open" :items="repos" :title="(r) => `${r.owner}/${r.name}`" remove-label="Remove" mono @remove="repos.splice($event, 1)">
|
||||
<template #default="{ item: repo, index: i }">
|
||||
<SettingRow label="Connection">
|
||||
<Select v-model="repo.connection">
|
||||
<SelectTrigger class="w-64" :aria-label="`Connection for ${repo.name}`"><SelectValue placeholder="Choose a connection" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="connection in connections" :key="connection.id" :value="connection.id">{{ connection.name || connection.id }}</SelectItem>
|
||||
<SelectItem v-if="repo.connection && !connections.some((connection) => connection.id === repo.connection)" :value="repo.connection" disabled>Unavailable connection</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</SettingRow>
|
||||
<SettingRow label="Check access">
|
||||
<div class="grid gap-2">
|
||||
<Select v-model="checkAgent">
|
||||
<SelectTrigger class="w-64" :aria-label="`Check ${repo.name} access as`"><SelectValue placeholder="Choose an agent" /></SelectTrigger>
|
||||
<SelectContent><SelectItem v-for="agent in agents" :key="agent.id" :value="agent.id">{{ agent.display_name }}</SelectItem></SelectContent>
|
||||
</Select>
|
||||
<Button type="button" variant="outline" class="w-fit" :disabled="!checkAgent || !repo.connection || unsaved || !!checking" @click="checkAccess(repo)">{{checking===`${repo.owner}/${repo.name}` ? "Checking…" : "Check access"}}</Button>
|
||||
<p v-if="unsaved" class="text-xs text-fg-muted">Save changes before checking access.</p>
|
||||
<p v-if="agentError" class="text-xs text-danger" role="alert">{{agentError}}</p>
|
||||
<p v-if="results[`${repo.owner}/${repo.name}`]" role="status" class="text-xs" :class="results[`${repo.owner}/${repo.name}`].verified ? 'text-ok' : 'text-danger'">
|
||||
{{ results[`${repo.owner}/${repo.name}`].message }}
|
||||
<span v-if="results[`${repo.owner}/${repo.name}`].verified">{{ results[`${repo.owner}/${repo.name}`].account }} · {{ results[`${repo.owner}/${repo.name}`].base_branch }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</SettingRow>
|
||||
<SettingRow label="Base branch" :for="`repo-${i}-base`">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<Input :id="`repo-${i}-base`" v-model="repo.base" class="max-w-56 font-mono" />
|
||||
|
||||
@@ -33,13 +33,13 @@ const recentRepos = ref<string[]>([]);
|
||||
const loadError = ref("");
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const [workflows, tasks] = await Promise.all([
|
||||
const [workflows, repositories] = await Promise.all([
|
||||
api.workflows<{ definitions?: WorkflowDefinition[]; workflows?: WorkflowStats[] }>(),
|
||||
api.tasks<{ owner?: string; repo?: string }[]>(),
|
||||
api.repositories<{ owner: string; name: string }[]>(),
|
||||
]);
|
||||
definitions.value = (workflows?.definitions ?? []).filter((d) => d.enabled);
|
||||
stats.value = workflows?.workflows ?? [];
|
||||
recentRepos.value = [...new Set((tasks ?? []).filter((t) => t.owner && t.repo).map((t) => `${t.owner}/${t.repo}`))].slice(0, 5);
|
||||
recentRepos.value = (repositories ?? []).map((repo) => `${repo.owner}/${repo.name}`);
|
||||
} catch (err) {
|
||||
loadError.value = String((err as Error).message || err);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ async function submit() {
|
||||
<datalist :id="`${uid}-repos`">
|
||||
<option v-for="r in recentRepos" :key="r" :value="r" />
|
||||
</datalist>
|
||||
<p v-if="recentRepos.length" class="text-xs text-fg-subtle">Recent:
|
||||
<p v-if="recentRepos.length" class="text-xs text-fg-subtle">Configured:
|
||||
<Button
|
||||
v-for="r in recentRepos"
|
||||
:key="r"
|
||||
|
||||
Reference in new issue
Block a user