Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove useless API #4311

Merged
merged 2 commits into from
Sep 25, 2024
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
18 changes: 6 additions & 12 deletions server/controllers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const {
getK8sRuntime,
getOAuthInfo,
getClusterRole,
getSupportGpuList,
getInstallerSpec,
getTheme,
} = require('../services/session');

Expand Down Expand Up @@ -182,26 +180,24 @@ const renderView = async ctx => {
const clusterRole = await getClusterRole(ctx);
const ksConfig = await getKSConfig(ctx);

const [user, runtime, supportGpuType, installer, installedExtensions] = await Promise.all([
const [user, runtime, installedExtensions] = await Promise.all([
getCurrentUser(ctx, clusterRole, ksConfig.multicluster),
getK8sRuntime(ctx),
getSupportGpuList(ctx),
getInstallerSpec(ctx),
getInstalledExtensions(ctx),
]);

await renderIndex(ctx, {
ksConfig: {
...ksConfig,
metrics_server: get(installer, 'metrics_server.enabled', false),
metrics_server: false,
},
user,
runtime,
clusterRole,
installedExtensions,
config: {
...clientConfig,
supportGpuType: [...supportGpuType, ...clientConfig.supportGpuType],
supportGpuType: [...clientConfig.supportGpuType],
},
});
} catch (err) {
Expand All @@ -214,24 +210,22 @@ const renderV3View = async ctx => {
const clusterRole = await getClusterRole(ctx);
const ksConfig = await getKSConfig(ctx);

const [user, runtime, supportGpuType, installer] = await Promise.all([
const [user, runtime] = await Promise.all([
getCurrentUser(ctx, clusterRole, ksConfig.multicluster),
getK8sRuntime(ctx),
getSupportGpuList(ctx),
getInstallerSpec(ctx),
]);

await renderV3Index(ctx, {
ksConfig: {
...ksConfig,
metrics_server: get(installer, 'metrics_server.enabled', false),
metrics_server: false,
},
user,
runtime,
clusterRole,
config: {
...clientConfig,
supportGpuType: [...supportGpuType, ...clientConfig.supportGpuType],
supportGpuType: [...clientConfig.supportGpuType],
},
});
} catch (err) {
Expand Down
49 changes: 0 additions & 49 deletions server/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,32 +404,6 @@ const getClusterRole = async ctx => {
return role;
};

const getSupportGpuList = async ctx => {
const token = ctx.cookies.get('token');
let gpuKinds = [];
if (!token) {
return [];
}
try {
const list = await sendGatewayRequest({
method: 'GET',
url: '/kapis/config.kubesphere.io/v1alpha2/configs/gpu/kinds',
token,
});
if (Array.isArray(list)) {
const defaultGpu = list.filter(item => item.default).map(item => item.resourceName);

const otherGpus = list.filter(item => !item.default).map(item => item.resourceName);

gpuKinds = [...defaultGpu, ...otherGpus];
}
} catch (error) {
console.error(error);
}

return gpuKinds;
};

const getOAuthInfo = async () => {
let resp = [];
try {
Expand Down Expand Up @@ -511,27 +485,6 @@ const createUser = (params, token) => {
});
};

const getInstallerSpec = async ctx => {
const token = ctx.cookies.get('token');
if (!token) {
return {};
}

try {
const result = await sendGatewayRequest({
method: 'GET',
url: `/apis/installer.kubesphere.io/v1alpha1/clusterconfigurations?name=ks-installer`,
token,
});

return result.items[0].spec;
} catch (error) {
console.error(error);
}

return {};
};

const getTheme = async () => {
try {
const theme = await sendGatewayRequest({
Expand Down Expand Up @@ -566,7 +519,5 @@ module.exports = {
getK8sRuntime,
createUser,
getClusterRole,
getSupportGpuList,
getInstallerSpec,
getTheme,
};
Loading