// Base is Middleware used by Coordinator Flex services.
//
// It installs a production Services instance into the Context.
181988
func (gsvc *GlobalServices) Base(c *router.Context, next router.Handler) {
	services := flexServicesInst{
		GlobalServices: gsvc,
	}

	c.Context = coordinator.WithConfigProvider(c.Context, &services)
	c.Context = WithServices(c.Context, &services)
	next(c)
}
600812
func KeybaseServiceInfo(g *GlobalContext) ServiceInfo {
	return ServiceInfo{
		Version: VersionString(),
		Label:   g.Env.GetLabel(),
		Pid:     os.Getpid(),
	}
}
123129
func (c *GetRefConfigsCall) Context(ctx context.Context) *GetRefConfigsCall {
	c.ctx_ = ctx
	return c
}
819291
func (s Linear) ebase() int {
	if s.Base == 0 {
		return 10
	} else if s.Base == 1 {
		panic("scale.Linear cannot have a base of 1")
	} else if s.Base < 0 {
		panic("scale.Linear cannot have a negative base")
	}
	return s.Base
}
641250
func baseType(t reflect.Type, expected reflect.Kind) (reflect.Type, error) {
	t = reflectx.Deref(t)
	if t.Kind() != expected {
		return nil, fmt.Errorf("expected %s but got %s", expected, t.Kind())
	}
	return t, nil
}
123541
func (d *Dispatcher) baseURL() string {
	switch {
	case d.BaseURL != "" && strings.HasSuffix(d.BaseURL, "/"):
		return d.BaseURL
	case d.BaseURL != "":
		return d.BaseURL + "/"
	default:
		return "/internal/tasks/"
	}
}
866465
func pageBase() router.MiddlewareChain {
	return standard.Base().Extend(
		templates.WithTemplates(templateBundle),
		auth.Authenticate(server.UsersAPIAuthMethod{}),
	)
}
299283
func (ctx *ServiceContext) Service(service interface{}) error {
	element := reflect.ValueOf(service).Elem()
	if running, ok := ctx.services[element.Type()]; ok {
		element.Set(reflect.ValueOf(running))
		return nil
	}
	return ErrServiceUnknown
}
209690
func Static(root string) echo.MiddlewareFunc {
	c := DefaultStaticConfig
	c.Root = root
	return StaticWithConfig(c)
}
438807
func (c *ConfigLocal) KeybaseService() KeybaseService {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.service
}
900557
func Base(secretkey *[Size]byte) *[Size]byte {
	dst := new([Size]byte)
	curve25519.ScalarBaseMult(dst, secretkey)
	return dst
}
583883
func (c *ServerGetBootstrapCall) Context(ctx context.Context) *ServerGetBootstrapCall {
	c.ctx_ = ctx
	return c
}
280652
func (s *RedisMapStore) SetBase(base interface{}, tagName string) {
	if tagName == "" {
		tagName = "redis"
	}
	s.SetEncoder(func(input interface{}, properties ...string) (map[string]string, error) {
		return encoding.ToStringStringMap(tagName, input, properties...)
	})
	s.SetDecoder(func(input map[string]string) (output interface{}, err error) {
		return encoding.FromStringStringMap(tagName, base, input)
	})
}
1285396
func setupCodebase(appl application.Application, cb *codebase.Content, spaceID uuid.UUID) error {
	if cb.CodebaseID == "" {
		newCodeBase := codebase.Codebase{
			SpaceID: spaceID,
			Type:    "git",
			URL:     cb.Repository,
			StackID: ptr.String("java-centos"),
			//TODO: Think of making stackID dynamic value (from analyzer)
		}
		existingCB, err := appl.Codebases().LoadByRepo(context.Background(), spaceID, cb.Repository)
		if existingCB != nil {
			cb.CodebaseID = existingCB.ID.String()
			return nil
		}
		err = appl.Codebases().Create(context.Background(), &newCodeBase)
		if err != nil {
			return errors.NewInternalError(context.Background(), err)
		}
		cb.CodebaseID = newCodeBase.ID.String()
	}
	return nil
}
1070903
func (repo *Repository) GetMergeBase(base, head string) (string, error) {
	stdout, err := NewCommand("merge-base", base, head).RunInDir(repo.Path)
	if err != nil {
		if strings.Contains(err.Error(), "exit status 1") {
			return "", ErrNoMergeBase{}
		}
		return "", err
	}
	return strings.TrimSpace(stdout), nil
}
243170
func (f *FileServerDefinition) Context() string {
	suffix := fmt.Sprintf("file server %s", f.FilePath)
	var prefix string
	if f.Parent != nil {
		prefix = f.Parent.Context() + " "
	}
	return prefix + suffix
}
1144857
func compileBaseType(t ast.BaseType) (TypeSpec, error) {
	annots, err := compileAnnotations(t.Annotations)
	if err != nil {
		return nil, err
	}

	switch t.ID {
	case ast.BoolTypeID:
		return &BoolSpec{Annotations: annots}, nil
	case ast.I8TypeID:
		return &I8Spec{Annotations: annots}, nil
	case ast.I16TypeID:
		return &I16Spec{Annotations: annots}, nil
	case ast.I32TypeID:
		return &I32Spec{Annotations: annots}, nil
	case ast.I64TypeID:
		return &I64Spec{Annotations: annots}, nil
	case ast.DoubleTypeID:
		return &DoubleSpec{Annotations: annots}, nil
	case ast.StringTypeID:
		return &StringSpec{Annotations: annots}, nil
	case ast.BinaryTypeID:
		return &BinarySpec{Annotations: annots}, nil
	default:
		panic(fmt.Sprintf("unknown base type %v", t))
	}
}