package debianpatch import ( "fmt" ) // IsBootcImage checks if an image is a bootc image by looking for either // com.redhat.bootc=true or com.debian.bootc=true labels func IsBootcImage(labels map[string]string) bool { // Check for Red Hat bootc label (for compatibility) if val, exists := labels["com.redhat.bootc"]; exists && val == "true" { return true } // Check for Debian bootc label (our addition) if val, exists := labels["com.debian.bootc"]; exists && val == "true" { return true } return false } // ValidateBootcImage validates that an image has the required bootc markers func ValidateBootcImage(labels map[string]string, imageRef string) error { if !IsBootcImage(labels) { return fmt.Errorf("image %s is not a bootc image (missing com.redhat.bootc=true or com.debian.bootc=true label)", imageRef) } // Check for required OSTree labels if val, exists := labels["ostree.bootable"]; !exists || val != "true" { return fmt.Errorf("image %s is not a bootc image (missing ostree.bootable=true label)", imageRef) } return nil } // GetBootcType returns the type of bootc image (redhat, debian, or unknown) func GetBootcType(labels map[string]string) string { if val, exists := labels["com.redhat.bootc"]; exists && val == "true" { return "redhat" } if val, exists := labels["com.debian.bootc"]; exists && val == "true" { return "debian" } return "unknown" } // ValidateDebianBootcImage performs Debian-specific validation func ValidateDebianBootcImage(labels map[string]string, imageRef string) error { // First, validate it's a bootc image if err := ValidateBootcImage(labels, imageRef); err != nil { return err } // Check if it's specifically a Debian bootc image if GetBootcType(labels) != "debian" { return fmt.Errorf("image %s is not a Debian bootc image (missing com.debian.bootc=true label)", imageRef) } // Additional Debian-specific validations can be added here // For example, checking for Debian-specific labels or configurations return nil }