Skip to content

Commit

Permalink
Merge pull request #331 from kloudlite/impl/accounts-secrets
Browse files Browse the repository at this point in the history
WEB: Implement accout level secrets
  • Loading branch information
nxtCoder19 authored Nov 19, 2024
2 parents 9f632de + b798b2d commit ff8c477
Show file tree
Hide file tree
Showing 24 changed files with 5,377 additions and 2,508 deletions.
75 changes: 75 additions & 0 deletions gql-queries-generator/doc/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,81 @@ query consoleListRegistryImages($pq: CursorPaginationIn) {
}
}

query consoleListSecretVariables($pq: CursorPaginationIn, $search: SearchSecretVariables) {
core_listSecretVariables(pq: $pq, search: $search) {
totalCount
edges {
node {
id
accountName
createdBy {
userEmail
userId
userName
}
creationTime
displayName
lastUpdatedBy {
userEmail
userId
userName
}
markedForDeletion
name
recordVersion
stringData
updateTime
}
}
pageInfo {
endCursor
hasNextPage
hasPrevPage
startCursor
}
}
}

mutation consoleCreateSecretVariable($secretVariable: SecretVariableIn!) {
core_createSecretVariable(secretVariable: $secretVariable) {
id
}
}

query consoleGetSecretVariable($name: String!) {
core_getSecretVariable(name: $name) {
accountName
createdBy {
userEmail
userId
userName
}
creationTime
displayName
id
lastUpdatedBy {
userEmail
userId
userName
}
markedForDeletion
name
recordVersion
stringData
updateTime
}
}

mutation consoleUpdateSecretVariable($secretVariable: SecretVariableIn!) {
core_updateSecretVariable(secretVariable: $secretVariable) {
id
}
}

mutation consoleDeleteSecretVariable($name: String!) {
core_deleteSecretVariable(name: $name)
}

mutation authCli_createGlobalVPNDevice($gvpnDevice: GlobalVPNDeviceIn!) {
infra_createGlobalVPNDevice(gvpnDevice: $gvpnDevice) {
accountName
Expand Down
4 changes: 2 additions & 2 deletions src/apps/console/page-components/secret-resource-v2.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useParams } from '@remix-run/react';
import { useState } from 'react';
import { toast } from '@kloudlite/design-system/molecule/toast';
import { generateKey, titleCase } from '@kloudlite/design-system/utils';
import { useParams } from '@remix-run/react';
import { useState } from 'react';
import { Trash } from '~/console/components/icons';
import {
ExtractNodeType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { redirect } from '@remix-run/node';
import {
Outlet,
useLoaderData,
Expand All @@ -6,10 +7,9 @@ import {
} from '@remix-run/react';
import { CommonTabs } from '~/console/components/common-navbar-tabs';
import { IRouter } from '~/console/server/gql/queries/router-queries';
import { redirect } from '@remix-run/node';
import { GQLServerHandler } from '~/console/server/gql/saved-queries';
import logger from '~/lib/client/helpers/log';
import { ensureAccountSet } from '~/console/server/utils/auth-utils';
import logger from '~/lib/client/helpers/log';
import { IRemixCtx } from '~/lib/types/common';
import { IEnvironmentContext } from '../../_layout';

Expand Down Expand Up @@ -61,13 +61,13 @@ export const handle = () => {
};

export const loader = async (ctx: IRemixCtx) => {
const { environment, router, account } = ctx.params;
const { environment, router, account } = ctx.params;
ensureAccountSet(ctx);

try {
const { data, errors } = await GQLServerHandler(ctx.request).getRouter({
envName: environment,

name: router,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Plus } from '~/console/components/icons';
import { Button } from '@kloudlite/design-system/atoms/button';
import { defer } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { useState } from 'react';
import { Plus } from '~/console/components/icons';
import { LoadingComp, pWrapper } from '~/console/components/loading-component';
import Wrapper from '~/console/components/wrapper';
import { GQLServerHandler } from '~/console/server/gql/saved-queries';
Expand All @@ -11,12 +13,10 @@ import {
} from '~/console/server/utils/auth-utils';
import { getPagination, getSearch } from '~/console/server/utils/common';
import { IRemixCtx } from '~/lib/types/common';
import { useState } from 'react';
import fake from '~/root/fake-data-generator/fake';
import { Button } from '@kloudlite/design-system/atoms/button';
import Tools from './tools';
import HandleRouter from './handle-router';
import RouterResourcesV2 from './router-resources-V2';
import Tools from './tools';

export const loader = async (ctx: IRemixCtx) => {
ensureAccountSet(ctx);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Link, useOutletContext, useParams } from '@remix-run/react';
import { useState } from 'react';
import { Badge } from '@kloudlite/design-system/atoms/badge';
import { toast } from '@kloudlite/design-system/molecule/toast';
import { generateKey, titleCase } from '@kloudlite/design-system/utils';
import { Link, useOutletContext, useParams } from '@remix-run/react';
import { useState } from 'react';
import {
ListItem,
ListItemV2,
Expand Down Expand Up @@ -41,8 +41,8 @@ type BaseType = ExtractNodeType<IClusterMSvs>;
const parseItem = (item: BaseType, templates: IMSvTemplates) => {
const template = getManagedTemplate({
templates,
kind: item.spec?.msvcSpec?.serviceTemplate.kind || '',
apiVersion: item.spec?.msvcSpec?.serviceTemplate.apiVersion || '',
kind: item.spec?.msvcSpec?.serviceTemplate?.kind || '',
apiVersion: item.spec?.msvcSpec?.serviceTemplate?.apiVersion || '',
});
return {
name: item?.displayName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable guard-for-in */
/* eslint-disable react/destructuring-assignment */
import { useEffect, useRef, useState } from 'react';
import {
ITextInputBase,
NumberInput,
TextInput,
} from '@kloudlite/design-system/atoms/input';
import { Switch } from '@kloudlite/design-system/atoms/switch';
import Popup from '@kloudlite/design-system/molecule/popup';
import { useEffect, useRef, useState } from 'react';
import { NameIdView } from '~/console/components/name-id-view';
import { IDialogBase } from '~/console/components/types.d';
import { useConsoleApi } from '~/console/server/gql/api-provider';
Expand Down Expand Up @@ -242,7 +242,7 @@ const Root = (props: IDialog) => {
clusterName: props.data.clusterName,
isNameError: false,
res: {
...props.data.spec?.msvcSpec.serviceTemplate.spec,
...props.data.spec?.msvcSpec.serviceTemplate?.spec,
},
}
: {
Expand All @@ -267,9 +267,9 @@ const Root = (props: IDialog) => {
msvcSpec: {
serviceTemplate: {
apiVersion:
props.data.spec?.msvcSpec.serviceTemplate.apiVersion ||
props.data.spec?.msvcSpec.serviceTemplate?.apiVersion ||
'',
kind: props.data.spec?.msvcSpec.serviceTemplate.kind || '',
kind: props.data.spec?.msvcSpec.serviceTemplate?.kind || '',
spec: {
...val.res,
},
Expand All @@ -294,8 +294,8 @@ const Root = (props: IDialog) => {
if (isUpdate)
return getManagedTemplate({
templates,
apiVersion: props.data.spec?.msvcSpec.serviceTemplate.apiVersion || '',
kind: props.data.spec?.msvcSpec.serviceTemplate.kind || '',
apiVersion: props.data.spec?.msvcSpec.serviceTemplate?.apiVersion || '',
kind: props.data.spec?.msvcSpec.serviceTemplate?.kind || '',
});
return undefined;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { dayjs } from '@kloudlite/design-system/molecule/dayjs';
import { useOutletContext } from '@remix-run/react';
import { ApexOptions } from 'apexcharts';
import axios from 'axios';
import { useState } from 'react';
import { dayjs } from '@kloudlite/design-system/molecule/dayjs';
import Chart from '~/console/components/charts/charts-client';
import { useClusterStatusV3 } from '~/console/hooks/use-cluster-status-v3';
import { useDataState } from '~/console/page-components/common-state';
Expand Down Expand Up @@ -208,7 +208,7 @@ const LogsAndMetrics = () => {
},

annotations: getAnnotations(
managedService.spec?.msvcSpec.serviceTemplate.spec?.resources
managedService.spec?.msvcSpec.serviceTemplate?.spec?.resources
?.cpu || {},

'cpu'
Expand All @@ -218,7 +218,7 @@ const LogsAndMetrics = () => {
min: 0,
max:
parseValue(
managedService.spec?.msvcSpec.serviceTemplate.spec?.resources
managedService.spec?.msvcSpec.serviceTemplate?.spec?.resources
?.cpu?.max,
0
) * 1.1,
Expand Down Expand Up @@ -250,7 +250,7 @@ const LogsAndMetrics = () => {
],

annotations: getAnnotations(
managedService.spec?.msvcSpec.serviceTemplate.spec?.resources
managedService.spec?.msvcSpec.serviceTemplate?.spec?.resources
?.cpu || {},
'memory'
),
Expand All @@ -259,7 +259,7 @@ const LogsAndMetrics = () => {
min: 0,
max:
parseValue(
managedService.spec?.msvcSpec.serviceTemplate.spec?.resources
managedService.spec?.msvcSpec.serviceTemplate?.spec?.resources
?.cpu?.max,
0
) * 1.1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { NumberInput, TextInput } from '@kloudlite/design-system/atoms/input';
import Select from '@kloudlite/design-system/atoms/select';
import { Switch } from '@kloudlite/design-system/atoms/switch';
import { titleCase, useMapper } from '@kloudlite/design-system/utils';
import { defer } from '@remix-run/node';
import {
useLoaderData,
Expand All @@ -6,10 +10,6 @@ import {
useParams,
} from '@remix-run/react';
import { FormEventHandler, useCallback, useEffect, useState } from 'react';
import { NumberInput, TextInput } from '@kloudlite/design-system/atoms/input';
import Select from '@kloudlite/design-system/atoms/select';
import { Switch } from '@kloudlite/design-system/atoms/switch';
import { titleCase, useMapper } from '@kloudlite/design-system/utils';
import {
BottomNavigation,
ReviewComponent,
Expand Down Expand Up @@ -458,9 +458,9 @@ const App = ({ services }: { services: ExtractNodeType<IClusterMSvs>[] }) => {
const commonTemplates = useCallback(() => {
return getManagedTemplate({
templates: msvtemplates || [],
kind: managedService?.spec?.msvcSpec.serviceTemplate.kind || '',
kind: managedService?.spec?.msvcSpec.serviceTemplate?.kind || '',
apiVersion:
managedService?.spec?.msvcSpec.serviceTemplate.apiVersion || '',
managedService?.spec?.msvcSpec.serviceTemplate?.apiVersion || '',
});
}, [managedService, msvtemplates]);

Expand Down Expand Up @@ -527,9 +527,9 @@ const App = ({ services }: { services: ExtractNodeType<IClusterMSvs>[] }) => {
namespace: managedService?.spec?.targetNamespace || '',
apiVersion:
managedService?.spec?.msvcSpec.serviceTemplate
.apiVersion || '',
?.apiVersion || '',
kind:
managedService?.spec?.msvcSpec.serviceTemplate.kind ||
managedService?.spec?.msvcSpec.serviceTemplate?.kind ||
'',
// clusterName: managedService.clusterName,
},
Expand Down
Loading

0 comments on commit ff8c477

Please sign in to comment.