Documentation ¶
Index ¶
- Variables
- func AddLabelManagedByCNRM(labels map[string]string) map[string]string
- func CompareProtoMessage(a, b proto.Message, compareDiff CompareDiff) (sets.Set[string], error)
- func ComputeGCPLabels(labels map[string]string) map[string]string
- func IsFieldBehavior(field protoreflect.FieldDescriptor, fieldBehavior annotations.FieldBehavior) bool
- func NormalizeReferences(ctx context.Context, reader client.Reader, obj client.Object, ...) error
- func NormalizeStringToTimestamp(ts string) *timestamppb.Timestamp
- func RemoveByPrefixes(a map[string]string, prefixes ...string)
- func VisitFields(obj any, visitor Visitor) error
- type CompareDiff
- type Visitor
Constants ¶
This section is empty.
Variables ¶
View Source
var BasicDiff = func(fieldName protoreflect.Name, a, b proto.Message) (bool, error) { aField := a.ProtoReflect().Descriptor().Fields().ByName(fieldName) bField := b.ProtoReflect().Descriptor().Fields().ByName(fieldName) if IsFieldBehavior(aField, annotations.FieldBehavior_OUTPUT_ONLY) { return false, nil } if bField == nil { return true, nil } if !aField.Kind().IsValid() { return false, fmt.Errorf("unimplemented kind: " + aField.Kind().String()) } diff := false aVal := a.ProtoReflect().Get(aField) bVal := b.ProtoReflect().Get(bField) switch aField.Kind() { case protoreflect.MessageKind: if aField.IsList() || aField.IsMap() { if !aVal.Equal(bVal) { diff = true } } else { m := aVal.Message().Interface() switch m.(type) { case *timestamppb.Timestamp: if !aVal.Equal(bVal) { diff = true } case *durationpb.Duration: if !aVal.Equal(bVal) { diff = true } default: return false, fmt.Errorf("field %s not recursed", fieldName) } } default: if !aVal.Equal(bVal) { diff = true } } if diff && IsFieldBehavior(aField, annotations.FieldBehavior_IMMUTABLE) { return false, fmt.Errorf("change to immutable field %s", fieldName) } return diff, nil }
Functions ¶
func AddLabelManagedByCNRM ¶ added in v1.126.0
func CompareProtoMessage ¶ added in v1.125.0
func IsFieldBehavior ¶ added in v1.125.0
func IsFieldBehavior(field protoreflect.FieldDescriptor, fieldBehavior annotations.FieldBehavior) bool
func NormalizeReferences ¶ added in v1.126.0
func NormalizeStringToTimestamp ¶
func NormalizeStringToTimestamp(ts string) *timestamppb.Timestamp
func RemoveByPrefixes ¶
func VisitFields ¶ added in v1.126.0
Types ¶
type CompareDiff ¶ added in v1.125.0
Click to show internal directories.
Click to hide internal directories.