Skip to content

Commit

Permalink
feat(dataplanes): include rules in dataplane bundle download (#3380)
Browse files Browse the repository at this point in the history
Closes #3356

Continuation of #3329

Signed-off-by: John Cowen <[email protected]>
  • Loading branch information
johncowen authored Jan 9, 2025
1 parent ce5d67f commit a3c51c0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ data-planes:
xds: XDS Configuration
eds: Include EDS
dataplane: Dataplane Configuration
policies: Poilicies
policies: Policies
clusters: Envoy Clusters Logs
stats: Envoy Stats Logs
about:
Expand Down
23 changes: 23 additions & 0 deletions packages/kuma-gui/src/app/data-planes/sources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TarWriter } from '@gera2ld/tarjs'
import createClient from 'openapi-fetch'

import {
Dataplane,
Expand All @@ -12,6 +13,7 @@ import { YAML } from '@/app/application'
import { defineSources, type Source } from '@/app/application/services/data-source'
import type KumaApi from '@/app/kuma/services/kuma-api/KumaApi'
import type { PaginatedApiListResponse as CollectionResponse, ApiKindListResponse as KindCollectionResponse } from '@/types/api.d'
import type { paths } from '@/types/auto-generated.d'
import type { PolicyTypeEntry } from '@/types/index.d'

export type { Dataplane, DataplaneOverview } from './data'
Expand All @@ -34,6 +36,10 @@ const includes = <T extends readonly string[]>(arr: T, item: string): item is T[
return arr.includes(item as T[number])
}
export const sources = (source: Source, api: KumaApi, can: Can) => {
const http = createClient<paths>({
baseUrl: '',
fetch: api.client.fetch,
})
return defineSources({
// always resolves and keeps polling until we have at least one dataplane and all dataplanes are online
'/dataplanes/poll': (params) => {
Expand Down Expand Up @@ -96,6 +102,23 @@ export const sources = (source: Source, api: KumaApi, can: Can) => {
}
})
break
case 'policies':
prev.push(async () => {
const res = await http.GET('/meshes/{mesh}/{resourceType}/{resourceName}/_rules', {
params: {
path: {
mesh,
resourceType: 'dataplanes',
resourceName: name,
},
},
})
return {
name: 'policies.json',
content: JSON.stringify(res!, null, 2),
}
})
break
case 'xds':
prev.push(async () => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ const props = defineProps<{
const specs = ref({
eds: false,
xds: false,
dataplane: false,
// policies: false,
clusters: false,
stats: false,
dataplane: false,
policies: false,
})
const downloadBundle = (close: () => void) => async (bundle: { name: string, url: string }) => {
const a = document.createElement('a')
Expand Down

0 comments on commit a3c51c0

Please sign in to comment.