// NormalizeEnvironment normalizes the supplied Environment such that two
// messages with identical meaning will have identical representation.
16142
func NormalizeEnvironment(env *vpython.Environment) error {
	if env.Spec == nil {
		env.Spec = &vpython.Spec{}
	}
	if err := NormalizeSpec(env.Spec, env.Pep425Tag); err != nil {
		return err
	}

	if env.Runtime == nil {
		env.Runtime = &vpython.Runtime{}
	}

	sort.Sort(pep425TagSlice(env.Pep425Tag))
	return nil
}
566521
func (s *CreateFunctionInput) SetEnvironment(v *Environment) *CreateFunctionInput {
	s.Environment = v
	return s
}
1353207
func (s *DeleteComputeEnvironmentInput) SetComputeEnvironment(v string) *DeleteComputeEnvironmentInput {
	s.ComputeEnvironment = &v
	return s
}
530418
func LoadEnvironment(path string, environment *vpython.Environment) error {
	content, err := ioutil.ReadFile(path)
	if err != nil {
		return errors.Annotate(err, "failed to load file from: %s", path).Err()
	}

	return ParseEnvironment(string(content), environment)
}
695499
func (s *Schema) Normalize() error {
	if s == nil {
		return errors.New("is nil")
	}
	if s.Schema == nil {
		return errors.New("has no type")
	}
	if enum := s.GetEnum(); enum != nil {
		return enum.Normalize()
	}
	return nil
}
1085333
func Normalize(email string) string {
	// Trim whitespaces.
	email = strings.TrimSpace(email)

	// Trim extra dot in hostname.
	email = strings.TrimRight(email, ".")

	// Lowercase.
	email = strings.ToLower(email)

	return email
}
584497
func normalizeEscape(s string) (string, error) {
	u, err := recursiveUnescape(s)
	if err != nil {
		return "", err
	}
	return escape(u), nil
}
801791
func (arc *AddressResourceConfig) Normalize() {
	testProto := strings.Trim(strings.ToLower(arc.Protocol), " ")
	arc.Protocol = testProto
}
1345242
func (d *DeploymentStatusRequest) GetEnvironment() string {
	if d == nil || d.Environment == nil {
		return ""
	}
	return *d.Environment
}
70317
func (kc *kubeClient) getEnvironmentNamespace(envName string) (string, error) {
	envNS, pres := kc.envMap[envName]
	if !pres {
		return "", errs.Errorf("unknown environment: %s", envName)
	}
	return envNS, nil
}
407438
func (m *Module) Normalized() string {
	return m.formatWithPrefix(m.normalizedHostPrefix(m.Host().Normalized()), false)
}
112896
func env(key string, defaultValue string) string {
	val := os.Getenv(key)
	if len(val) == 0 {
		return defaultValue
	}
	return val
}
283829
func normalizeToEnvCentre(line1Start, line1End, line2Start, line2End, normPt geom.Coord) {
	// Note: All these "max" checks are inlined for performance.
	// It would be visually cleaner to do that but requires more function calls

	line1MinX := line1End[0]
	if line1Start[0] < line1End[0] {
		line1MinX = line1Start[0]
	}

	line1MinY := line1End[1]
	if line1Start[1] < line1End[1] {
		line1MinY = line1Start[1]
	}
	line1MaxX := line1End[0]
	if line1Start[0] > line1End[0] {
		line1MaxX = line1Start[0]
	}
	line1MaxY := line1End[1]
	if line1Start[1] > line1End[1] {
		line1MaxY = line1Start[1]
	}

	line2MinX := line2End[0]
	if line2Start[0] < line2End[0] {
		line2MinX = line2Start[0]
	}
	line2MinY := line2End[1]
	if line2Start[1] < line2End[1] {
		line2MinY = line2Start[1]
	}
	line2MaxX := line2End[0]
	if line2Start[0] > line2End[0] {
		line2MaxX = line2Start[0]
	}
	line2MaxY := line2End[1]
	if line2Start[1] > line2End[1] {
		line2MaxY = line2Start[1]
	}

	intMinX := line2MinX
	if line1MinX > line2MinX {
		intMinX = line1MinX
	}
	intMaxX := line2MaxX
	if line1MaxX < line2MaxX {
		intMaxX = line1MaxX
	}
	intMinY := line2MinY
	if line1MinY > line2MinY {
		intMinY = line1MinY
	}
	intMaxY := line2MaxY
	if line1MaxY < line2MaxY {
		intMaxY = line1MaxY
	}

	intMidX := (intMinX + intMaxX) / 2.0
	intMidY := (intMinY + intMaxY) / 2.0
	normPt[0] = intMidX
	normPt[1] = intMidY

	line1Start[0] -= normPt[0]
	line1Start[1] -= normPt[1]
	line1End[0] -= normPt[0]
	line1End[1] -= normPt[1]
	line2Start[0] -= normPt[0]
	line2Start[1] -= normPt[1]
	line2End[0] -= normPt[0]
	line2End[1] -= normPt[1]
}
778864
func (c *Config) ReadEnvironment() error {
	var envAddress string
	var envAgentAddress string
	var envCACert string
	var envCAPath string
	var envClientCert string
	var envClientKey string
	var envClientTimeout time.Duration
	var envInsecure bool
	var envTLSServerName string
	var envMaxRetries *uint64
	var limit *rate.Limiter

	// Parse the environment variables
	if v := os.Getenv(EnvVaultAddress); v != "" {
		envAddress = v
	}
	if v := os.Getenv(EnvVaultAgentAddr); v != "" {
		envAgentAddress = v
	}
	if v := os.Getenv(EnvVaultMaxRetries); v != "" {
		maxRetries, err := strconv.ParseUint(v, 10, 32)
		if err != nil {
			return err
		}
		envMaxRetries = &maxRetries
	}
	if v := os.Getenv(EnvVaultCACert); v != "" {
		envCACert = v
	}
	if v := os.Getenv(EnvVaultCAPath); v != "" {
		envCAPath = v
	}
	if v := os.Getenv(EnvVaultClientCert); v != "" {
		envClientCert = v
	}
	if v := os.Getenv(EnvVaultClientKey); v != "" {
		envClientKey = v
	}
	if v := os.Getenv(EnvRateLimit); v != "" {
		rateLimit, burstLimit, err := parseRateLimit(v)
		if err != nil {
			return err
		}
		limit = rate.NewLimiter(rate.Limit(rateLimit), burstLimit)
	}
	if t := os.Getenv(EnvVaultClientTimeout); t != "" {
		clientTimeout, err := parseutil.ParseDurationSecond(t)
		if err != nil {
			return fmt.Errorf("could not parse %q", EnvVaultClientTimeout)
		}
		envClientTimeout = clientTimeout
	}
	if v := os.Getenv(EnvVaultSkipVerify); v != "" {
		var err error
		envInsecure, err = strconv.ParseBool(v)
		if err != nil {
			return fmt.Errorf("could not parse VAULT_SKIP_VERIFY")
		}
	}
	if v := os.Getenv(EnvVaultTLSServerName); v != "" {
		envTLSServerName = v
	}

	// Configure the HTTP clients TLS configuration.
	t := &TLSConfig{
		CACert:        envCACert,
		CAPath:        envCAPath,
		ClientCert:    envClientCert,
		ClientKey:     envClientKey,
		TLSServerName: envTLSServerName,
		Insecure:      envInsecure,
	}

	c.modifyLock.Lock()
	defer c.modifyLock.Unlock()

	c.Limiter = limit

	if err := c.ConfigureTLS(t); err != nil {
		return err
	}

	if envAddress != "" {
		c.Address = envAddress
	}

	if envAgentAddress != "" {
		c.AgentAddress = envAgentAddress
	}

	if envMaxRetries != nil {
		c.MaxRetries = int(*envMaxRetries)
	}

	if envClientTimeout != 0 {
		c.Timeout = envClientTimeout
	}

	return nil
}
1271835
func (app *AppModel) Normalize() error {
	for _, env := range app.Environments {
		if err := env.Normalize(); err != nil {
			return err
		}
	}
	return nil
}
182795
func ReplaceEnv(arg string, environments ...map[string]string) string {
	return envRe.ReplaceAllStringFunc(arg, func(arg string) string {
		stripped := arg[2 : len(arg)-1]
		for _, env := range environments {
			if value, ok := env[stripped]; ok {
				return value
			}
		}

		return arg
	})
}
1271326
func (v *Value) Normalize() error {
	norm, needsNormalization := v.Value.(interface {
		Normalize() error
	})
	if !needsNormalization {
		return nil
	}
	return norm.Normalize()
}