// EnvOr will return the value for 'name' or the fallback if it doesn't exist
976106
func EnvOr(name, fallback string) string {
	value, ok := os.LookupEnv(name)
	if !ok {
		return fallback
	}

	return value
}
333950
func (v Variable) Resolve(env Environ) (string, Variable) {
	name := ""
	for i := 0; i < maxNameRefDepth; i++ {
		if v.Kind != NameRef {
			return name, v
		}
		name = v.Str // keep name for the next iteration
		v = env.Get(name)
	}
	return name, Variable{}
}
1157808
func (e *Encoder) Encode(v interface{}) error {
	val := reflect.ValueOf(v)
	return e.encode(val)
}
121577
func (e Environment) Get(name string) (value string, ok bool) {
	for _, env := range e {
		if env.Name == name {
			return env.Value, true
		}
	}
	return "", false
}
63084
func (e Enum) Name() string {
	switch e {
	case "-Infinity", "-0":
		return strings.Replace(string(e), "-", "Negative", 1)
	}
	s := strings.Replace(string(e), "-", " ", -1)
	s = strings.Title(s)
	return lint.Name(strings.Replace(s, " ", "", -1))
}
159868
func (ss *scaleSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) {
	managedByAS, err := ss.isNodeManagedByAvailabilitySet(name)
	if err != nil {
		klog.Errorf("Failed to check isNodeManagedByAvailabilitySet: %v", err)
		return cloudprovider.Zone{}, err
	}
	if managedByAS {
		// vm is managed by availability set.
		return ss.availabilitySet.GetZoneByNodeName(name)
	}

	_, _, vm, err := ss.getVmssVM(name)
	if err != nil {
		return cloudprovider.Zone{}, err
	}

	var failureDomain string
	if vm.Zones != nil && len(*vm.Zones) > 0 {
		// Get availability zone for the node.
		zones := *vm.Zones
		zoneID, err := strconv.Atoi(zones[0])
		if err != nil {
			return cloudprovider.Zone{}, fmt.Errorf("failed to parse zone %q: %v", zones, err)
		}

		failureDomain = ss.makeZone(zoneID)
	} else if vm.InstanceView != nil && vm.InstanceView.PlatformFaultDomain != nil {
		// Availability zone is not used for the node, falling back to fault domain.
		failureDomain = strconv.Itoa(int(*vm.InstanceView.PlatformFaultDomain))
	}

	return cloudprovider.Zone{
		FailureDomain: failureDomain,
		Region:        *vm.Location,
	}, nil
}
1334292
func (getter Getter) GetVar(name string) (Value, bool) {
	if getter == nil {
		return nilValue, false
	}
	v, ok := getter[name]
	return v, ok
}
1371916
func FromEnvP(env string, value interface{}) interface{} {
	ev, err := FromEnv(env, value)
	if err != nil {
		panic(err)
	}
	return ev
}
195624
func EnvBool(envVar string, defaultValue bool) bool {
	return envBool(os.Getenv, envVar, defaultValue)
}
222299
func (r *SdkRoleManager) Enumerate(
	ctx context.Context,
	req *api.SdkRoleEnumerateRequest,
) (*api.SdkRoleEnumerateResponse, error) {
	keys, err := r.kv.Keys(rolePrefix, "/")
	if err != nil {
		return nil, status.Errorf(codes.Internal, "Failed to access roles from database: %v", err)
	}

	names := make([]string, len(keys))
	for i, key := range keys {
		names[i] = strings.TrimPrefix(key, rolePrefix+"/")
	}

	return &api.SdkRoleEnumerateResponse{
		Names: names,
	}, nil
}
670691
func Encode(v interface{}) (ev interface{}, err error) {
	defer func() {
		if r := recover(); r != nil {
			if _, ok := r.(runtime.Error); ok {
				panic(r)
			}
			if v, ok := r.(string); ok {
				err = errors.New(v)
			} else {
				err = r.(error)
			}
		}
	}()

	return encode(reflect.ValueOf(v))
}
94403
func Env(key string, defaultValue string) string {
	val := os.Getenv(key)
	if len(val) == 0 {
		return defaultValue
	}
	return val
}
793491
func (r *Router) SetEnv(name, value string) {
	r.Lock()
	defer r.Unlock()

	env := os.Getenv(name)
	if len(env) == 0 { env = value }
	r.Set(name, env)
}
308915
func EncodeName(buf []byte, name string) ([]byte, error) {
	return Encode(buf, Names[name])
}
1098019
func (c *ServerContext) GetEnv(key string) (string, bool) {
	val, ok := c.env[key]
	return val, ok
}
389385
func environ(env map[string]*string) []string {
	var keys []string
	var pairs []string

	for k := range env {
		keys = append(keys, k)
	}

	sort.Strings(keys)

	for _, k := range keys {
		pairs = append(pairs, fmt.Sprintf("%s=%s", k, *env[k]))
	}

	return pairs
}
15818
func EnvAdd(m map[string]interface{}) web.MiddlewareType {
	return func(c *web.C, h http.Handler) http.Handler {
		return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
			for k, v := range m {
				c.Env[k] = v
			}
			h.ServeHTTP(rw, r)
		})
	}
}