in operatortrace-go/pkg/client/conditions.go [95:123]
func deleteConditionAsMap(conditionType string, obj client.Object, scheme *runtime.Scheme) error {
// Retrieve the current conditions as a map
conditions, err := getConditionsAsMap(obj, scheme)
if err != nil {
return err
}
var outConditions []map[string]interface{}
for _, condition := range conditions {
// Check if "Type" key exists
conType, exists := condition["Type"]
if !exists {
return fmt.Errorf("condition does not contain a 'Type' field")
}
// Convert conType to string using reflection
conTypeStr, err := convertToString(conType)
if err != nil {
return fmt.Errorf("failed to convert 'Type' field to string: %v", err)
}
if conTypeStr != conditionType {
outConditions = append(outConditions, condition)
}
}
// Set the updated conditions back to the object
return setConditionsFromMap(obj, outConditions, scheme)
}