sigs.k8s.io/kueue@v0.6.2/pkg/util/api/api.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package api 18 19 const ( 20 maxEventMsgSize = 1024 21 maxConditionMsgSize = 32 * 1024 22 ) 23 24 // TruncateEventMessage truncates a message if it hits the maxEventMessage. 25 func TruncateEventMessage(message string) string { 26 return truncateMessage(message, maxEventMsgSize) 27 } 28 29 func TruncateConditionMessage(message string) string { 30 return truncateMessage(message, maxConditionMsgSize) 31 } 32 33 // truncateMessage truncates a message if it hits the NoteLengthLimit. 34 func truncateMessage(message string, limit int) string { 35 if len(message) <= limit { 36 return message 37 } 38 suffix := " ..." 39 return message[:limit-len(suffix)] + suffix 40 }