本文整理汇总了Golang中github.com/tsuru/tsuru/provision.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
// Run is the function that starts the collector. The dryMode parameter
// indicates whether the collector should loop forever or not.
//
// It assumes the configuration has already been defined (from a config file or
// memory).
func Run(dryMode bool) {
log.Init()
connString, err := config.GetString("database:url")
if err != nil {
connString = db.DefaultDatabaseURL
}
dbName, err := config.GetString("database:name")
if err != nil {
dbName = db.DefaultDatabaseName
}
fmt.Printf("Using the database %q from the server %q.\n\n", dbName, connString)
if !dryMode {
provisioner, err := config.GetString("provisioner")
if err != nil {
fmt.Println("Warning: configuration didn't declare a provisioner, using default provisioner.")
provisioner = "docker"
}
app.Provisioner, err = provision.Get(provisioner)
if err != nil {
fatal(err)
}
fmt.Printf("Using %q provisioner.\n\n", provisioner)
timer, err := config.GetInt("collector:ticker-time")
if err != nil {
timer = 60
}
ticker := time.Tick(time.Duration(timer) * time.Second)
fmt.Println("tsuru collector agent started...")
collect(ticker)
}
}
示例2: RunAdminServer
// RunAdminServer starts tsuru administrative api
func RunAdminServer(dry bool) {
log.Init()
connString, err := config.GetString("database:url")
if err != nil {
connString = db.DefaultDatabaseURL
}
dbName, err := config.GetString("database:name")
if err != nil {
dbName = db.DefaultDatabaseName
}
fmt.Printf("Using the database %q from the server %q.\n\n", dbName, connString)
if !dry {
provisioner, err := getProvisioner()
if err != nil {
fmt.Printf("Warning: configuration didn't declare a provisioner, using default provisioner.\n")
}
app.Provisioner, err = provision.Get(provisioner)
if err != nil {
fatal(err)
}
fmt.Printf("Using %q provisioner.\n\n", provisioner)
listen, err := config.GetString("admin-listen")
if err != nil {
fatal(err)
}
listener, err := net.Listen("tcp", listen)
if err != nil {
fatal(err)
}
fmt.Printf("tsuru HTTP server listening at %s...\n", listen)
http.Handle("/", m)
fatal(http.Serve(listener, nil))
}
}
示例3: migrateImages
func migrateImages() error {
provisioner, _ := getProvisioner()
if provisioner == defaultProvisionerName {
p, err := provision.Get(provisioner)
if err != nil {
return err
}
err = p.(provision.InitializableProvisioner).Initialize()
if err != nil {
return err
}
return docker.MigrateImages()
}
return nil
}
示例4: migrateImages
func (c *migrateCmd) migrateImages() error {
provisioner, _ := getProvisioner()
if provisioner == "docker" {
p, err := provision.Get(provisioner)
if err != nil {
return err
}
err = p.(provision.InitializableProvisioner).Initialize()
if err != nil {
return err
}
return docker.MigrateImages()
}
return nil
}
示例5: List
// List returns the list of apps filtered through the filter parameter.
func List(filter *Filter) ([]App, error) {
apps := []App{}
conn, err := db.Conn()
if err != nil {
return nil, err
}
defer conn.Close()
query := filter.Query()
if err = conn.Apps().Find(query).All(&apps); err != nil {
return apps, err
}
if filter != nil && len(filter.Statuses) > 0 {
appsProvisionerMap := make(map[string][]provision.App)
for i := range apps {
a := &apps[i]
prov, err := a.getProvisioner()
if err != nil {
return nil, err
}
appsProvisionerMap[prov.GetName()] = append(appsProvisionerMap[prov.GetName()], a)
}
var provisionApps []provision.App
for provName, apps := range appsProvisionerMap {
prov, err := provision.Get(provName)
if err != nil {
return nil, err
}
if filterProv, ok := prov.(provision.AppFilterProvisioner); ok {
apps, err = filterProv.FilterAppsByUnitStatus(apps, filter.Statuses)
if err != nil {
return nil, err
}
}
provisionApps = append(provisionApps, apps...)
}
for i := range provisionApps {
apps[i] = *(provisionApps[i].(*App))
}
apps = apps[:len(provisionApps)]
}
return apps, nil
}
示例6: TestShouldBeRegistered
func (s *S) TestShouldBeRegistered(c *gocheck.C) {
p, err := provision.Get("docker")
c.Assert(err, gocheck.IsNil)
c.Assert(p, gocheck.FitsTypeOf, &dockerProvisioner{})
}
示例7: RunServer
// RunServer starts tsuru API server. The dry parameter indicates whether the
// server should run in dry mode, not starting the HTTP listener (for testing
// purposes).
func RunServer(dry bool) http.Handler {
log.Init()
connString, err := config.GetString("database:url")
if err != nil {
connString = db.DefaultDatabaseURL
}
dbName, err := config.GetString("database:name")
if err != nil {
dbName = db.DefaultDatabaseName
}
fmt.Printf("Using mongodb database %q from the server %q.\n", dbName, connString)
m := &delayedRouter{}
for _, handler := range tsuruHandlerList {
m.Add(handler.method, handler.path, handler.h)
}
if disableIndex, _ := config.GetBool("disable-index-page"); !disableIndex {
m.Add("Get", "/", Handler(index))
}
m.Add("Get", "/info", Handler(info))
m.Add("Get", "/services/instances", authorizationRequiredHandler(serviceInstances))
m.Add("Get", "/services/instances/{name}", authorizationRequiredHandler(serviceInstance))
m.Add("Delete", "/services/instances/{name}", authorizationRequiredHandler(removeServiceInstance))
m.Add("Post", "/services/instances", authorizationRequiredHandler(createServiceInstance))
m.Add("Put", "/services/instances/{instance}/{app}", authorizationRequiredHandler(bindServiceInstance))
m.Add("Delete", "/services/instances/{instance}/{app}", authorizationRequiredHandler(unbindServiceInstance))
m.Add("Get", "/services/instances/{instance}/status", authorizationRequiredHandler(serviceInstanceStatus))
m.Add("Put", "/services/instances/permission/{instance}/{team}", authorizationRequiredHandler(serviceInstanceGrantTeam))
m.Add("Delete", "/services/instances/permission/{instance}/{team}", authorizationRequiredHandler(serviceInstanceRevokeTeam))
m.AddAll("/services/proxy/{instance}", authorizationRequiredHandler(serviceInstanceProxy))
m.AddAll("/services/proxy/service/{service}", authorizationRequiredHandler(serviceProxy))
m.Add("Get", "/services", authorizationRequiredHandler(serviceList))
m.Add("Post", "/services", authorizationRequiredHandler(serviceCreate))
m.Add("Put", "/services", authorizationRequiredHandler(serviceUpdate))
m.Add("Delete", "/services/{name}", authorizationRequiredHandler(serviceDelete))
m.Add("Get", "/services/{name}", authorizationRequiredHandler(serviceInfo))
m.Add("Get", "/services/{name}/plans", authorizationRequiredHandler(servicePlans))
m.Add("Get", "/services/{name}/doc", authorizationRequiredHandler(serviceDoc))
m.Add("Put", "/services/{name}/doc", authorizationRequiredHandler(serviceAddDoc))
m.Add("Put", "/services/{service}/team/{team}", authorizationRequiredHandler(grantServiceAccess))
m.Add("Delete", "/services/{service}/team/{team}", authorizationRequiredHandler(revokeServiceAccess))
m.Add("Delete", "/apps/{app}", authorizationRequiredHandler(appDelete))
m.Add("Get", "/apps/{app}", authorizationRequiredHandler(appInfo))
m.Add("Post", "/apps/{app}/cname", authorizationRequiredHandler(setCName))
m.Add("Delete", "/apps/{app}/cname", authorizationRequiredHandler(unsetCName))
m.Add("Post", "/apps/{app}/plan", authorizationRequiredHandler(changePlan))
runHandler := authorizationRequiredHandler(runCommand)
m.Add("Post", "/apps/{app}/run", runHandler)
m.Add("Post", "/apps/{app}/restart", authorizationRequiredHandler(restart))
m.Add("Post", "/apps/{app}/start", authorizationRequiredHandler(start))
m.Add("Post", "/apps/{app}/stop", authorizationRequiredHandler(stop))
m.Add("Get", "/apps/{appname}/quota", AdminRequiredHandler(getAppQuota))
m.Add("Post", "/apps/{appname}/quota", AdminRequiredHandler(changeAppQuota))
m.Add("Get", "/apps/{app}/env", authorizationRequiredHandler(getEnv))
m.Add("Post", "/apps/{app}/env", authorizationRequiredHandler(setEnv))
m.Add("Delete", "/apps/{app}/env", authorizationRequiredHandler(unsetEnv))
m.Add("Get", "/apps", authorizationRequiredHandler(appList))
m.Add("Post", "/apps", authorizationRequiredHandler(createApp))
m.Add("Post", "/apps/{app}/team-owner", authorizationRequiredHandler(setTeamOwner))
forceDeleteLockHandler := AdminRequiredHandler(forceDeleteLock)
m.Add("Delete", "/apps/{app}/lock", forceDeleteLockHandler)
m.Add("Put", "/apps/{app}/units", authorizationRequiredHandler(addUnits))
m.Add("Delete", "/apps/{app}/units", authorizationRequiredHandler(removeUnits))
registerUnitHandler := authorizationRequiredHandler(registerUnit)
m.Add("Post", "/apps/{app}/units/register", registerUnitHandler)
setUnitStatusHandler := authorizationRequiredHandler(setUnitStatus)
m.Add("Post", "/apps/{app}/units/{unit}", setUnitStatusHandler)
m.Add("Put", "/apps/{app}/teams/{team}", authorizationRequiredHandler(grantAppAccess))
m.Add("Delete", "/apps/{app}/teams/{team}", authorizationRequiredHandler(revokeAppAccess))
m.Add("Get", "/apps/{app}/log", authorizationRequiredHandler(appLog))
logPostHandler := authorizationRequiredHandler(addLog)
m.Add("Post", "/apps/{app}/log", logPostHandler)
m.Add("Post", "/apps/{appname}/deploy/rollback", authorizationRequiredHandler(deployRollback))
m.Add("Post", "/apps/{app}/pool", authorizationRequiredHandler(appChangePool))
m.Add("Get", "/apps/{app}/metric/envs", authorizationRequiredHandler(appMetricEnvs))
m.Add("Post", "/apps/{app}/routes", AdminRequiredHandler(appRebuildRoutes))
m.Add("Post", "/units/status", authorizationRequiredHandler(setUnitsStatus))
m.Add("Get", "/deploys", authorizationRequiredHandler(deploysList))
m.Add("Get", "/deploys/{deploy}", authorizationRequiredHandler(deployInfo))
m.Add("Get", "/platforms", authorizationRequiredHandler(platformList))
m.Add("Post", "/platforms", AdminRequiredHandler(platformAdd))
m.Add("Put", "/platforms/{name}", AdminRequiredHandler(platformUpdate))
m.Add("Delete", "/platforms/{name}", AdminRequiredHandler(platformRemove))
// These handlers don't use {app} on purpose. Using :app means that only
// the token generate for the given app is valid, but these handlers
// use a token generated for Gandalf.
m.Add("Get", "/apps/{appname}/available", authorizationRequiredHandler(appIsAvailable))
//.........这里部分代码省略.........
示例8: RunServer
// RunServer starts tsuru API server. The dry parameter indicates whether the
// server should run in dry mode, not starting the HTTP listener (for testing
// purposes).
func RunServer(dry bool) http.Handler {
log.Init()
connString, err := config.GetString("database:url")
if err != nil {
connString = db.DefaultDatabaseURL
}
dbName, err := config.GetString("database:name")
if err != nil {
dbName = db.DefaultDatabaseName
}
fmt.Printf("Using the database %q from the server %q.\n\n", dbName, connString)
m := &delayedRouter{}
for _, handler := range tsuruHandlerList {
m.Add(handler.method, handler.path, handler.h)
}
m.Add("Get", "/schema/app", authorizationRequiredHandler(appSchema))
m.Add("Get", "/schema/service", authorizationRequiredHandler(serviceSchema))
m.Add("Get", "/schema/services", authorizationRequiredHandler(servicesSchema))
m.Add("Get", "/services/instances", authorizationRequiredHandler(serviceInstances))
m.Add("Get", "/services/instances/{name}", authorizationRequiredHandler(serviceInstance))
m.Add("Delete", "/services/instances/{name}", authorizationRequiredHandler(removeServiceInstance))
m.Add("Post", "/services/instances", authorizationRequiredHandler(createServiceInstance))
m.Add("Put", "/services/instances/{instance}/{app}", authorizationRequiredHandler(bindServiceInstance))
m.Add("Delete", "/services/instances/{instance}/{app}", authorizationRequiredHandler(unbindServiceInstance))
m.Add("Get", "/services/instances/{instance}/status", authorizationRequiredHandler(serviceInstanceStatus))
m.AddAll("/services/proxy/{instance}", authorizationRequiredHandler(serviceProxy))
m.Add("Get", "/services", authorizationRequiredHandler(serviceList))
m.Add("Post", "/services", authorizationRequiredHandler(serviceCreate))
m.Add("Put", "/services", authorizationRequiredHandler(serviceUpdate))
m.Add("Delete", "/services/{name}", authorizationRequiredHandler(serviceDelete))
m.Add("Get", "/services/{name}", authorizationRequiredHandler(serviceInfo))
m.Add("Get", "/services/{name}/plans", authorizationRequiredHandler(servicePlans))
m.Add("Get", "/services/{name}/doc", authorizationRequiredHandler(serviceDoc))
m.Add("Put", "/services/{name}/doc", authorizationRequiredHandler(serviceAddDoc))
m.Add("Put", "/services/{service}/{team}", authorizationRequiredHandler(grantServiceAccess))
m.Add("Delete", "/services/{service}/{team}", authorizationRequiredHandler(revokeServiceAccess))
m.Add("Delete", "/apps/{app}", authorizationRequiredHandler(appDelete))
m.Add("Get", "/apps/{app}", authorizationRequiredHandler(appInfo))
m.Add("Post", "/apps/{app}/cname", authorizationRequiredHandler(setCName))
m.Add("Delete", "/apps/{app}/cname", authorizationRequiredHandler(unsetCName))
runHandler := authorizationRequiredHandler(runCommand)
m.Add("Post", "/apps/{app}/run", runHandler)
m.Add("Post", "/apps/{app}/restart", authorizationRequiredHandler(restart))
m.Add("Post", "/apps/{app}/start", authorizationRequiredHandler(start))
m.Add("Post", "/apps/{app}/stop", authorizationRequiredHandler(stop))
m.Add("Get", "/apps/{app}/env", authorizationRequiredHandler(getEnv))
m.Add("Post", "/apps/{app}/env", authorizationRequiredHandler(setEnv))
m.Add("Delete", "/apps/{app}/env", authorizationRequiredHandler(unsetEnv))
m.Add("Get", "/apps", authorizationRequiredHandler(appList))
m.Add("Post", "/apps", authorizationRequiredHandler(createApp))
m.Add("Put", "/apps/{app}/units", authorizationRequiredHandler(addUnits))
m.Add("Delete", "/apps/{app}/units", authorizationRequiredHandler(removeUnits))
m.Add("Post", "/apps/{app}/units/{unit}", authorizationRequiredHandler(setUnitStatus))
m.Add("Put", "/apps/{app}/{team}", authorizationRequiredHandler(grantAppAccess))
m.Add("Delete", "/apps/{app}/{team}", authorizationRequiredHandler(revokeAppAccess))
m.Add("Get", "/apps/{app}/log", authorizationRequiredHandler(appLog))
logPostHandler := authorizationRequiredHandler(addLog)
m.Add("Post", "/apps/{app}/log", logPostHandler)
m.Add("Get", "/deploys", AdminRequiredHandler(deploysList))
m.Add("Get", "/deploys/{deploy}", AdminRequiredHandler(deployInfo))
m.Add("Get", "/platforms", authorizationRequiredHandler(platformList))
m.Add("Post", "/platforms", AdminRequiredHandler(platformAdd))
m.Add("Put", "/platforms/{name}", AdminRequiredHandler(platformUpdate))
// These handlers don't use :app on purpose. Using :app means that only
// the token generate for the given app is valid, but these handlers
// use a token generated for Gandalf.
m.Add("Get", "/apps/{appname}/available", authorizationRequiredHandler(appIsAvailable))
m.Add("Post", "/apps/{appname}/repository/clone", authorizationRequiredHandler(deploy))
m.Add("Post", "/apps/{appname}/deploy", authorizationRequiredHandler(deploy))
m.Add("Post", "/users", Handler(createUser))
m.Add("Get", "/auth/scheme", Handler(authScheme))
m.Add("Post", "/auth/login", Handler(login))
m.Add("Post", "/users/{email}/password", Handler(resetPassword))
m.Add("Post", "/users/{email}/tokens", Handler(login))
m.Add("Delete", "/users/tokens", authorizationRequiredHandler(logout))
m.Add("Put", "/users/password", authorizationRequiredHandler(changePassword))
m.Add("Delete", "/users", authorizationRequiredHandler(removeUser))
m.Add("Get", "/users/{email}/keys", authorizationRequiredHandler(listKeys))
m.Add("Post", "/users/keys", authorizationRequiredHandler(addKeyToUser))
m.Add("Delete", "/users/keys", authorizationRequiredHandler(removeKeyFromUser))
m.Add("Post", "/tokens", AdminRequiredHandler(generateAppToken))
m.Add("Delete", "/logs", AdminRequiredHandler(logRemove))
m.Add("Get", "/teams", authorizationRequiredHandler(teamList))
//.........这里部分代码省略.........
示例9: RunServer
// RunServer starts tsuru API server. The dry parameter indicates whether the
// server should run in dry mode, not starting the HTTP listener (for testing
// purposes).
func RunServer(dry bool) {
log.Init()
connString, err := config.GetString("database:url")
if err != nil {
connString = db.DefaultDatabaseURL
}
dbName, err := config.GetString("database:name")
if err != nil {
dbName = db.DefaultDatabaseName
}
fmt.Printf("Using the database %q from the server %q.\n\n", dbName, connString)
m := pat.New()
for _, handler := range tsuruHandlerList {
m.Add(handler.method, handler.path, handler.h)
}
m.Get("/schema/app", authorizationRequiredHandler(appSchema))
m.Get("/schema/service", authorizationRequiredHandler(serviceSchema))
m.Get("/schema/services", authorizationRequiredHandler(servicesSchema))
m.Get("/services/instances", authorizationRequiredHandler(serviceInstances))
m.Get("/services/instances/:name", authorizationRequiredHandler(serviceInstance))
m.Del("/services/instances/:name", authorizationRequiredHandler(removeServiceInstance))
m.Post("/services/instances", authorizationRequiredHandler(createServiceInstance))
m.Put("/services/instances/:instance/:app", authorizationRequiredHandler(bindServiceInstance))
m.Del("/services/instances/:instance/:app", authorizationRequiredHandler(unbindServiceInstance))
m.Get("/services/instances/:instance/status", authorizationRequiredHandler(serviceInstanceStatus))
m.Get("/services", authorizationRequiredHandler(serviceList))
m.Post("/services", authorizationRequiredHandler(serviceCreate))
m.Put("/services", authorizationRequiredHandler(serviceUpdate))
m.Del("/services/:name", authorizationRequiredHandler(serviceDelete))
m.Get("/services/:name", authorizationRequiredHandler(serviceInfo))
m.Get("/services/:name/plans", authorizationRequiredHandler(servicePlans))
m.Get("/services/:name/doc", authorizationRequiredHandler(serviceDoc))
m.Put("/services/:name/doc", authorizationRequiredHandler(serviceAddDoc))
m.Put("/services/:service/:team", authorizationRequiredHandler(grantServiceAccess))
m.Del("/services/:service/:team", authorizationRequiredHandler(revokeServiceAccess))
m.Del("/apps/:app", authorizationRequiredHandler(appDelete))
m.Get("/apps/:app", authorizationRequiredHandler(appInfo))
m.Post("/apps/:app/cname", authorizationRequiredHandler(setCName))
m.Del("/apps/:app/cname", authorizationRequiredHandler(unsetCName))
m.Post("/apps/:app/run", authorizationRequiredHandler(runCommand))
m.Get("/apps/:app/restart", authorizationRequiredHandler(restart))
m.Get("/apps/:app/start", authorizationRequiredHandler(start))
m.Get("/apps/:app/env", authorizationRequiredHandler(getEnv))
m.Post("/apps/:app/env", authorizationRequiredHandler(setEnv))
m.Del("/apps/:app/env", authorizationRequiredHandler(unsetEnv))
m.Get("/apps", authorizationRequiredHandler(appList))
m.Post("/apps", authorizationRequiredHandler(createApp))
m.Put("/apps/:app/units", authorizationRequiredHandler(addUnits))
m.Del("/apps/:app/units", authorizationRequiredHandler(removeUnits))
m.Put("/apps/:app/:team", authorizationRequiredHandler(grantAppAccess))
m.Del("/apps/:app/:team", authorizationRequiredHandler(revokeAppAccess))
m.Get("/apps/:app/log", authorizationRequiredHandler(appLog))
m.Post("/apps/:app/log", authorizationRequiredHandler(addLog))
m.Get("/deploys", AdminRequiredHandler(deploysList))
m.Get("/platforms", authorizationRequiredHandler(platformList))
m.Put("/platforms/add", AdminRequiredHandler(platformAdd))
// These handlers don't use :app on purpose. Using :app means that only
// the token generate for the given app is valid, but these handlers
// use a token generated for Gandalf.
m.Get("/apps/:appname/available", authorizationRequiredHandler(appIsAvailable))
m.Post("/apps/:appname/repository/clone", authorizationRequiredHandler(deploy))
m.Post("/apps/:appname/deploy", authorizationRequiredHandler(deploy))
if registrationEnabled, _ := config.GetBool("auth:user-registration"); registrationEnabled {
m.Post("/users", Handler(createUser))
}
m.Post("/users/:email/password", Handler(resetPassword))
m.Post("/users/:email/tokens", Handler(login))
m.Del("/users/tokens", authorizationRequiredHandler(logout))
m.Put("/users/password", authorizationRequiredHandler(changePassword))
m.Del("/users", authorizationRequiredHandler(removeUser))
m.Get("/users/:email/keys", authorizationRequiredHandler(listKeys))
m.Post("/users/keys", authorizationRequiredHandler(addKeyToUser))
m.Del("/users/keys", authorizationRequiredHandler(removeKeyFromUser))
m.Post("/tokens", AdminRequiredHandler(generateAppToken))
m.Del("/logs", AdminRequiredHandler(logRemove))
m.Get("/teams", authorizationRequiredHandler(teamList))
m.Post("/teams", authorizationRequiredHandler(createTeam))
m.Get("/teams/:name", authorizationRequiredHandler(getTeam))
m.Del("/teams/:name", authorizationRequiredHandler(removeTeam))
m.Put("/teams/:team/:user", authorizationRequiredHandler(addUserToTeam))
m.Del("/teams/:team/:user", authorizationRequiredHandler(removeUserFromTeam))
m.Get("/healers", authorizationRequiredHandler(healers))
//.........这里部分代码省略.........