- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器 - 新增 log_datasource.go model - 新增 monitor/log-center.ts API 模块 - 新增 LogCenter 前端组件及页面 - 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等) - 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件 - 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等) - 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等) - 更新静态资源 (index.html + 新 JS/CSS bundle) - 删除废弃静态资源文件
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
// image-ref-utils.ts — 容器镜像引用解析与拼接 // Logan.Li
|
||
|
||
export interface ImageRefParts {
|
||
repository: string;
|
||
tag: string;
|
||
/** digest 形式时存在,如 sha256:abc... // Logan.Li */
|
||
digest?: string;
|
||
}
|
||
|
||
/** 解析镜像引用为仓库地址 + tag(兼容 registry:port 与 digest)// Logan.Li */
|
||
export function parseImageRef(image: string): ImageRefParts {
|
||
const raw = (image || '').trim();
|
||
if (!raw) return { repository: '', tag: 'latest' };
|
||
|
||
if (raw.includes('@')) {
|
||
const at = raw.lastIndexOf('@');
|
||
return {
|
||
repository: raw.slice(0, at),
|
||
tag: raw.slice(at + 1),
|
||
digest: raw.slice(at + 1),
|
||
};
|
||
}
|
||
|
||
const slashIdx = raw.lastIndexOf('/');
|
||
const colonIdx = raw.lastIndexOf(':');
|
||
if (colonIdx > slashIdx) {
|
||
return {
|
||
repository: raw.slice(0, colonIdx),
|
||
tag: raw.slice(colonIdx + 1) || 'latest',
|
||
};
|
||
}
|
||
|
||
return { repository: raw, tag: 'latest' };
|
||
}
|
||
|
||
/** 拼接完整镜像引用 // Logan.Li */
|
||
export function joinImageRef(repository: string, tag: string): string {
|
||
const repo = repository.trim();
|
||
const t = tag.trim();
|
||
if (!repo) return '';
|
||
if (!t) return repo;
|
||
if (t.startsWith('sha256:')) return `${repo}@${t}`;
|
||
return `${repo}:${t}`;
|
||
} |