// getVariable gets environment variable's value from the image metadata
323860
func getVariable(image *api.Image, name string) string {
	envName := name + "="
	for _, v := range image.Config.Env {
		if strings.HasPrefix(v, envName) {
			return strings.TrimSpace(v[len(envName):])
		}
	}

	return ""
}
645243
func (s *Service) FindVariableByID(ctx context.Context, id platform.ID) (*platform.Variable, error) {
	m, pe := s.loadVariable(ctx, id)
	if pe != nil {
		return nil, &platform.Error{
			Err: pe,
			Op:  OpPrefix + platform.OpFindVariableByID,
		}
	}

	return m, nil
}
169368
func (c *CloudAPI) GetImage(imageID string) (*cloudapi.Image, error) {
	if err := c.ProcessFunctionHook(c, imageID); err != nil {
		return nil, err
	}

	for _, image := range c.images {
		if image.Id == imageID {
			return &image, nil
		}
	}

	return nil, fmt.Errorf("Image %s not found", imageID)
}
676462
func Getenv(key, userDefault string) string {
	if val := os.Getenv(key); val != "" {
		return val
	}
	return userDefault
}
561854
func varNameForVar(raw config.InterpolatedVariable) string {
	switch v := raw.(type) {
	case *config.ModuleVariable:
		return fmt.Sprintf("module.%s.output.%s", v.Name, v.Field)
	case *config.ResourceVariable:
		return v.ResourceId()
	case *config.UserVariable:
		return fmt.Sprintf("var.%s", v.Name)
	default:
		return ""
	}
}
879886
func GetSessionSystemVar(s *variable.SessionVars, key string) (string, error) {
	key = strings.ToLower(key)
	sysVar := variable.SysVars[key]
	if sysVar == nil {
		return "", variable.UnknownSystemVar
	}
	sVal, ok := s.Systems[key]
	if ok {
		return sVal, nil
	}
	if sysVar.Scope&variable.ScopeGlobal == 0 {
		// None-Global variable can use pre-defined default value.
		return sysVar.Value, nil
	}
	gVal, err := s.GlobalVarsAccessor.GetGlobalSysVar(key)
	if err != nil {
		return "", errors.Trace(err)
	}
	s.Systems[key] = gVal
	return gVal, nil
}
348668
func WithVariable(v *runtimevar.Variable) source.Option {
	return func(o *source.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, variableKey{}, v)
	}
}
737249
func GetDotEnvVal(envPath, varName string) (string, error) {
	cmd := fmt.Sprintf("grep %s '%s' | rev | cut -d= -f1 | rev", varName, envPath)

	out, err := exec.Command("bash", "-c", cmd).Output()
	if err != nil {
		return "", fmt.Errorf("Failed to execute command: %s", cmd)
	}
	return string(out), nil
}
279728
func MustGet(key string) string {
	v := os.Getenv(key)
	if v == "" {
		panic("Environment variable " + key + " does not exist.")
	}

	return v
}
302259
func (s *Service) ReplaceVariable(ctx context.Context, m *platform.Variable) error {
	s.variableKV.Store(m.ID.String(), m)
	return nil
}
512254
func (c *images) Get(name string, options v1.GetOptions) (result *image.Image, err error) {
	result = &image.Image{}
	err = c.client.Get().
		Resource("images").
		Name(name).
		VersionedParams(&options, scheme.ParameterCodec).
		Do().
		Into(result)
	return
}
421922
func getvarint(pp *[]uint8) uint32 {
	var p []uint8
	var shift int
	var v uint32
	v = 0
	p = []uint8(*pp)
	for shift = 0; ; shift += 7 {
		v |= uint32(p[0]&0x7F) << uint(shift)
		tmp7 := p
		p = p[1:]
		if tmp7[0]&0x80 == 0 {
			break
		}
	}
	*pp = p
	return v
}
707569
func Getenv(ctx context.Context, key string) string {
	val, _ := LookupEnv(ctx, key)
	return val
}
227965
func (m *Mrb) GetGlobalVariable(name string) *MrbValue {
	cs := C.CString(name)
	defer C.free(unsafe.Pointer(cs))
	return newValue(m.state, C._go_mrb_gv_get(m.state, C.mrb_intern_cstr(m.state, cs)))
}
1046167
func getVariableValue(schema Schema, definitionAST *ast.VariableDefinition, input interface{}) (interface{}, error) {
	ttype, err := typeFromAST(schema, definitionAST.Type)
	if err != nil {
		return nil, err
	}
	variable := definitionAST.Variable

	if ttype == nil || !IsInputType(ttype) {
		return "", gqlerrors.NewError(
			fmt.Sprintf(`Variable "$%v" expected value of type `+
				`"%v" which cannot be used as an input type.`, variable.Name.Value, printer.Print(definitionAST.Type)),
			[]ast.Node{definitionAST},
			"",
			nil,
			[]int{},
			nil,
		)
	}

	isValid, messages := isValidInputValue(input, ttype)
	if isValid {
		if isNullish(input) {
			if definitionAST.DefaultValue != nil {
				return valueFromAST(definitionAST.DefaultValue, ttype, nil), nil
			}
		}
		return coerceValue(ttype, input), nil
	}
	if isNullish(input) {
		return "", gqlerrors.NewError(
			fmt.Sprintf(`Variable "$%v" of required type `+
				`"%v" was not provided.`, variable.Name.Value, printer.Print(definitionAST.Type)),
			[]ast.Node{definitionAST},
			"",
			nil,
			[]int{},
			nil,
		)
	}
	// convert input interface into string for error message
	bts, _ := json.Marshal(input)
	var (
		inputStr = string(bts)
		msg      string
	)
	if len(messages) > 0 {
		msg = "\n" + strings.Join(messages, "\n")
	}

	return "", gqlerrors.NewError(
		fmt.Sprintf(`Variable "$%v" got invalid value `+
			`%v.%v`, variable.Name.Value, inputStr, msg),
		[]ast.Node{definitionAST},
		"",
		nil,
		[]int{},
		nil,
	)
}
1359812
func ReadVariable(id string) (StaySetVariable, error) {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().ReadVariable(id)
}
66025
func (v *MrbValue) GetInstanceVariable(variable string) *MrbValue {
	cs := C.CString(variable)
	defer C.free(unsafe.Pointer(cs))
	return newValue(v.state, C._go_mrb_iv_get(v.state, v.value, C.mrb_intern_cstr(v.state, cs)))
}