(o metav1.Object, key, value string)
| 59 | } |
| 60 | |
| 61 | func AddLabel(o metav1.Object, key, value string) { |
| 62 | labels := o.GetLabels() |
| 63 | if labels == nil { |
| 64 | labels = make(map[string]string) |
| 65 | } |
| 66 | |
| 67 | labels[key] = truncateAndHashIfExceed(value) |
| 68 | o.SetLabels(labels) |
| 69 | } |
| 70 | |
| 71 | func truncateAndHashIfExceed(input string) string { |
| 72 | if len(input) <= LabelMaxLength { |
no test coverage detected