Files
aiops/frontend/src/components/kubernetes/image-ref-utils.ts
T
Logan 8d46e8f352 feat: 新增日志中心、功能优化与代码重构
- 新增 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)
- 删除废弃静态资源文件
2026-06-26 23:18:05 +08:00

44 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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}`;
}