// CheckAndSetDefaults checks and sets default values for any missing fields.
CheckAndSetDefaults checks and sets default values for any missing fields.
// CheckAndSetDefaults checks and sets default values for any missing fields .
func (s *DatabaseServerV3) CheckAndSetDefaults() error {
	if err := s.Metadata.CheckAndSetDefaults(); err != nil {
		return trace.Wrap(err)
	}
	if s.Kind == "" {
		return trace.BadParameter("database server %q kind is empty", s.GetName())
	}
	for key := range s.Spec.DynamicLabels {
		if !IsValidLabelKey(key) {
			return trace.BadParameter("database server %q invalid label key: %q", s.GetName(), key)
		}
	}
	if s.Spec.Protocol == "" {
		return trace.BadParameter("database server %q protocol is empty", s.GetName())
	}
	if s.Spec.URI == "" {
		return trace.BadParameter("database server %q URI is empty", s.GetName())
	}
	if s.Spec.Hostname == "" {
		return trace.BadParameter("database server %q hostname is empty", s.GetName())
	}
	if s.Spec.HostID == "" {
		return trace.BadParameter("database server %q host ID is empty", s.GetName())
	}
	return nil
}
func ( s * DatabaseServerV3 ) CheckAndSetDefaults ( ) error { if err := s . Metadata . CheckAndSetDefaults ( ) ; err != nil { return trace . Wrap ( err ) } if s . Kind == " " { return trace . BadParameter ( " " , s . GetName ( ) ) } for key := range s . Spec . DynamicLabels { if ! IsValidLabelKey ( key ) { return trace . BadParameter ( " " , s . GetName ( ) , key ) } } if s . Spec . Protocol == " " { return trace . BadParameter ( " " , s . GetName ( ) ) } if s . Spec . URI == " " { return trace . BadParameter ( " " , s . GetName ( ) ) } if s . Spec . Hostname == " " { return trace . BadParameter ( " " , s . GetName ( ) ) } if s . Spec . HostID == " " { return trace . BadParameter ( " " , s . GetName ( ) ) } return nil }
CheckAndSetDefaults checks and sets default values for any missing fields.
CheckAndSetDefaults checks and sets default values for any missing fields .