// CheckAndSetDefaults checks and set default values for any missing fields.
CheckAndSetDefaults checks and set default values for any missing fields.
// CheckAndSetDefaults checks and set default values for any missing fields .
func (s *ServerV2) CheckAndSetDefaults() error {
	err := s.Metadata.CheckAndSetDefaults()
	if err != nil {
		return trace.Wrap(err)
	}
	if s.Kind == "" {
		return trace.BadParameter("server Kind is empty")
	}
	for key := range s.Spec.CmdLabels {
		if !IsValidLabelKey(key) {
			return trace.BadParameter("invalid label key: %q", key)
		}
	}
	for _, kc := range s.Spec.KubernetesClusters {
		if !validKubeClusterName.MatchString(kc.Name) {
			return trace.BadParameter("invalid kubernetes cluster name: %q", kc.Name)
		}
	}
	return nil
}
func ( s * ServerV2 ) CheckAndSetDefaults ( ) error { err := s . Metadata . CheckAndSetDefaults ( ) if err != nil { return trace . Wrap ( err ) } if s . Kind == " " { return trace . BadParameter ( " " ) } for key := range s . Spec . CmdLabels { if ! IsValidLabelKey ( key ) { return trace . BadParameter ( " " , key ) } } for _ , kc := range s . Spec . KubernetesClusters { if ! validKubeClusterName . MatchString ( kc . Name ) { return trace . BadParameter ( " " , kc . Name ) } } return nil }
CheckAndSetDefaults checks and set default values for any missing fields.
CheckAndSetDefaults checks and set default values for any missing fields .
// TODO(awly): default s.Metadata.Expiry if not set (use // defaults.ServerAnnounceTTL).