// Normalize returns an error iff the Quest_Desc is invalid.
189827
func (q *Quest_Desc) Normalize() error {
	if q.Meta == nil {
		q.Meta = &Quest_Desc_Meta{
			Retry:    &Quest_Desc_Meta_Retry{},
			Timeouts: &Quest_Desc_Meta_Timeouts{},
		}
	} else {
		if q.Meta.Retry == nil {
			q.Meta.Retry = &Quest_Desc_Meta_Retry{}
		}
		if q.Meta.Timeouts == nil {
			q.Meta.Timeouts = &Quest_Desc_Meta_Timeouts{}
		}
	}
	if err := q.Meta.Timeouts.Normalize(); err != nil {
		return err
	}

	length := len(q.Parameters) + len(q.DistributorParameters)
	if length > QuestDescPayloadMaxLength {
		return fmt.Errorf("quest payload is too large: %d > %d",
			length, QuestDescPayloadMaxLength)
	}
	normed, err := templateproto.NormalizeJSON(q.Parameters, true)
	if err != nil {
		return fmt.Errorf("failed to normalize parameters: %s", err)
	}
	q.Parameters = normed

	normed, err = templateproto.NormalizeJSON(q.DistributorParameters, true)
	if err != nil {
		return fmt.Errorf("failed to normalize distributor parameters: %s", err)
	}
	q.DistributorParameters = normed
	return nil
}
454798
func (u *URI) normalize() string {
	scheme := u.Scheme
	index := strings.Index(scheme, "+")
	if index >= 0 {
		scheme = scheme[:index]
	}
	return fmt.Sprintf("%s://%s:%d", scheme, u.Host, u.Port)
}
1161646
func (f *File) Normalize() error {
	me := errors.MultiError(nil)
	for tname, t := range f.Template {
		if err := t.Normalize(); err != nil {
			me = append(me, fmt.Errorf("for template %q: %s", tname, err))
		}
	}
	if len(me) > 0 {
		return me
	}
	return nil
}
120329
func (f *File) Normalize() error {
	for tempName, t := range f.Template {
		if err := t.Normalize(); err != nil {
			return fmt.Errorf("template %q: %s", tempName, err)
		}
	}
	return nil
}
759816
func (p *configPair) normalize(ctx context.Context) error {
	var err error
	p.original, err = normalizeOne(ctx, p.original, p)
	if err != nil {
		return fmt.Errorf("failed to normalize the original config - %s", err)
	}
	p.generated, err = normalizeOne(ctx, p.generated, p)
	if err != nil {
		return fmt.Errorf("failed to normalize the generated config - %s", err)
	}
	return nil
}
598281
func (s *Stage) Normalize() error {
	switch st := s.GetStageType().(type) {
	case *Stage_Failure:
		return st.Failure.Normalize()
	case *Stage_Stall:
		return st.Stall.Normalize()
	case *Stage_Deps:
		return st.Deps.Normalize()
	}
	return fmt.Errorf("empty stage")
}
36343
func Normalize(cmd *cobra.Command) *cobra.Command {
	if len(cmd.Long) > 0 {
		cmd.Long = LongDesc(cmd.Long)
	}
	if len(cmd.Example) > 0 {
		cmd.Example = Examples(cmd.Example)
	}
	return cmd
}
1369015
func (z Zones) Normalize() {
	for i := range z {
		z[i] = Name(z[i]).Normalize()
	}
}
1211786
func (i *Parameters_Job_Inputs) Normalize() (err error) {
	if i.Cipd == nil && len(i.Isolated) == 0 {
		return errors.New(
			"job.inputs: at least one of packages and isolated must be specified")
	}
	if i.Cipd != nil {
		if err = i.Cipd.Normalize(); err != nil {
			return
		}
	}
	return
}
535382
func (a *ActivateExecutionReq) Normalize() error {
	if err := a.Auth.Normalize(); err != nil {
		return err
	}
	if len(a.ExecutionToken) < MinimumActivationTokenLength {
		return fmt.Errorf("insufficiently long ExecutionToken: %d",
			len(a.ExecutionToken))
	}
	return nil
}
856695
func (p *Parameters) Normalize() (err error) {
	if err = p.Scheduling.Normalize(); err != nil {
		return
	}
	if err = p.Meta.Normalize(); err != nil {
		return
	}
	if err = p.Job.Normalize(); err != nil {
		return
	}
	return
}
1298700
func (p *Phrase) Normalize() error {
	if p != nil {
		if p.Name == "" {
			return fmt.Errorf("empty ID")
		}
		for _, s := range p.Stages {
			if err := s.Normalize(); err != nil {
				return err
			}
		}
		if p.ReturnStage == nil {
			p.ReturnStage = &ReturnStage{Retval: 1}
		}
	}
	return nil
}
686504
func (s *Parameters_Scheduling) Normalize() (err error) {
	if s.Priority > 255 {
		return errors.New("scheduling.priority > 256")
	}
	// Priority == 0 means default.
	if s.Priority == 0 {
		s.Priority = DefaultSwarmingPriority
	}
	for k, v := range s.Dimensions {
		if k == "" {
			return errors.New("scheduling.dimensions: empty dimension key")
		}
		if v == "" {
			return fmt.Errorf("scheduling.dimensions: dimension key %q with empty value", k)
		}
	}
	if google.DurationFromProto(s.IoTimeout) < 0 {
		return errors.New("scheduling.io_timeout: negative timeout not allowed")
	}
	return
}
468255
func (vs Values) Normalize() []Value {
	var output []Value
	var total float64

	for _, v := range vs {
		total += v.Value
	}

	for _, v := range vs {
		if v.Value > 0 {
			output = append(output, Value{
				Style: v.Style,
				Label: v.Label,
				Value: util.Math.RoundDown(v.Value/total, 0.0001),
			})
		}
	}
	return output
}
608333
func (a Dimensions) Normalize() (time.Duration, []string) {
	var dur time.Duration
	var tags []string

	for _, dim := range a {
		switch expr := dim.Expr.(type) {
		case *Call:
			lit, _ := expr.Args[0].(*DurationLiteral)
			dur = lit.Val
		case *VarRef:
			tags = append(tags, expr.Val)
		}
	}

	return dur, tags
}
1142368
func Normalize(platform specs.Platform) specs.Platform {
	platform.OS = normalizeOS(platform.OS)
	platform.Architecture, platform.Variant = normalizeArch(platform.Architecture, platform.Variant)

	// these fields are deprecated, remove them
	platform.OSFeatures = nil
	platform.OSVersion = ""

	return platform
}
941634
func (al *GraphQuery_AttemptRange) Normalize() error {
	if al.Quest == "" {
		return fmt.Errorf("must specify quest")
	}
	if al.Low == 0 {
		return fmt.Errorf("must specify low")
	}
	if al.High <= al.Low {
		return fmt.Errorf("high must be > low")
	}
	return nil
}