Writes and verify image

This commit is contained in:
2026-04-04 02:45:46 +08:00
parent 9cb593ffc0
commit 4f490ab37e
20 changed files with 596 additions and 65 deletions

View File

@@ -21,19 +21,17 @@ const (
// ResolveCatalog resolves catalog using priority:
// Inline > ConfigMap > URL > cached
func ResolveCatalog(
ctx context.Context,
func ResolveCatalog(ctx context.Context,
kubeClient kubernetes.Interface,
namespace string,
src *monov1alpha1.VersionCatalogSource,
namespace string, src *monov1alpha1.VersionCatalogSource,
) (*VersionCatalog, error) {
// 1. Inline
// Inline
if src != nil && src.Inline != "" {
return parseCatalog([]byte(src.Inline))
}
// 2. ConfigMap
// ConfigMap
if src != nil && src.ConfigMap != "" {
cm, err := kubeClient.CoreV1().ConfigMaps(namespace).Get(ctx, src.ConfigMap, metav1.GetOptions{})
if err != nil {
@@ -48,7 +46,7 @@ func ResolveCatalog(
return parseCatalog([]byte(data))
}
// 3. URL
// URL
if src != nil && src.URL != "" {
cat, err := fetchCatalog(src.URL)
if err == nil {
@@ -64,7 +62,7 @@ func ResolveCatalog(
return nil, fmt.Errorf("fetch catalog failed and no cache: %w", err)
}
// 4. cached fallback
// fallback cache
if cached, err := loadCached(); err == nil {
return cached, nil
}