Exemple #1
0
package gogs

import (
	"github.com/drone/config"
	"github.com/drone/drone/plugin/remote"
)

var (
	gogsUrl    = config.String("gogs-url", "")
	gogsSecret = config.String("gogs-secret", "")
)

// Registers the Gogs plugin using the default
// settings from the config file or environment
// variables.
func Register() {
	if len(*gogsUrl) == 0 {
		return
	}
	remote.Register(
		New(*gogsUrl, *gogsSecret),
	)
}
Exemple #2
0
package bitbucket

import (
	"github.com/drone/config"
	"github.com/quartethealth/drone/plugin/remote"
)

var (
	// Bitbucket cloud configuration details
	bitbucketClient = config.String("bitbucket-client", "")
	bitbucketSecret = config.String("bitbucket-secret", "")
	bitbucketOpen   = config.Bool("bitbucket-open", false)
)

// Registers the Bitbucket plugin using the default
// settings from the config file or environment
// variables.
func Register() {
	if len(*bitbucketClient) == 0 || len(*bitbucketSecret) == 0 {
		return
	}
	remote.Register(
		NewDefault(*bitbucketClient, *bitbucketSecret, *bitbucketOpen),
	)
}
Exemple #3
0
const (
	DockerTLSWarning = `WARINING: Docker TLS cert or key not given, this may cause a build errors`
)

var (
	// commit sha for the current build, set by
	// the compile process.
	version  string = "0.3-dev"
	revision string
)

var (
	// Database driver configuration. Defaults to sqlite
	// when no database configuration specified.
	datasource = config.String("database-datasource", "drone.sqlite")
	driver     = config.String("database-driver", "sqlite3")

	// HTTP Server settings.
	port   = config.String("server-port", ":8000")
	sslcrt = config.String("server-ssl-cert", "")
	sslkey = config.String("server-ssl-key", "")

	// Enable self-registration. When false, the system admin
	// must grant user access.
	open = config.Bool("registration-open", false)

	workers *pool.Pool
	worker  *director.Director
	pub     *pubsub.PubSub
Exemple #4
0
package github

import (
	"github.com/drone/config"
	"github.com/drone/drone/plugin/remote"
)

var (
	// GitHub cloud configuration details
	githubClient = config.String("github-client", "")
	githubSecret = config.String("github-secret", "")

	// GitHub Enterprise configuration details
	githubEnterpriseURL     = config.String("github-enterprise-url", "")
	githubEnterpriseAPI     = config.String("github-enterprise-api", "")
	githubEnterpriseClient  = config.String("github-enterprise-client", "")
	githubEnterpriseSecret  = config.String("github-enterprise-secret", "")
	githubEnterprisePrivate = config.Bool("github-enterprise-private-mode", true)
)

// Registers the GitHub plugins using the default
// settings from the config file or environment
// variables.
func Register() {
	registerGitHub()
	registerGitHubEnterprise()
}

// registers the GitHub (github.com) plugin
func registerGitHub() {
	if len(*githubClient) == 0 || len(*githubSecret) == 0 {
Exemple #5
0
	"code.google.com/p/go.net/context"
	"github.com/armab/drone/server/datastore"
	"github.com/armab/drone/shared/httputil"
	"github.com/armab/drone/shared/model"
	"github.com/dgrijalva/jwt-go"
	"github.com/drone/config"
	"github.com/gorilla/securecookie"
)

// random key used to create jwt if none
// provided in the configuration.
var random = securecookie.GenerateRandomKey(32)

var (
	secret  = config.String("session-secret", string(random))
	expires = config.Duration("session-expires", time.Hour*72)
)

// GetUser gets the currently authenticated user for the
// http.Request. The user details will be stored as either
// a simple API token or JWT bearer token.
func GetUser(c context.Context, r *http.Request) *model.User {
	switch {
	case r.Header.Get("Authorization") != "":
		return getUserBearer(c, r)
	case r.FormValue("access_token") != "":
		return getUserToken(c, r)
	default:
		return nil
	}
const rsaKeyPrefix = "-----BEGIN RSA PRIVATE KEY-----"

func formatRsaKey(key string) string {
	// If this came from the config file it should be formatted right
	if !strings.HasPrefix(key, rsaKeyPrefix) {
		// Replace spaces in the key with newlines. This makes it
		// easier to pass the key in an environment variable
		key = strings.Replace(key, " ", "\n", -1)
		key = fmt.Sprintf("%s\n%s\n-----END RSA PRIVATE KEY-----", rsaKeyPrefix, key)
	}

	return key
}

var (
	googleServiceEmail      = config.String("google-service-email", "")
	googleServicePrivateKey = config.String("google-service-private-key", "")
	googleServiceUser       = config.String("google-service-user", "")
)

// InitializeGoogleGroup checks that our Google service account is able to fetch
// group membership for a user (It users the `google-service-user` to test).
func InitializeGoogleGroup() error {
	*googleServicePrivateKey = formatRsaKey(*googleServicePrivateKey)

	groups, err := GetUserGroups(*googleServiceUser)
	if err != nil {
		return fmt.Errorf("Google groups doesn't work: %s", err)
	}
	fmt.Printf("google groups test: passed (user %s is a member of %#v)\n",
		*googleServiceUser, groups)
Exemple #7
0
package gitlab

import (
	"github.com/drone/config"
	"github.com/drone/drone/plugin/remote"
)

var (
	gitlabURL        = config.String("gitlab-url", "")
	gitlabSkipVerify = config.Bool("gitlab-skip-verify", false)
)

// Registers the Gitlab plugin using the default
// settings from the config file or environment
// variables.
func Register() {
	if len(*gitlabURL) == 0 {
		return
	}
	remote.Register(
		New(
			*gitlabURL,
			*gitlabSkipVerify,
		),
	)
}
Exemple #8
0
package gitlab

import (
	"github.com/drone/config"
	"github.com/drone/drone/plugin/remote"
)

var (
	gitlabURL        = config.String("gitlab-url", "")
	gitlabSkipVerify = config.Bool("gitlab-skip-verify", false)
	gitlabOpen       = config.Bool("gitlab-open", false)

	gitlabClient = config.String("gitlab-client", "")
	gitlabSecret = config.String("gitlab-secret", "")
)

// Registers the Gitlab plugin using the default
// settings from the config file or environment
// variables.
func Register() {
	if len(*gitlabURL) == 0 {
		return
	}
	remote.Register(
		New(
			*gitlabURL,
			*gitlabSkipVerify,
			*gitlabOpen,
			*gitlabClient,
			*gitlabSecret,
		),
Exemple #9
0
	npm publish %s
	[ -n ${_NPM_PACKAGE_TAG} ] && npm tag ${_NPM_PACKAGE_NAME} ${_NPM_PACKAGE_TAG}
else
	echo "skipping publish, package ${_NPM_PACKAGE_NAME} already published"
fi
unset _NPM_PACKAGE_NAME
unset _NPM_PACKAGE_TAG
`

const (
	CmdAlwaysAuth  = "npm set always-auth true"
	CmdSetRegistry = "npm config set registry %s"
)

var (
	DefaultUser  = config.String("npm-user", "")
	DefaultPass  = config.String("npm-pass", "")
	DefaultEmail = config.String("npm-email", "")
)

type NPM struct {
	// The Email address used by NPM to connect
	// and publish to a repository
	Email string `yaml:"email,omitempty"`

	// The Username used by NPM to connect
	// and publish to a repository
	Username string `yaml:"username,omitempty"`

	// The Password used by NPM to connect
	// and publish to a repository
Exemple #10
0
	NotifyNever  = "never"  // never send email notifications
	NotifyAuthor = "author" // only send email notifications to the author

	NotifyTrue  = "true"  // alias for NotifyTrue
	NotifyFalse = "false" // alias for NotifyFalse
	NotifyOn    = "on"    // alias for NotifyTrue
	NotifyOff   = "off"   // alias for NotifyFalse
	NotifyBlame = "blame" // alias for NotifyAuthor
)

const (
	Subject = "[%s] %s/%s (%s - %s)"
)

var (
	DefaultHost = config.String("smtp-host", "")
	DefaultPort = config.String("smtp-port", "")
	DefaultFrom = config.String("smtp-from", "")
	DefaultUser = config.String("smtp-user", "")
	DefaultPass = config.String("smtp-pass", "")
)

type Email struct {
	Recipients []string `yaml:"recipients"`
	Success    string   `yaml:"on_success"`
	Failure    string   `yaml:"on_failure"`

	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	From     string `yaml:"from"`
	Username string `yaml:"username"`
Exemple #11
0
package stash

import (
	"github.com/drone/config"
	"github.com/drone/drone/plugin/remote"
)

var (
	// Stash configuration details
	stashURL        = config.String("stash-url", "")
	stashAPI        = config.String("stash-api", "")
	stashSecret     = config.String("stash-secret", "")
	stashPrivateKey = config.String("stash-private-key", "")
	stashHook       = config.String("stash-hook", "")
	stashOpen       = config.Bool("stash-open", false)
)

// Registers the Stash plugin using the default
// settings from the config file or environment
// variables
func Register() {
	if len(*stashURL) == 0 ||
		len(*stashAPI) == 0 ||
		len(*stashSecret) == 0 ||
		len(*stashPrivateKey) == 0 ||
		len(*stashHook) == 0 {
		return
	}
	remote.Register(
		New(
			*stashURL,
Exemple #12
0
_NPM_PACKAGE_NAME=$(cd %s && npm list | head -n 1 | cut -d ' ' -f1)
_NPM_PACKAGE_TAG="%s"
_EXISTING_NPM_PKG=$(npm info ${_NPM_PACKAGE_NAME} 2> /dev/null || true)
if [ "${_EXISTING_NPM_PKG}" = "" ] || [ "${_EXISTING_NPM_PKG}" = "undefined" ]
then
	npm publish %s
else
	echo "skipping publish, package ${_NPM_PACKAGE_NAME} already published"
fi
unset _NPM_PACKAGE_NAME
unset _NPM_PACKAGE_TAG
unset _EXISTING_NPM_PKG
`

var (
	DefaultToken    = config.String("npm-token", "")
	DefaultRegistry = config.String("npm-registry", "registry.npmjs.org")
)

type NPM struct {
	// The Token used by NPM to connect
	// and publish to a repository
	Token string `yaml:"token,omitempty"`

	// The registry URL of custom npm repository
	Registry string `yaml:"registry,omitempty"`

	// A folder containing the package.json file
	Folder string `yaml:"folder,omitempty"`

	// Registers the published package with the given tag
Exemple #13
0
	//"strings"

	"github.com/drone/config"

	"github.com/tuanp/autoapi/middleware"
	"github.com/tuanp/autoapi/router"
	"github.com/tuanp/autoapi/system"
	"github.com/tuanp/autoapi/util/log"

	//"github.com/RainingClouds/yaag/yaag"

	gojiMiddleware "github.com/zenazn/goji/web/middleware"
)

var (
	databaseUrl      = config.String("database-url", "mongodb://*****:*****@ds041160.mongolab.com:41160/voa")
	databaseName     = config.String("database-name", "voa")
	databaseUsername = config.String("database-username", "drone.sqlite")
	databasePassword = config.String("database-password", "drone.sqlite")

	// HTTP Server settings.
	port   = config.String("server-port", ":8000")
	sslcrt = config.String("server-ssl-cert", "")
	sslkey = config.String("server-ssl-key", "")
)

func main() {
	log.SetPriority(log.LOG_NOTICE)

	var conf string
	flag.StringVar(&conf, "config", "", "")
Exemple #14
0
	"github.com/armab/drone/plugin/remote/github/oauth"
	"github.com/armab/drone/shared/httputil"
	"github.com/armab/drone/shared/model"
	"github.com/drone/config"
	"github.com/drone/go-github/github"
)

const (
	DefaultAPI   = "https://api.github.com/"
	DefaultURL   = "https://github.com"
	DefaultScope = "repo,repo:status,user:email"
)

var (
	BuildConfigFile = config.String("server-file", ".drone.yml")
)

type GitHub struct {
	URL        string
	API        string
	Client     string
	Secret     string
	Private    bool
	SkipVerify bool
	Orgs       []string
	Open       bool
}

func New(url, api, client, secret string, private, skipVerify bool, orgs []string, open bool) *GitHub {
	var github = GitHub{
package awsconsoleauth

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"time"

	"github.com/dgrijalva/jwt-go"
	"github.com/drone/config"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/google"
)

var googleClientID = config.String("google-client-id", "")
var googleClientSecret = config.String("google-client-secret", "")
var googleDomain = config.String("google-domain", "")

var googleOauthConfig = &oauth2.Config{
	Scopes:   []string{"email"},
	Endpoint: google.Endpoint,
}

var googleJWTSigningKeys = map[string]interface{}{}

func updateGoogleJWTSigningKeys() error {
	// Fetch the google keys for oauth
	googleCertsResponse, err := http.Get("https://www.googleapis.com/oauth2/v1/certs")
	if err != nil {
		return err
Exemple #16
0
package awsconsoleauth

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"strings"
	"time"

	"github.com/crowdmob/goamz/aws"
	"github.com/crowdmob/goamz/sts"
	"github.com/drone/config"
)

var awsRegion = config.String("aws-region", "")

var awsAccessKey = config.String("aws-access-key-id", "")
var awsSecretKey = config.String("aws-secret-access-key", "")

var awsAuth aws.Auth

// InitializeAWS sets up access to the AWS Simple Token Service
func InitializeAWS() error {
	if *awsRegion == "" {
		*awsRegion = aws.InstanceRegion()
		if *awsRegion == "unknown" {
			*awsRegion = "us-east-1"
		}
	}