func (v *Namespace) decodeRequest(log logr.Logger, in admission.Request) (*nsRequest, error) {
	ns := &corev1.Namespace{}
	var err error
	// For DELETE request, use DecodeRaw() from req.OldObject, since Decode() only uses req.Object,
	// which will be empty for a DELETE request.
	if in.Operation == v1beta1.Delete {
		log.V(1).Info("Decoding a delete request.")
		err = v.decoder.DecodeRaw(in.OldObject, ns)
	} else {
		err = v.decoder.Decode(in, ns)
	}
	if err != nil {
		return nil, err
	}

	return &nsRequest{
		ns: ns,
		op: in.Operation,
	}, nil
}
// decodeRequest gets the information we care about into a simple struct that's easy to both a) use
// and b) factor out in unit tests.
decodeRequest gets the information we care about into a simple struct that's easy to both a) use
and b) factor out in unit tests.
// decodeRequest gets the information we care about into a simple struct that ' s easy to both a ) use // and b ) factor out in unit tests .
func (v *Namespace) decodeRequest(log logr.Logger, in admission.Request) (*nsRequest, error) {
	ns := &corev1.Namespace{}
	var err error
	if in.Operation == v1beta1.Delete {
		log.V(1).Info("Decoding a delete request.")
		err = v.decoder.DecodeRaw(in.OldObject, ns)
	} else {
		err = v.decoder.Decode(in, ns)
	}
	if err != nil {
		return nil, err
	}
	return &nsRequest{
		ns: ns,
		op: in.Operation,
	}, nil
}
func ( v * Namespace ) decodeRequest ( log logr . Logger , in admission . Request ) ( * nsRequest , error ) { ns := & corev1 . Namespace { } var err error if in . Operation == v1beta1 . Delete { log . V ( 1 ) . Info ( " " ) err = v . decoder . DecodeRaw ( in . OldObject , ns ) } else { err = v . decoder . Decode ( in , ns ) } if err != nil { return nil , err } return & nsRequest { ns : ns , op : in . Operation , } , nil }
decodeRequest gets the information we care about into a simple struct that's easy to both a) use
and b) factor out in unit tests.
decodeRequest gets the information we care about into a simple struct that ' s easy to both a ) use and b ) factor out in unit tests .
// For DELETE request, use DecodeRaw() from req.OldObject, since Decode() only uses req.Object, // which will be empty for a DELETE request.