當前位置: 首頁>>代碼示例>>Golang>>正文


Golang envconfig.Env類代碼示例

本文整理匯總了Golang中github.com/drone/drone/shared/envconfig.Env的典型用法代碼示例。如果您正苦於以下問題:Golang Env類的具體用法?Golang Env怎麽用?Golang Env使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Env類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Load

// Load creates a new build engine, loaded with registered nodes from the
// database. The registered nodes are added to the pool of nodes to immediately
// start accepting workloads.
func Load(env envconfig.Env, s store.Store) Engine {
	engine := &engine{}
	engine.bus = newEventbus()
	engine.pool = newPool()
	engine.updater = &updater{engine.bus}

	// quick fix to propogate HTTP_PROXY variables
	// throughout the build environment.
	var proxyVars = []string{"HTTP_PROXY", "http_proxy", "HTTPS_PROXY", "https_proxy", "NO_PROXY", "no_proxy"}
	for _, proxyVar := range proxyVars {
		proxyVal := env.Get(proxyVar)
		if len(proxyVal) != 0 {
			engine.envs = append(engine.envs, proxyVar+"="+proxyVal)
		}
	}

	nodes, err := s.Nodes().GetList()
	if err != nil {
		log.Fatalf("failed to get nodes from database. %s", err)
	}
	for _, node := range nodes {
		engine.pool.allocate(node)
		log.Infof("registered docker daemon %s", node.Addr)
	}

	return engine
}
開發者ID:fclairamb,項目名稱:drone,代碼行數:30,代碼來源:engine.go

示例2: Load

func Load(env envconfig.Env) *Gitlab {
	config := env.String("REMOTE_CONFIG", "")

	url_, err := url.Parse(config)
	if err != nil {
		panic(err)
	}
	params := url_.Query()
	url_.RawQuery = ""

	gitlab := Gitlab{}
	gitlab.URL = url_.String()
	gitlab.Client = params.Get("client_id")
	gitlab.Secret = params.Get("client_secret")
	gitlab.AllowedOrgs = params["orgs"]
	gitlab.SkipVerify, _ = strconv.ParseBool(params.Get("skip_verify"))
	gitlab.Open, _ = strconv.ParseBool(params.Get("open"))

	switch params.Get("clone_mode") {
	case "oauth":
		gitlab.CloneMode = "oauth"
	default:
		gitlab.CloneMode = "token"
	}

	// this is a temp workaround
	gitlab.Search, _ = strconv.ParseBool(params.Get("search"))

	return &gitlab
}
開發者ID:fclairamb,項目名稱:drone,代碼行數:30,代碼來源:gitlab.go

示例3: Load

func Load(env envconfig.Env) *Github {
	config := env.String("REMOTE_CONFIG", "")

	// parse the remote DSN configuration string
	url_, err := url.Parse(config)
	if err != nil {
		log.Fatalln("unable to parse remote dsn. %s", err)
	}
	params := url_.Query()
	url_.Path = ""
	url_.RawQuery = ""

	// create the Githbub remote using parameters from
	// the parsed DSN configuration string.
	github := Github{}
	github.URL = url_.String()
	github.Client = params.Get("client_id")
	github.Secret = params.Get("client_secret")
	github.Orgs = params["orgs"]
	github.PrivateMode, _ = strconv.ParseBool(params.Get("private_mode"))
	github.SkipVerify, _ = strconv.ParseBool(params.Get("skip_verify"))
	github.Open, _ = strconv.ParseBool(params.Get("open"))
	github.GitSSH, _ = strconv.ParseBool(params.Get("ssh"))

	if github.URL == DefaultURL {
		github.API = DefaultAPI
	} else {
		github.API = github.URL + "/api/v3/"
	}

	return &github
}
開發者ID:rkrdo,項目名稱:drone,代碼行數:32,代碼來源:github.go

示例4: Load

// Load opens a new database connection with the specified driver
// and connection string specified in the environment variables.
func Load(env envconfig.Env) store.Store {
	var (
		driver = env.String("DATABASE_DRIVER", "sqlite3")
		config = env.String("DATABASE_CONFIG", "drone.sqlite")
	)

	log.Infof("using database driver %s", driver)
	log.Infof("using database config %s", config)

	return New(driver, config)
}
開發者ID:Gavinmine,項目名稱:drone,代碼行數:13,代碼來源:store.go

示例5: Load

func Load(env envconfig.Env) Remote {
	driver := env.Get("REMOTE_DRIVER")

	switch driver {
	case "bitbucket":
		return bitbucket.Load(env)
	case "github":
		return github.Load(env)
	case "gitlab":
		return gitlab.Load(env)
	case "gogs":
		return gogs.Load(env)

	default:
		log.Fatalf("unknown remote driver %s", driver)
	}

	return nil
}
開發者ID:fclairamb,項目名稱:drone,代碼行數:19,代碼來源:remote.go

示例6: Load

func Load(env envconfig.Env) *Gogs {
	config := env.String("REMOTE_CONFIG", "")

	// parse the remote DSN configuration string
	url_, err := url.Parse(config)
	if err != nil {
		log.Fatalln("unable to parse remote dsn. %s", err)
	}
	params := url_.Query()
	url_.RawQuery = ""

	// create the Githbub remote using parameters from
	// the parsed DSN configuration string.
	gogs := Gogs{}
	gogs.URL = url_.String()
	gogs.PrivateMode, _ = strconv.ParseBool(params.Get("private_mode"))
	gogs.SkipVerify, _ = strconv.ParseBool(params.Get("skip_verify"))
	gogs.Open, _ = strconv.ParseBool(params.Get("open"))

	return &gogs
}
開發者ID:clanstyles,項目名稱:drone,代碼行數:21,代碼來源:gogs.go

示例7: Load

func Load(env envconfig.Env) *Server {
	return &Server{
		Addr: env.String("SERVER_ADDR", ":8000"),
		Cert: env.String("SERVER_CERT", ""),
		Key:  env.String("SERVER_KEY", ""),
	}
}
開發者ID:fclairamb,項目名稱:drone,代碼行數:7,代碼來源:server.go

示例8: Load

func Load(env envconfig.Env) *Bitbucket {
	config := env.String("REMOTE_CONFIG", "")

	// parse the remote DSN configuration string
	url_, err := url.Parse(config)
	if err != nil {
		log.Fatalln("unable to parse remote dsn. %s", err)
	}
	params := url_.Query()
	url_.Path = ""
	url_.RawQuery = ""

	// create the Githbub remote using parameters from
	// the parsed DSN configuration string.
	bitbucket := Bitbucket{}
	bitbucket.Client = params.Get("client_id")
	bitbucket.Secret = params.Get("client_secret")
	bitbucket.Orgs = params["orgs"]
	bitbucket.Open, _ = strconv.ParseBool(params.Get("open"))

	return &bitbucket
}
開發者ID:fclairamb,項目名稱:drone,代碼行數:22,代碼來源:bitbucket.go


注:本文中的github.com/drone/drone/shared/envconfig.Env類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。