Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
// 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
}
Ejemplo n.º 3
0
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
}
Ejemplo n.º 4
0
// 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)
}
Ejemplo n.º 5
0
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
}
Ejemplo n.º 6
0
func Load(env envconfig.Env) *Server {
	return &Server{
		Addr: env.String("SERVER_ADDR", ":8000"),
		Cert: env.String("SERVER_CERT", ""),
		Key:  env.String("SERVER_KEY", ""),
	}
}
Ejemplo n.º 7
0
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_.Path = ""
	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
}
Ejemplo n.º 8
0
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
}