mirror of
https://github.com/harness/drone.git
synced 2025-05-11 14:40:05 +08:00
Merge branch 'master' into gitea-oauth
This commit is contained in:
commit
dd0795bb1c
11
BUILDING_OSS
Normal file
11
BUILDING_OSS
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
1. Clone the repository
|
||||||
|
2. Install go 1.11 or later with Go modules enabled
|
||||||
|
3. Install binaries to $GOPATH/bin
|
||||||
|
|
||||||
|
go install -tags oss github.com/drone/drone/cmd/drone-server
|
||||||
|
|
||||||
|
4. Start the server at localhost:8080
|
||||||
|
|
||||||
|
export DRONE_GITHUB_CLIENT_ID=...
|
||||||
|
export DRONE_GITHUB_CLIENT_SECRET=...
|
||||||
|
drone-server
|
5
LICENSE
5
LICENSE
@ -10,6 +10,11 @@ The Drone Enterprise Edition is licensed under the Drone
|
|||||||
Non-Commercial License (the "Non-Commercial License"). A copy of
|
Non-Commercial License (the "Non-Commercial License"). A copy of
|
||||||
the Non-Commercial License is provided below.
|
the Non-Commercial License is provided below.
|
||||||
|
|
||||||
|
The source files in this repository have a header indicating
|
||||||
|
which license they are under. The BUILDING_OSS file provides
|
||||||
|
instructions for creating the Community Edition distribution
|
||||||
|
subject to the terms of the Apache License.
|
||||||
|
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
Drone Non-Commercial License
|
Drone Non-Commercial License
|
||||||
|
@ -54,6 +54,7 @@ type (
|
|||||||
Datadog Datadog
|
Datadog Datadog
|
||||||
Docker Docker
|
Docker Docker
|
||||||
HTTP HTTP
|
HTTP HTTP
|
||||||
|
Jsonnet Jsonnet
|
||||||
Logging Logging
|
Logging Logging
|
||||||
// Prometheus Prometheus
|
// Prometheus Prometheus
|
||||||
Proxy Proxy
|
Proxy Proxy
|
||||||
@ -116,6 +117,11 @@ type (
|
|||||||
Token string `envconfig:"DRONE_DATADOG_TOKEN"`
|
Token string `envconfig:"DRONE_DATADOG_TOKEN"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jsonnet configures the jsonnet plugin
|
||||||
|
Jsonnet struct {
|
||||||
|
Enabled bool `envconfig:"DRONE_JSONNET_ENABLED"`
|
||||||
|
}
|
||||||
|
|
||||||
// Kubernetes provides kubernetes configuration
|
// Kubernetes provides kubernetes configuration
|
||||||
Kubernetes struct {
|
Kubernetes struct {
|
||||||
Enabled bool `envconfig:"DRONE_KUBERNETES_ENABLED"`
|
Enabled bool `envconfig:"DRONE_KUBERNETES_ENABLED"`
|
||||||
@ -386,6 +392,48 @@ func (c *Config) String() string {
|
|||||||
return string(out)
|
return string(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsGitHub returns true if the GitHub integration
|
||||||
|
// is activated.
|
||||||
|
func (c *Config) IsGitHub() bool {
|
||||||
|
return c.Github.ClientID != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsGitHubEnterprise returns true if the GitHub
|
||||||
|
// integration is activated.
|
||||||
|
func (c *Config) IsGitHubEnterprise() bool {
|
||||||
|
return c.IsGitHub() && !strings.HasPrefix(c.Github.Server, "https://github.com")
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsGitLab returns true if the GitLab integration
|
||||||
|
// is activated.
|
||||||
|
func (c *Config) IsGitLab() bool {
|
||||||
|
return c.GitLab.ClientID != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsGogs returns true if the Gogs integration
|
||||||
|
// is activated.
|
||||||
|
func (c *Config) IsGogs() bool {
|
||||||
|
return c.Gogs.Server != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsGitea returns true if the Gitea integration
|
||||||
|
// is activated.
|
||||||
|
func (c *Config) IsGitea() bool {
|
||||||
|
return c.Gitea.Server != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsBitbucket returns true if the Bitbucket Cloud
|
||||||
|
// integration is activated.
|
||||||
|
func (c *Config) IsBitbucket() bool {
|
||||||
|
return c.Bitbucket.ClientID != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsStash returns true if the Atlassian Stash
|
||||||
|
// integration is activated.
|
||||||
|
func (c *Config) IsStash() bool {
|
||||||
|
return c.Stash.Server != ""
|
||||||
|
}
|
||||||
|
|
||||||
func defaultAddress(c *Config) {
|
func defaultAddress(c *Config) {
|
||||||
if c.Server.Key != "" || c.Server.Cert != "" || c.Server.Acme {
|
if c.Server.Key != "" || c.Server.Cert != "" || c.Server.Acme {
|
||||||
c.Server.Port = ":443"
|
c.Server.Port = ":443"
|
||||||
|
@ -57,6 +57,7 @@ func provideConfigPlugin(client *scm.Client, contents core.FileService, conf spe
|
|||||||
conf.Yaml.Secret,
|
conf.Yaml.Secret,
|
||||||
conf.Yaml.SkipVerify,
|
conf.Yaml.SkipVerify,
|
||||||
),
|
),
|
||||||
|
config.Jsonnet(contents, conf.Jsonnet.Enabled),
|
||||||
config.Repository(contents),
|
config.Repository(contents),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ func provideDatadog(
|
|||||||
repos core.RepositoryStore,
|
repos core.RepositoryStore,
|
||||||
builds core.BuildStore,
|
builds core.BuildStore,
|
||||||
system *core.System,
|
system *core.System,
|
||||||
|
license *core.License,
|
||||||
config config.Config,
|
config config.Config,
|
||||||
) *sink.Datadog {
|
) *sink.Datadog {
|
||||||
return sink.New(
|
return sink.New(
|
||||||
@ -152,8 +153,21 @@ func provideDatadog(
|
|||||||
builds,
|
builds,
|
||||||
*system,
|
*system,
|
||||||
sink.Config{
|
sink.Config{
|
||||||
Endpoint: config.Datadog.Endpoint,
|
Endpoint: config.Datadog.Endpoint,
|
||||||
Token: config.Datadog.Token,
|
Token: config.Datadog.Token,
|
||||||
|
License: license.Kind,
|
||||||
|
Licensor: license.Licensor,
|
||||||
|
Subscription: license.Subscription,
|
||||||
|
EnableGithub: config.IsGitHub(),
|
||||||
|
EnableGithubEnt: config.IsGitHubEnterprise(),
|
||||||
|
EnableGitlab: config.IsGitLab(),
|
||||||
|
EnableBitbucket: config.IsBitbucket(),
|
||||||
|
EnableStash: config.IsStash(),
|
||||||
|
EnableGogs: config.IsGogs(),
|
||||||
|
EnableGitea: config.IsGitea(),
|
||||||
|
EnableAgents: config.Agent.Enabled,
|
||||||
|
EnableNomad: config.Nomad.Enabled,
|
||||||
|
EnableKubernetes: config.Kube.Enabled,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,8 @@ func InitializeApplication(config2 config.Config) (application, error) {
|
|||||||
triggerer := trigger.New(configService, commitService, statusService, buildStore, scheduler, repositoryStore, userStore, webhookSender)
|
triggerer := trigger.New(configService, commitService, statusService, buildStore, scheduler, repositoryStore, userStore, webhookSender)
|
||||||
cronScheduler := cron2.New(commitService, cronStore, repositoryStore, userStore, triggerer)
|
cronScheduler := cron2.New(commitService, cronStore, repositoryStore, userStore, triggerer)
|
||||||
system := provideSystem(config2)
|
system := provideSystem(config2)
|
||||||
datadog := provideDatadog(userStore, repositoryStore, buildStore, system, config2)
|
coreLicense := provideLicense(client, config2)
|
||||||
|
datadog := provideDatadog(userStore, repositoryStore, buildStore, system, coreLicense, config2)
|
||||||
corePubsub := pubsub.New()
|
corePubsub := pubsub.New()
|
||||||
logStore := provideLogStore(db, config2)
|
logStore := provideLogStore(db, config2)
|
||||||
logStream := livelog.New()
|
logStream := livelog.New()
|
||||||
@ -75,7 +76,6 @@ func InitializeApplication(config2 config.Config) (application, error) {
|
|||||||
registryService := provideRegistryPlugin(config2)
|
registryService := provideRegistryPlugin(config2)
|
||||||
runner := provideRunner(buildManager, secretService, registryService, config2)
|
runner := provideRunner(buildManager, secretService, registryService, config2)
|
||||||
hookService := provideHookService(client, renewer, config2)
|
hookService := provideHookService(client, renewer, config2)
|
||||||
coreLicense := provideLicense(client, config2)
|
|
||||||
licenseService := license.NewService(userStore, repositoryStore, buildStore, coreLicense)
|
licenseService := license.NewService(userStore, repositoryStore, buildStore, coreLicense)
|
||||||
permStore := perm.New(db)
|
permStore := perm.New(db)
|
||||||
repositoryService := repo.New(client, renewer)
|
repositoryService := repo.New(client, renewer)
|
||||||
|
@ -45,12 +45,14 @@ var ErrBuildLimit = errors.New("Build limit exceeded")
|
|||||||
type (
|
type (
|
||||||
// License defines software license parameters.
|
// License defines software license parameters.
|
||||||
License struct {
|
License struct {
|
||||||
Expires time.Time `json:"expires_at,omitempty"`
|
Licensor string `json:"-"`
|
||||||
Kind string `json:"kind,omitempty"`
|
Subscription string `json:"-"`
|
||||||
Repos int64 `json:"repos,omitempty"`
|
Expires time.Time `json:"expires_at,omitempty"`
|
||||||
Users int64 `json:"users,omitempty"`
|
Kind string `json:"kind,omitempty"`
|
||||||
Builds int64 `json:"builds,omitempty"`
|
Repos int64 `json:"repos,omitempty"`
|
||||||
Nodes int64 `json:"nodes,omitempty"`
|
Users int64 `json:"users,omitempty"`
|
||||||
|
Builds int64 `json:"builds,omitempty"`
|
||||||
|
Nodes int64 `json:"nodes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LicenseService provides access to the license
|
// LicenseService provides access to the license
|
||||||
|
3
go.mod
3
go.mod
@ -18,7 +18,7 @@ require (
|
|||||||
github.com/drone/drone-go v0.0.0-20190217024616-3e8b71333e59
|
github.com/drone/drone-go v0.0.0-20190217024616-3e8b71333e59
|
||||||
github.com/drone/drone-runtime v0.0.0-20190210191445-ad403a0ca24e
|
github.com/drone/drone-runtime v0.0.0-20190210191445-ad403a0ca24e
|
||||||
github.com/drone/drone-ui v0.0.0-20190223014501-189a4d227db5
|
github.com/drone/drone-ui v0.0.0-20190223014501-189a4d227db5
|
||||||
github.com/drone/drone-yaml v1.0.1
|
github.com/drone/drone-yaml v1.0.2
|
||||||
github.com/drone/envsubst v1.0.1
|
github.com/drone/envsubst v1.0.1
|
||||||
github.com/drone/go-license v1.0.2
|
github.com/drone/go-license v1.0.2
|
||||||
github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2
|
github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2
|
||||||
@ -35,6 +35,7 @@ require (
|
|||||||
github.com/golang/protobuf v1.2.0
|
github.com/golang/protobuf v1.2.0
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
|
||||||
github.com/google/go-cmp v0.2.0
|
github.com/google/go-cmp v0.2.0
|
||||||
|
github.com/google/go-jsonnet v0.12.1
|
||||||
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
|
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
|
||||||
github.com/google/wire v0.2.1
|
github.com/google/wire v0.2.1
|
||||||
github.com/googleapis/gnostic v0.2.0
|
github.com/googleapis/gnostic v0.2.0
|
||||||
|
6
go.sum
6
go.sum
@ -50,6 +50,8 @@ github.com/drone/drone-yaml v1.0.1-0.20190222030833-0e9ca9cdb963 h1:c/xcHqxU4sSj
|
|||||||
github.com/drone/drone-yaml v1.0.1-0.20190222030833-0e9ca9cdb963/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
github.com/drone/drone-yaml v1.0.1-0.20190222030833-0e9ca9cdb963/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
||||||
github.com/drone/drone-yaml v1.0.1 h1:a5t5zCqDFRa791B6/7i19rSpuT9slublvCGt5v0tl+I=
|
github.com/drone/drone-yaml v1.0.1 h1:a5t5zCqDFRa791B6/7i19rSpuT9slublvCGt5v0tl+I=
|
||||||
github.com/drone/drone-yaml v1.0.1/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
github.com/drone/drone-yaml v1.0.1/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
||||||
|
github.com/drone/drone-yaml v1.0.2 h1:nj66Fi8LcFUHqSACjDou8QbWgU+3ZLFvsbafQCrfH1w=
|
||||||
|
github.com/drone/drone-yaml v1.0.2/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
||||||
github.com/drone/envsubst v1.0.1 h1:NOOStingM2sbBwsIUeQkKUz8ShwCUzmqMxWrpXItfPE=
|
github.com/drone/envsubst v1.0.1 h1:NOOStingM2sbBwsIUeQkKUz8ShwCUzmqMxWrpXItfPE=
|
||||||
github.com/drone/envsubst v1.0.1/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0=
|
github.com/drone/envsubst v1.0.1/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0=
|
||||||
github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrkok=
|
github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrkok=
|
||||||
@ -90,6 +92,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCy
|
|||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-jsonnet v0.12.1 h1:v0iUm/b4SBz7lR/diMoz9tLAz8lqtnNRKIwMrmU2HEU=
|
||||||
|
github.com/google/go-jsonnet v0.12.1/go.mod h1:gVu3UVSfOt5fRFq+dh9duBqXa5905QY8S1QvMNcEIVs=
|
||||||
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck=
|
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck=
|
||||||
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
||||||
github.com/google/wire v0.2.1 h1:TYj4Z2qjqxa2ufb34UJqVeO9aznL+i0fLO6TqThKZ7Y=
|
github.com/google/wire v0.2.1 h1:TYj4Z2qjqxa2ufb34UJqVeO9aznL+i0fLO6TqThKZ7Y=
|
||||||
@ -113,7 +117,7 @@ github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uP
|
|||||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||||
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6 h1:qCv4319q2q7XKn0MQbi8p37hsJ+9Xo8e6yojA73JVxk=
|
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6 h1:qCv4319q2q7XKn0MQbi8p37hsJ+9Xo8e6yojA73JVxk=
|
||||||
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6/go.mod h1:fXcdFsQoipQa7mwORhKad5jmDCeSy/RCGzWA08PO0lM=
|
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6/go.mod h1:fXcdFsQoipQa7mwORhKad5jmDCeSy/RCGzWA08PO0lM=
|
||||||
github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI=
|
github.com/hashicorp/go-rootcerts v1.0.0 h1:ueI78wUjYExhCvMLow4icJnayNNFRgy0d9EGs/a1T44=
|
||||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||||
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
|
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package builds
|
package builds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/render"
|
"github.com/drone/drone/handler/api/render"
|
||||||
"github.com/drone/drone/logger"
|
"github.com/drone/drone/logger"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandleIncomplete returns an http.HandlerFunc that writes a
|
// HandleIncomplete returns an http.HandlerFunc that writes a
|
||||||
|
33
handler/api/builds/builds_oss.go
Normal file
33
handler/api/builds/builds_oss.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package builds
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
)
|
||||||
|
|
||||||
|
var notImplemented = func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
render.NotImplemented(w, render.ErrNotImplemented)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleIncomplete returns a no-op http.HandlerFunc.
|
||||||
|
func HandleIncomplete(repos core.RepositoryStore) http.HandlerFunc {
|
||||||
|
return notImplemented
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package builds
|
package builds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,9 +12,9 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/errors"
|
"github.com/drone/drone/handler/api/errors"
|
||||||
"github.com/drone/drone/mock"
|
"github.com/drone/drone/mock"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
|
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package events
|
package events
|
||||||
|
|
||||||
@ -10,9 +20,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/render"
|
"github.com/drone/drone/handler/api/render"
|
||||||
"github.com/drone/drone/logger"
|
"github.com/drone/drone/logger"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package events
|
package events
|
||||||
|
|
||||||
@ -10,9 +20,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/request"
|
"github.com/drone/drone/handler/api/request"
|
||||||
"github.com/drone/drone/logger"
|
"github.com/drone/drone/logger"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandleGlobal creates an http.HandlerFunc that streams builds events
|
// HandleGlobal creates an http.HandlerFunc that streams builds events
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package events
|
package events
|
||||||
|
|
||||||
@ -12,8 +22,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/drone/drone/handler/api/render"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
)
|
)
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/render"
|
"github.com/drone/drone/handler/api/render"
|
||||||
"github.com/drone/drone/logger"
|
"github.com/drone/drone/logger"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandleItems returns an http.HandlerFunc that writes a
|
// HandleItems returns an http.HandlerFunc that writes a
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
32
handler/api/queue/none.go
Normal file
32
handler/api/queue/none.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package queue
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
)
|
||||||
|
|
||||||
|
var notImplemented = func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
render.NotImplemented(w, render.ErrNotImplemented)
|
||||||
|
}
|
||||||
|
|
||||||
|
func HandleItems(store core.StageStore) http.HandlerFunc {
|
||||||
|
return notImplemented
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
|
||||||
// import (
|
// import (
|
||||||
|
@ -2,4 +2,6 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
|
||||||
// import (
|
// import (
|
||||||
|
@ -2,4 +2,6 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
@ -2,15 +2,17 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package builds
|
package builds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/render"
|
"github.com/drone/drone/handler/api/render"
|
||||||
"github.com/drone/drone/handler/api/request"
|
"github.com/drone/drone/handler/api/request"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
)
|
)
|
||||||
|
37
handler/api/repos/builds/promote_oss.go
Normal file
37
handler/api/repos/builds/promote_oss.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package builds
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
)
|
||||||
|
|
||||||
|
var notImplemented = func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
render.NotImplemented(w, render.ErrNotImplemented)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandlePromote returns a non-op http.HandlerFunc.
|
||||||
|
func HandlePromote(
|
||||||
|
core.RepositoryStore,
|
||||||
|
core.BuildStore,
|
||||||
|
core.Triggerer,
|
||||||
|
) http.HandlerFunc {
|
||||||
|
return notImplemented
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package builds
|
package builds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,10 +12,10 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/errors"
|
"github.com/drone/drone/handler/api/errors"
|
||||||
"github.com/drone/drone/handler/api/request"
|
"github.com/drone/drone/handler/api/request"
|
||||||
"github.com/drone/drone/mock"
|
"github.com/drone/drone/mock"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
"github.com/golang/mock/gomock"
|
"github.com/golang/mock/gomock"
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package builds
|
package builds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/drone/drone/handler/api/render"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
)
|
)
|
||||||
|
28
handler/api/repos/builds/purge_oss.go
Normal file
28
handler/api/repos/builds/purge_oss.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package builds
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HandlePurge returns a non-op http.HandlerFunc.
|
||||||
|
func HandlePurge(core.RepositoryStore, core.BuildStore) http.HandlerFunc {
|
||||||
|
return notImplemented
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package builds
|
package builds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
7
handler/api/repos/builds/rollback.go
Normal file
7
handler/api/repos/builds/rollback.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
|
package builds
|
7
handler/api/repos/builds/rollback_test.go
Normal file
7
handler/api/repos/builds/rollback_test.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
|
package builds
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package stages
|
package stages
|
||||||
|
|
||||||
@ -9,8 +19,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/drone/drone/handler/api/render"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package stages
|
package stages
|
||||||
|
|
||||||
@ -9,8 +19,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/drone/drone/handler/api/render"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,4 +2,6 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
45
handler/api/system/none.go
Normal file
45
handler/api/system/none.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/handler/api/render"
|
||||||
|
)
|
||||||
|
|
||||||
|
var notImplemented = func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
render.NotImplemented(w, render.ErrNotImplemented)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleLicense returns a no-op http.HandlerFunc.
|
||||||
|
func HandleLicense(license core.License) http.HandlerFunc {
|
||||||
|
return notImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleStats returns a no-op http.HandlerFunc.
|
||||||
|
func HandleStats(
|
||||||
|
core.BuildStore,
|
||||||
|
core.StageStore,
|
||||||
|
core.UserStore,
|
||||||
|
core.RepositoryStore,
|
||||||
|
core.Pubsub,
|
||||||
|
core.LogStream,
|
||||||
|
) http.HandlerFunc {
|
||||||
|
return notImplemented
|
||||||
|
}
|
@ -2,14 +2,16 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/handler/api/render"
|
"github.com/drone/drone/handler/api/render"
|
||||||
"github.com/drone/drone/logger"
|
"github.com/drone/drone/logger"
|
||||||
"github.com/drone/drone/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package web
|
package web
|
||||||
|
|
||||||
@ -14,8 +24,8 @@ import (
|
|||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/drone/drone/logger"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/logger"
|
||||||
"github.com/drone/go-scm/scm"
|
"github.com/drone/go-scm/scm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package landingpage
|
package landingpage
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package web
|
package web
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package web
|
package web
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package web
|
package web
|
||||||
|
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
// +build !oss
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package livelog
|
package livelog
|
||||||
|
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
// +build !oss
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package livelog
|
package livelog
|
||||||
|
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
// +build !oss
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package livelog
|
package livelog
|
||||||
|
|
||||||
|
35
metric/handler_oss.go
Normal file
35
metric/handler_oss.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package metric
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Server is a no-op http Metrics server.
|
||||||
|
type Server struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewServer returns a new metrics server.
|
||||||
|
func NewServer(session core.Session) *Server {
|
||||||
|
return new(Server)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServeHTTP is a no-op http handler.
|
||||||
|
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {}
|
27
metric/metric_oss.go
Normal file
27
metric/metric_oss.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package metric
|
||||||
|
|
||||||
|
import "github.com/drone/drone/core"
|
||||||
|
|
||||||
|
func BuildCount(core.BuildStore) {}
|
||||||
|
func PendingBuildCount(core.BuildStore) {}
|
||||||
|
func RunningBuildCount(core.BuildStore) {}
|
||||||
|
func RunningJobCount(core.StageStore) {}
|
||||||
|
func PendingJobCount(core.StageStore) {}
|
||||||
|
func RepoCount(core.RepositoryStore) {}
|
||||||
|
func UserCount(core.UserStore) {}
|
@ -18,4 +18,18 @@ package sink
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Token string
|
Token string
|
||||||
|
|
||||||
|
License string
|
||||||
|
Licensor string
|
||||||
|
Subscription string
|
||||||
|
EnableGithub bool
|
||||||
|
EnableGithubEnt bool
|
||||||
|
EnableGitlab bool
|
||||||
|
EnableBitbucket bool
|
||||||
|
EnableStash bool
|
||||||
|
EnableGogs bool
|
||||||
|
EnableGitea bool
|
||||||
|
EnableAgents bool
|
||||||
|
EnableNomad bool
|
||||||
|
EnableKubernetes bool
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@ type payload struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type series struct {
|
type series struct {
|
||||||
Metric string `json:"metric"`
|
Metric string `json:"metric"`
|
||||||
Points [][]int64 `json:"points"`
|
Points [][]int64 `json:"points"`
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Tags map[string]string `json:"tags,omitempty"`
|
Tags []string `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Datadog defines a no-op sink to datadog.
|
// Datadog defines a no-op sink to datadog.
|
||||||
@ -82,6 +82,7 @@ func (d *Datadog) do(ctx context.Context, unix int64) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
tags := createTags(d.config)
|
||||||
data := new(payload)
|
data := new(payload)
|
||||||
data.Series = []series{
|
data.Series = []series{
|
||||||
{
|
{
|
||||||
@ -89,18 +90,21 @@ func (d *Datadog) do(ctx context.Context, unix int64) error {
|
|||||||
Points: [][]int64{[]int64{unix, users}},
|
Points: [][]int64{[]int64{unix, users}},
|
||||||
Type: "gauge",
|
Type: "gauge",
|
||||||
Host: d.system.Host,
|
Host: d.system.Host,
|
||||||
|
Tags: tags,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Metric: "drone.repos",
|
Metric: "drone.repos",
|
||||||
Points: [][]int64{[]int64{unix, repos}},
|
Points: [][]int64{[]int64{unix, repos}},
|
||||||
Type: "gauge",
|
Type: "gauge",
|
||||||
Host: d.system.Host,
|
Host: d.system.Host,
|
||||||
|
Tags: tags,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Metric: "drone.builds",
|
Metric: "drone.builds",
|
||||||
Points: [][]int64{[]int64{unix, builds}},
|
Points: [][]int64{[]int64{unix, builds}},
|
||||||
Type: "gauge",
|
Type: "gauge",
|
||||||
Host: d.system.Host,
|
Host: d.system.Host,
|
||||||
|
Tags: tags,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,21 @@ package sink
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Datadog defines a no-op sink to datadog.
|
// Datadog defines a no-op sink to datadog.
|
||||||
type Datadog struct{}
|
type Datadog struct{}
|
||||||
|
|
||||||
// New returns a no-op sink.
|
// New returns a no-op sink.
|
||||||
func New(Config) *Datadog {
|
func New(
|
||||||
|
core.UserStore,
|
||||||
|
core.RepositoryStore,
|
||||||
|
core.BuildStore,
|
||||||
|
core.System,
|
||||||
|
Config,
|
||||||
|
) *Datadog {
|
||||||
return new(Datadog)
|
return new(Datadog)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,9 @@ func TestDo(t *testing.T) {
|
|||||||
d.repos = repos
|
d.repos = repos
|
||||||
d.builds = builds
|
d.builds = builds
|
||||||
d.system.Host = "test.example.com"
|
d.system.Host = "test.example.com"
|
||||||
|
d.config.License = "trial"
|
||||||
|
d.config.EnableGithub = true
|
||||||
|
d.config.EnableAgents = true
|
||||||
d.config.Endpoint = "https://api.datadoghq.com/api/v1/series"
|
d.config.Endpoint = "https://api.datadoghq.com/api/v1/series"
|
||||||
d.do(noContext, 915148800)
|
d.do(noContext, 915148800)
|
||||||
|
|
||||||
@ -60,19 +63,22 @@ var sample = `{
|
|||||||
"metric": "drone.users",
|
"metric": "drone.users",
|
||||||
"points": [[915148800, 10]],
|
"points": [[915148800, 10]],
|
||||||
"type": "gauge",
|
"type": "gauge",
|
||||||
"host": "test.example.com"
|
"host": "test.example.com",
|
||||||
|
"tags": ["remote:github:cloud","scheduler:internal:agents","license:trial"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metric": "drone.repos",
|
"metric": "drone.repos",
|
||||||
"points": [[915148800, 20]],
|
"points": [[915148800, 20]],
|
||||||
"type": "gauge",
|
"type": "gauge",
|
||||||
"host": "test.example.com"
|
"host": "test.example.com",
|
||||||
|
"tags": ["remote:github:cloud","scheduler:internal:agents","license:trial"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metric": "drone.builds",
|
"metric": "drone.builds",
|
||||||
"points": [[915148800, 30]],
|
"points": [[915148800, 30]],
|
||||||
"type": "gauge",
|
"type": "gauge",
|
||||||
"host": "test.example.com"
|
"host": "test.example.com",
|
||||||
|
"tags": ["remote:github:cloud","scheduler:internal:agents","license:trial"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}`
|
}`
|
||||||
|
61
metric/sink/tags.go
Normal file
61
metric/sink/tags.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
|
package sink
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func createTags(config Config) []string {
|
||||||
|
var tags []string
|
||||||
|
switch {
|
||||||
|
case config.EnableBitbucket:
|
||||||
|
tags = append(tags, "remote:bitbucket:cloud")
|
||||||
|
case config.EnableStash:
|
||||||
|
tags = append(tags, "remote:bitbucket:server")
|
||||||
|
case config.EnableGithubEnt:
|
||||||
|
tags = append(tags, "remote:github:enterprise")
|
||||||
|
case config.EnableGithub:
|
||||||
|
tags = append(tags, "remote:github:cloud")
|
||||||
|
case config.EnableGitlab:
|
||||||
|
tags = append(tags, "remote:gitlab")
|
||||||
|
case config.EnableGogs:
|
||||||
|
tags = append(tags, "remote:gogs")
|
||||||
|
case config.EnableGitea:
|
||||||
|
tags = append(tags, "remote:gitea")
|
||||||
|
default:
|
||||||
|
tags = append(tags, "remote:undefined")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case config.EnableAgents:
|
||||||
|
tags = append(tags, "scheduler:internal:agents")
|
||||||
|
case config.EnableKubernetes:
|
||||||
|
tags = append(tags, "scheduler:kubernetes")
|
||||||
|
case config.EnableGithub:
|
||||||
|
tags = append(tags, "scheduler:nomad")
|
||||||
|
default:
|
||||||
|
tags = append(tags, "scheduler:internal:local")
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Subscription != "" {
|
||||||
|
tag := fmt.Sprintf("license:%s:%s:%s",
|
||||||
|
config.License,
|
||||||
|
config.Licensor,
|
||||||
|
config.Subscription,
|
||||||
|
)
|
||||||
|
tags = append(tags, tag)
|
||||||
|
} else if config.Licensor != "" {
|
||||||
|
tag := fmt.Sprintf("license:%s:%s",
|
||||||
|
config.License,
|
||||||
|
config.Licensor,
|
||||||
|
)
|
||||||
|
tags = append(tags, tag)
|
||||||
|
} else {
|
||||||
|
tag := fmt.Sprintf("license:%s", config.License)
|
||||||
|
tags = append(tags, tag)
|
||||||
|
}
|
||||||
|
return tags
|
||||||
|
}
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -18,8 +20,8 @@ import (
|
|||||||
|
|
||||||
"github.com/drone/drone/operator/manager"
|
"github.com/drone/drone/operator/manager"
|
||||||
|
|
||||||
"github.com/drone/drone/store/shared/db"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/store/shared/db"
|
||||||
|
|
||||||
"github.com/hashicorp/go-retryablehttp"
|
"github.com/hashicorp/go-retryablehttp"
|
||||||
"github.com/oxtoacart/bpool"
|
"github.com/oxtoacart/bpool"
|
||||||
|
@ -2,15 +2,17 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/drone/drone/store/shared/db"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/operator/manager"
|
"github.com/drone/drone/operator/manager"
|
||||||
|
"github.com/drone/drone/store/shared/db"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/h2non/gock"
|
"github.com/h2non/gock"
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
type serverError struct {
|
type serverError struct {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
101
operator/manager/rpc/server_oss.go
Normal file
101
operator/manager/rpc/server_oss.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package rpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/operator/manager"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Server is a no-op rpc server.
|
||||||
|
type Server struct {
|
||||||
|
manager manager.BuildManager
|
||||||
|
secret string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewServer returns a no-op rpc server.
|
||||||
|
func NewServer(manager.BuildManager, string) *Server {
|
||||||
|
return &Server{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request requests the next available build stage for execution.
|
||||||
|
func (Server) Request(ctx context.Context, args *manager.Request) (*core.Stage, error) {
|
||||||
|
return nil, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accept accepts the build stage for execution.
|
||||||
|
func (Server) Accept(ctx context.Context, stage int64, machine string) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Netrc returns a valid netrc for execution.
|
||||||
|
func (Server) Netrc(ctx context.Context, repo int64) (*core.Netrc, error) {
|
||||||
|
return nil, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Details fetches build details
|
||||||
|
func (Server) Details(ctx context.Context, stage int64) (*manager.Context, error) {
|
||||||
|
return nil, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Before signals the build step is about to start.
|
||||||
|
func (Server) Before(ctxt context.Context, step *core.Step) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// After signals the build step is complete.
|
||||||
|
func (Server) After(ctx context.Context, step *core.Step) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Before signals the build stage is about to start.
|
||||||
|
func (Server) BeforeAll(ctxt context.Context, stage *core.Stage) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// After signals the build stage is complete.
|
||||||
|
func (Server) AfterAll(ctx context.Context, stage *core.Stage) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch watches for build cancellation requests.
|
||||||
|
func (Server) Watch(ctx context.Context, stage int64) (bool, error) {
|
||||||
|
return false, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write writes a line to the build logs
|
||||||
|
func (Server) Write(ctx context.Context, step int64, line *core.Line) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload uploads the full logs
|
||||||
|
func (Server) Upload(ctx context.Context, step int64, r io.Reader) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadBytes uploads the full logs
|
||||||
|
func (Server) UploadBytes(ctx context.Context, step int64, b []byte) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServeHTTP is an empty handler.
|
||||||
|
func (Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {}
|
@ -2,4 +2,6 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
@ -9,8 +19,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/drone/drone/store/shared/db"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/store/shared/db"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
@ -9,8 +19,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/drone/drone/store/shared/db"
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
|
"github.com/drone/drone/store/shared/db"
|
||||||
"github.com/drone/go-scm/scm"
|
"github.com/drone/go-scm/scm"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package manager
|
package manager
|
||||||
|
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
// import (
|
// import (
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,4 +2,6 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package runner
|
|
||||||
|
|
||||||
// import (
|
|
||||||
// "context"
|
|
||||||
// "encoding/json"
|
|
||||||
// "strings"
|
|
||||||
|
|
||||||
// "github.com/drone/drone-yaml/yaml"
|
|
||||||
// "github.com/drone/drone/core"
|
|
||||||
// "github.com/drone/drone/plugin/registry/auths"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// type registryManager struct {
|
|
||||||
// build *core.Build
|
|
||||||
// config *yaml.Manifest
|
|
||||||
// repo *core.Repository
|
|
||||||
// auths core.RegistryService
|
|
||||||
// secrets core.SecretService
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (s *registryManager) list(_ context.Context) ([]*core.Registry, error) {
|
|
||||||
// // get the registry credentials from the external
|
|
||||||
// // registry credential provider. This could, for example,
|
|
||||||
// // source credentials from ~/.docker/config.json
|
|
||||||
// registries, err := s.auths.List(noContext, &core.RegistryRequest{
|
|
||||||
// Repo: s.repo,
|
|
||||||
// Build: s.build,
|
|
||||||
// })
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // // get the registry credentials from the external
|
|
||||||
// // // user-defined registry credential provider.
|
|
||||||
// // userdef, err := s.auths.ListEndpoint(noContext, &core.RegistryRequest{
|
|
||||||
// // Repo: s.repo,
|
|
||||||
// // Build: s.build,
|
|
||||||
// // }, s.repo.Endpoints.Registry)
|
|
||||||
// // if err != nil {
|
|
||||||
// // return nil, err
|
|
||||||
// // }
|
|
||||||
// // // append user-defined registry credentials to the list.
|
|
||||||
// // registries = append(registries, userdef...)
|
|
||||||
|
|
||||||
// // the user can also define registry credentials in the
|
|
||||||
// // yaml secret section.
|
|
||||||
// for _, resource := range s.config.Resources {
|
|
||||||
// res, ok := resource.(*yaml.Secret)
|
|
||||||
// if !ok {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// for name, value := range res.Data {
|
|
||||||
// // skip secrets the are intended for use with authenticating
|
|
||||||
// // to the docker registry and pulling private images.
|
|
||||||
// if isDockerConfig(name) == false {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if res.Type == "encrypted" {
|
|
||||||
// value = strings.Replace(value, " ", "", -1)
|
|
||||||
// value = strings.Replace(value, "\n", "", -1)
|
|
||||||
|
|
||||||
// plaintext, err := decrypt(core.EncryptAESGCM, value, s.repo.Secret)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// secret := new(core.Secret)
|
|
||||||
// err = json.Unmarshal([]byte(plaintext), secret)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// parsed, err := auths.ParseString(secret.Data)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// registries = append(registries, parsed...)
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// // the user has the option of aliasing the
|
|
||||||
// // secret name. If the user specifies an external
|
|
||||||
// // name it must be used for the external query.
|
|
||||||
// req := &core.SecretRequest{
|
|
||||||
// Name: value,
|
|
||||||
// Repo: s.repo,
|
|
||||||
// Build: s.build,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // TODO: bradrydzewski this should fetch from
|
|
||||||
// // the user-defined secrets.
|
|
||||||
// //
|
|
||||||
// secret, err := s.secrets.Find(noContext, req)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// parsed, err := auths.ParseString(secret.Data)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// registries = append(registries, parsed...)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return registries, nil
|
|
||||||
// }
|
|
@ -1,323 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package runner
|
|
||||||
|
|
||||||
// import (
|
|
||||||
// "context"
|
|
||||||
// "encoding/json"
|
|
||||||
// "io"
|
|
||||||
// "testing"
|
|
||||||
|
|
||||||
// "github.com/drone/drone-yaml/yaml"
|
|
||||||
// "github.com/drone/drone/core"
|
|
||||||
// "github.com/drone/drone/mock"
|
|
||||||
|
|
||||||
// "github.com/golang/mock/gomock"
|
|
||||||
// "github.com/google/go-cmp/cmp"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// func Test_RegistryManager_ListExternal(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// want := []*core.Registry{
|
|
||||||
// {
|
|
||||||
// Address: "docker.io",
|
|
||||||
// Username: "octocat",
|
|
||||||
// Password: "pa55word",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// service := mock.NewMockRegistryService(controller)
|
|
||||||
// service.EXPECT().List(gomock.Any(), gomock.Any()).Return(want, nil)
|
|
||||||
// service.EXPECT().ListEndpoint(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// auths: service,
|
|
||||||
// config: &yaml.Manifest{},
|
|
||||||
// repo: &core.Repository{},
|
|
||||||
// }
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// }
|
|
||||||
// if diff := cmp.Diff(got, want); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // this test verifies that the registry credential manager
|
|
||||||
// // exits and returns an error if unable to fetch registry
|
|
||||||
// // credentials from the external provider.
|
|
||||||
// func Test_RegistryManager_ListExternal_Err(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// service := mock.NewMockRegistryService(controller)
|
|
||||||
// service.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil, io.EOF)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// auths: service,
|
|
||||||
// }
|
|
||||||
// _, err := manager.list(noContext)
|
|
||||||
// if err == nil {
|
|
||||||
// t.Errorf("Expect error fetching external secret")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // this test verifies that the registry credential manager
|
|
||||||
// // skips secrets that are not docker_auth_config files.
|
|
||||||
// func Test_RegistryManager_ListInternal_Skip(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// service := mock.NewMockRegistryService(controller)
|
|
||||||
// service.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
// service.EXPECT().ListEndpoint(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// repo: &core.Repository{},
|
|
||||||
// auths: service,
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "external",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "docker_password",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var want []*core.Registry
|
|
||||||
// if diff := cmp.Diff(got, want); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // this test verifies that the registry credential manager
|
|
||||||
// // fetches registry credentials from the remote secret store,
|
|
||||||
// // and successfully parses the .docker/config.json contents.
|
|
||||||
// func Test_RegistryManager_ListExternalSecrets(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// mockRepo := &core.Repository{
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockBuild := &core.Build{
|
|
||||||
// Event: core.EventPullRequest,
|
|
||||||
// Fork: "octocat/hello-world",
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockSecret := &core.Secret{
|
|
||||||
// Name: "docker_auth_config",
|
|
||||||
// Data: `{"auths": {"index.docker.io": {"auth": "b2N0b2NhdDpjb3JyZWN0LWhvcnNlLWJhdHRlcnktc3RhcGxl"}}}`,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockSecretReq := &core.SecretRequest{
|
|
||||||
// Name: mockSecret.Name,
|
|
||||||
// Repo: mockRepo,
|
|
||||||
// Build: mockBuild,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockResp := func(ctx context.Context, req *core.SecretRequest) (*core.Secret, error) {
|
|
||||||
// if diff := cmp.Diff(req, mockSecretReq); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// return mockSecret, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// registries := mock.NewMockRegistryService(controller)
|
|
||||||
// registries.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
// registries.EXPECT().ListEndpoint(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
|
|
||||||
// secrets := mock.NewMockSecretService(controller)
|
|
||||||
// secrets.EXPECT().Find(gomock.Any(), gomock.Any()).DoAndReturn(mockResp)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// auths: registries,
|
|
||||||
// secrets: secrets,
|
|
||||||
// repo: mockRepo,
|
|
||||||
// build: mockBuild,
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "external",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_auth_config": "docker_auth_config",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// want := []*core.Registry{
|
|
||||||
// {
|
|
||||||
// Address: "index.docker.io",
|
|
||||||
// Username: "octocat",
|
|
||||||
// Password: "correct-horse-battery-staple",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if diff := cmp.Diff(got, want); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // this test verifies that the registry credential manager
|
|
||||||
// // fetches registry credentials from the remote secret store,
|
|
||||||
// // and returns an error if external rpc call fails.
|
|
||||||
// func Test_RegistryManager_ListExternalSecrets_Err(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// registries := mock.NewMockRegistryService(controller)
|
|
||||||
// registries.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
// registries.EXPECT().ListEndpoint(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
|
|
||||||
// secrets := mock.NewMockSecretService(controller)
|
|
||||||
// secrets.EXPECT().Find(gomock.Any(), gomock.Any()).Return(nil, io.EOF)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// repo: &core.Repository{},
|
|
||||||
// auths: registries,
|
|
||||||
// secrets: secrets,
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "external",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_auth_config": "docker_auth_config",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _, err := manager.list(noContext)
|
|
||||||
// if err == nil {
|
|
||||||
// t.Errorf("Expect error")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // this test verifies that the registry credential manager
|
|
||||||
// // fetches registry credentials from the remote secret store,
|
|
||||||
// // and returns an error if the .docker/config.json contents
|
|
||||||
// // cannot be unmarshaled.
|
|
||||||
// func Test_RegistryManager_ListExternalSecrets_ParseErr(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// mockSecret := &core.Secret{
|
|
||||||
// Name: "docker_auth_config",
|
|
||||||
// Data: `[]`,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// registries := mock.NewMockRegistryService(controller)
|
|
||||||
// registries.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
// registries.EXPECT().ListEndpoint(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
|
|
||||||
// secrets := mock.NewMockSecretService(controller)
|
|
||||||
// secrets.EXPECT().Find(gomock.Any(), gomock.Any()).Return(mockSecret, nil)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// auths: registries,
|
|
||||||
// secrets: secrets,
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// Fork: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "external",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_auth_config": "docker_auth_config",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _, err := manager.list(noContext)
|
|
||||||
// if _, ok := err.(*json.UnmarshalTypeError); !ok {
|
|
||||||
// t.Errorf("Expect decoding error")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // this test verifies that the registry credential manager
|
|
||||||
// // can decrypt inline registry credentials included in the yaml,
|
|
||||||
// // where the encrypted content is a .docker/config.json file.
|
|
||||||
// func Test_RegistryManager_ListInline(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// if true {
|
|
||||||
// t.Skipf("skip docker_auth_config encryption test")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// registries := mock.NewMockRegistryService(controller)
|
|
||||||
// registries.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
// registries.EXPECT().ListEndpoint(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil)
|
|
||||||
|
|
||||||
// manager := registryManager{
|
|
||||||
// auths: registries,
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Secret: "m5bahAG7YVp114R4YgMv5uW7bTEzx7yn",
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// Fork: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "encrypted",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_auth_config": "0jye_JUWxgu1qZRd56d9GSnl3-gJgsBAakeKAQ4BX_UDSvT0ntcwXT38KfiI5OY-BNZSKwfoQrQuPYn2VJWXcUMSmy0JLdBEDzWJ-m8s-KPBApuh6vVTafKzrslK-E0P7ZfqiR0ulXWsHqJhzVXInjITx8oxsmcZ458Fwbvk6gXLudRsKKr6RjI4Jcr4mQGT",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// want := []*core.Registry{
|
|
||||||
// {
|
|
||||||
// Address: "index.docker.io",
|
|
||||||
// Username: "octocat",
|
|
||||||
// Password: "correct-horse-battery-staple",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// if diff := cmp.Diff(got, want); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
|
||||||
@ -277,16 +287,16 @@ func (r *Runner) Run(ctx context.Context, id int64) error {
|
|||||||
transform.WithEnviron(r.Environ),
|
transform.WithEnviron(r.Environ),
|
||||||
transform.WithLables(
|
transform.WithLables(
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"io.drone": "true",
|
"io.drone": "true",
|
||||||
"io.core.build.number": fmt.Sprint(m.Build.Number),
|
"io.drone.build.number": fmt.Sprint(m.Build.Number),
|
||||||
"io.core.repo.namespace": m.Repo.Namespace,
|
"io.drone.repo.namespace": m.Repo.Namespace,
|
||||||
"io.core.repo.name": m.Repo.Name,
|
"io.drone.repo.name": m.Repo.Name,
|
||||||
"io.core.stage.name": m.Stage.Name,
|
"io.drone.stage.name": m.Stage.Name,
|
||||||
"io.core.stage.number": fmt.Sprint(m.Stage.Number),
|
"io.drone.stage.number": fmt.Sprint(m.Stage.Number),
|
||||||
"io.core.ttl": fmt.Sprint(time.Duration(m.Repo.Timeout) * time.Minute),
|
"io.drone.ttl": fmt.Sprint(time.Duration(m.Repo.Timeout) * time.Minute),
|
||||||
"io.core.expires": fmt.Sprint(time.Now().Add(time.Duration(m.Repo.Timeout)*time.Minute + time.Hour).Unix()),
|
"io.drone.expires": fmt.Sprint(time.Now().Add(time.Duration(m.Repo.Timeout)*time.Minute + time.Hour).Unix()),
|
||||||
"io.core.created": fmt.Sprint(time.Now().Unix()),
|
"io.drone.created": fmt.Sprint(time.Now().Unix()),
|
||||||
"io.core.protected": "false",
|
"io.drone.protected": "false",
|
||||||
},
|
},
|
||||||
), // TODO append labels here
|
), // TODO append labels here
|
||||||
transform.WithLimits(
|
transform.WithLimits(
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
|
||||||
@ -13,121 +23,3 @@ func toSecretMap(secrets []*core.Secret) map[string]string {
|
|||||||
}
|
}
|
||||||
return set
|
return set
|
||||||
}
|
}
|
||||||
|
|
||||||
// import (
|
|
||||||
// "context"
|
|
||||||
// "encoding/json"
|
|
||||||
// "strings"
|
|
||||||
|
|
||||||
// "github.com/drone/drone-yaml/yaml"
|
|
||||||
// "github.com/drone/drone/core"
|
|
||||||
// "github.com/drone/drone/crypto/aesgcm"
|
|
||||||
// "github.com/drone/drone/crypto/secretbox"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// var noContext = context.Background()
|
|
||||||
|
|
||||||
// type secretManager struct {
|
|
||||||
// repo *core.Repository
|
|
||||||
// build *core.Build
|
|
||||||
// config *yaml.Manifest
|
|
||||||
// remote core.SecretService
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (s *secretManager) list(_ context.Context) ([]*core.Secret, error) {
|
|
||||||
// var secrets []*core.Secret
|
|
||||||
// for _, resource := range s.config.Resources {
|
|
||||||
// res, ok := resource.(*yaml.Secret)
|
|
||||||
// if !ok {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// for name, value := range res.Data {
|
|
||||||
// // skip secrets the are intended for use with authenticating
|
|
||||||
// // to the docker registry and pulling private images.
|
|
||||||
// if isDockerConfig(name) {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if res.Type == "encrypted" {
|
|
||||||
// value = strings.Replace(value, " ", "", -1)
|
|
||||||
// value = strings.Replace(value, "\n", "", -1)
|
|
||||||
|
|
||||||
// plaintext, err := decrypt(core.EncryptAESGCM, value, s.repo.Secret)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// secret := new(core.Secret)
|
|
||||||
// secret.Name = name
|
|
||||||
// err = json.Unmarshal([]byte(plaintext), secret)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// if secret.Pull == false && s.build.Event == core.EventPullRequest {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// secrets = append(secrets, secret)
|
|
||||||
// } else {
|
|
||||||
// // the user has the option of aliasing the
|
|
||||||
// // secret name. If the user specifies an external
|
|
||||||
// // name it must be used for the external query.
|
|
||||||
// req := &core.SecretRequest{
|
|
||||||
// Name: value,
|
|
||||||
// Repo: s.repo,
|
|
||||||
// Build: s.build,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // if s.repo.Endpoints.Secret.Endpoint != "" {
|
|
||||||
// // // fetch the secret from the user-defined endpoint.
|
|
||||||
// // secret, err := s.remote.FindEndpoint(noContext, req, s.repo.Endpoints.Secret)
|
|
||||||
// // if err != nil {
|
|
||||||
// // return nil, err
|
|
||||||
// // }
|
|
||||||
// // if secret == nil {
|
|
||||||
// // continue
|
|
||||||
// // }
|
|
||||||
// // secrets = append(secrets, &core.Secret{
|
|
||||||
// // Name: name, // use the aliased name.
|
|
||||||
// // Data: secret.Data,
|
|
||||||
// // })
|
|
||||||
// // } else {
|
|
||||||
// // fetch the secret from the global endpoint.
|
|
||||||
// secret, err := s.remote.Find(noContext, req)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// if secret == nil {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// secrets = append(secrets, &core.Secret{
|
|
||||||
// Name: name, // use the aliased name.
|
|
||||||
// Data: secret.Data,
|
|
||||||
// })
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return secrets, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // helper function extracts the ciphertext and algorithm type
|
|
||||||
// // // from the yaml secret structure.
|
|
||||||
// // func extractCiphertext(secret yaml.Secret) (algorithm, ciphertext string, ok bool) {
|
|
||||||
// // return core.EncryptAESGCM, secret.Data, true
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // helper funciton decrypts the ciphertext using the provided
|
|
||||||
// // decryption algorithm and decryption key.
|
|
||||||
// func decrypt(algorithm, ciphertext, key string) (string, error) {
|
|
||||||
// switch algorithm {
|
|
||||||
// case core.EncryptAESGCM:
|
|
||||||
// return aesgcm.DecryptString(ciphertext, key)
|
|
||||||
// default:
|
|
||||||
// return secretbox.Decrypt(ciphertext, key)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // helper function returns true if the build event matches the
|
|
||||||
// // docker_auth_config variable name.
|
|
||||||
// func isDockerConfig(name string) bool {
|
|
||||||
// return strings.EqualFold(name, "DOCKER_AUTH_CONFIG")
|
|
||||||
// }
|
|
||||||
|
@ -1,360 +0,0 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
|
||||||
// that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package runner
|
|
||||||
|
|
||||||
// import (
|
|
||||||
// "context"
|
|
||||||
// "encoding/json"
|
|
||||||
// "io"
|
|
||||||
// "testing"
|
|
||||||
|
|
||||||
// "github.com/drone/drone-yaml/yaml"
|
|
||||||
// "github.com/drone/drone/core"
|
|
||||||
// "github.com/drone/drone/mock"
|
|
||||||
// "github.com/golang/mock/gomock"
|
|
||||||
// "github.com/google/go-cmp/cmp"
|
|
||||||
// )
|
|
||||||
|
|
||||||
// func Test_SecretManager_List_SkipDockerAuthConfig(t *testing.T) {
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Secret: "m5bahAG7YVp114R4YgMv5uW7bTEzx7yn",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "encrypted",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "DOCKER_AUTH_CONFIG": "LiDvQo6Zw5ArpwCByD4Pb9DAibl5bMaUInzXFT93sEoejT_jNZQCtXpIbuGJh7Iw3ixyd8vMDC0vXiQWw5VhKvLWLKg=",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if len(got) != 0 {
|
|
||||||
// t.Errorf("Expect DOCKER_AUTH_CONFIG excluded from secret list")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_SecretManager_ListInline(t *testing.T) {
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Secret: "dvBIW3c7P5WW0iwMaPNKRCKIN19NgqMH",
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// Fork: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "encrypted",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "5OXQwLXkLY0eWcqx0oM7SzY6nKrMBBUlRIC5aod0kmRH0-85AaH-4itxTrS21VaG88NESE5HB5Klq9QtTkAXsaW9KQ==",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// want := []*core.Secret{
|
|
||||||
// {
|
|
||||||
// Name: "docker_password",
|
|
||||||
// Data: "correct-horse-battery-staple",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// if diff := cmp.Diff(got, want); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_SecretManager_ListInline_SkipPull(t *testing.T) {
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Secret: "dvBIW3c7P5WW0iwMaPNKRCKIN19NgqMH",
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPullRequest,
|
|
||||||
// Fork: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "encrypted",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "5OXQwLXkLY0eWcqx0oM7SzY6nKrMBBUlRIC5aod0kmRH0-85AaH-4itxTrS21VaG88NESE5HB5Klq9QtTkAXsaW9KQ==",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// secrets, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if len(secrets) != 0 {
|
|
||||||
// t.Errorf("Expect secret not exposed to a pull request")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_SecretManager_ListInline_DecryptErr(t *testing.T) {
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Secret: "invalid",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "encrypted",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "LiDvQo6Zw5ArpwCByD4Pb9DAibl5bMaUInzXFT93sEoejT_jNZQCtXpIbuGJh7Iw3ixyd8vMDC0vXiQWw5VhKvLWLKg=",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// _, err := manager.list(noContext)
|
|
||||||
// if err == nil {
|
|
||||||
// t.Errorf("Expect decryption error")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_SecretManager_ListInline_DecodeErr(t *testing.T) {
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Secret: "m5bahAG7YVp114R4YgMv5uW7bTEzx7yn",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "encrypted",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "nNOfLyHNFMecBwWq4DxGIkIRqfCX3DElxc7sejue",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// _, err := manager.list(noContext)
|
|
||||||
// if _, ok := err.(*json.UnmarshalTypeError); !ok {
|
|
||||||
// t.Errorf("Expect decoding error")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_SecretManager_ListExternal(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// mockRepo := &core.Repository{
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockBuild := &core.Build{
|
|
||||||
// Event: core.EventPullRequest,
|
|
||||||
// Fork: "octocat/hello-world",
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockSecret := &core.Secret{
|
|
||||||
// Name: "docker_password",
|
|
||||||
// Data: "correct-horse-battery-staple",
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockSecretReq := &core.SecretRequest{
|
|
||||||
// Name: mockSecret.Name,
|
|
||||||
// Repo: mockRepo,
|
|
||||||
// Build: mockBuild,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mockResp := func(ctx context.Context, req *core.SecretRequest) (*core.Secret, error) {
|
|
||||||
// if diff := cmp.Diff(req, mockSecretReq); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// return mockSecret, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// service := mock.NewMockSecretService(controller)
|
|
||||||
// service.EXPECT().Find(gomock.Any(), gomock.Any()).DoAndReturn(mockResp)
|
|
||||||
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: mockRepo,
|
|
||||||
// build: mockBuild,
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "external",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "docker_password",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// remote: service,
|
|
||||||
// }
|
|
||||||
// got, err := manager.list(noContext)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Error(err)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// want := []*core.Secret{
|
|
||||||
// {
|
|
||||||
// Name: "docker_password",
|
|
||||||
// Data: "correct-horse-battery-staple",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// if diff := cmp.Diff(got, want); diff != "" {
|
|
||||||
// t.Errorf(diff)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_SecretManager_ListExternal_Err(t *testing.T) {
|
|
||||||
// controller := gomock.NewController(t)
|
|
||||||
// defer controller.Finish()
|
|
||||||
|
|
||||||
// service := mock.NewMockSecretService(controller)
|
|
||||||
// service.EXPECT().Find(gomock.Any(), gomock.Any()).Return(nil, io.EOF)
|
|
||||||
|
|
||||||
// manager := secretManager{
|
|
||||||
// repo: &core.Repository{
|
|
||||||
// Slug: "octocat/hello-world",
|
|
||||||
// },
|
|
||||||
// build: &core.Build{
|
|
||||||
// Event: core.EventPush,
|
|
||||||
// },
|
|
||||||
// config: &yaml.Manifest{
|
|
||||||
// Resources: []yaml.Resource{
|
|
||||||
// &yaml.Secret{
|
|
||||||
// Kind: "secret",
|
|
||||||
// Type: "external",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// "docker_password": "docker_password",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// remote: service,
|
|
||||||
// }
|
|
||||||
// _, err := manager.list(noContext)
|
|
||||||
// if err == nil {
|
|
||||||
// t.Errorf("Expect error fetching external secret")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // func Test_extractCiphertext(t *testing.T) {
|
|
||||||
// // tests := []struct {
|
|
||||||
// // secret config.Secret
|
|
||||||
// // algorithm string
|
|
||||||
// // ciphertext string
|
|
||||||
// // ok bool
|
|
||||||
// // }{
|
|
||||||
// // {
|
|
||||||
// // secret: config.Secret{Secretbox: "LiDvQo6Zw5ArpwCByD4Pb9DAibl5bMaUInzXFT93sEoejT_jNZQCtXpIbuGJh7Iw3ixyd8vMDC0vXiQWw5VhKvLWLKg="},
|
|
||||||
// // algorithm: core.EncryptSecretBox,
|
|
||||||
// // ciphertext: "LiDvQo6Zw5ArpwCByD4Pb9DAibl5bMaUInzXFT93sEoejT_jNZQCtXpIbuGJh7Iw3ixyd8vMDC0vXiQWw5VhKvLWLKg=",
|
|
||||||
// // ok: true,
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // secret: config.Secret{Aesgcm: "JjnUFKmN-H0GJmXO8oByrgZoCb0imNTcGgV496TNB7Y3MESCerxYvxjWWP1RQdPibfT1P97F1WA="},
|
|
||||||
// // algorithm: core.EncryptAESGCM,
|
|
||||||
// // ciphertext: "JjnUFKmN-H0GJmXO8oByrgZoCb0imNTcGgV496TNB7Y3MESCerxYvxjWWP1RQdPibfT1P97F1WA=",
|
|
||||||
// // ok: true,
|
|
||||||
// // },
|
|
||||||
// // {
|
|
||||||
// // secret: config.Secret{},
|
|
||||||
// // ok: false,
|
|
||||||
// // },
|
|
||||||
// // }
|
|
||||||
// // for i, test := range tests {
|
|
||||||
// // algorithm, ciphertext, ok := extractCiphertext(test.secret)
|
|
||||||
// // if got, want := algorithm, test.algorithm; got != want {
|
|
||||||
// // t.Errorf("Want algorithm %s at index %v", want, i)
|
|
||||||
// // }
|
|
||||||
// // if got, want := ciphertext, test.ciphertext; got != want {
|
|
||||||
// // t.Errorf("Want ciphertext %s at index %v", want, i)
|
|
||||||
// // }
|
|
||||||
// // if got, want := ok, test.ok; got != want {
|
|
||||||
// // t.Errorf("Want ok %v at index %v", want, i)
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// func Test_decrypt(t *testing.T) {
|
|
||||||
// tests := []struct {
|
|
||||||
// Key string
|
|
||||||
// Algorithm string
|
|
||||||
// Ciphertext string
|
|
||||||
// Plaintext string
|
|
||||||
// }{
|
|
||||||
// {
|
|
||||||
// Algorithm: core.EncryptSecretBox,
|
|
||||||
// Plaintext: "correct-horse-battery-staple",
|
|
||||||
// Ciphertext: "LiDvQo6Zw5ArpwCByD4Pb9DAibl5bMaUInzXFT93sEoejT_jNZQCtXpIbuGJh7Iw3ixyd8vMDC0vXiQWw5VhKvLWLKg=",
|
|
||||||
// Key: "m5bahAG7YVp114R4YgMv5uW7bTEzx7yn",
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// Algorithm: core.EncryptAESGCM,
|
|
||||||
// Plaintext: "correct-horse-battery-staple",
|
|
||||||
// Ciphertext: "JjnUFKmN-H0GJmXO8oByrgZoCb0imNTcGgV496TNB7Y3MESCerxYvxjWWP1RQdPibfT1P97F1WA=",
|
|
||||||
// Key: "m5bahAG7YVp114R4YgMv5uW7bTEzx7yn",
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// for i, test := range tests {
|
|
||||||
// plaintext, _ := decrypt(test.Algorithm, test.Ciphertext, test.Key)
|
|
||||||
// if got, want := plaintext, test.Plaintext; got != want {
|
|
||||||
// t.Errorf("Want %v at index %v", want, i)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func Test_isDockerConfig(t *testing.T) {
|
|
||||||
// tests := []struct {
|
|
||||||
// Name string
|
|
||||||
// Match bool
|
|
||||||
// }{
|
|
||||||
// {
|
|
||||||
// Name: "docker_auth_config",
|
|
||||||
// Match: true,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// Name: "DOCKER_auth_CONFIG",
|
|
||||||
// Match: true,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// Name: "docker_config",
|
|
||||||
// Match: false,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// for i, test := range tests {
|
|
||||||
// if got, want := isDockerConfig(test.Name), test.Match; got != want {
|
|
||||||
// t.Errorf("Want %v at index %v", want, i)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -16,9 +16,13 @@
|
|||||||
|
|
||||||
package admission
|
package admission
|
||||||
|
|
||||||
import "github.com/drone/drone/core"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
)
|
||||||
|
|
||||||
// Nobot is a no-op admission controller
|
// Nobot is a no-op admission controller
|
||||||
func Nobot(string, string, bool) core.AdmissionService {
|
func Nobot(core.UserService, time.Duration) core.AdmissionService {
|
||||||
return new(noop)
|
return new(noop)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
// Global returns a no-op configuration service.
|
// Global returns a no-op configuration service.
|
||||||
func Global(string, string, bool) core.ConfigService {
|
func Global(string, string, bool) core.ConfigService {
|
||||||
return
|
return new(noop)
|
||||||
}
|
}
|
||||||
|
|
||||||
type noop struct{}
|
type noop struct{}
|
||||||
|
77
plugin/config/jsonnet.go
Normal file
77
plugin/config/jsonnet.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/drone/drone/core"
|
||||||
|
|
||||||
|
"github.com/google/go-jsonnet"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Jsonnet returns a configuration service that fetches the
|
||||||
|
// jsonnet file directly from the source code management (scm)
|
||||||
|
// system and converts to a yaml file.
|
||||||
|
func Jsonnet(service core.FileService, enabled bool) core.ConfigService {
|
||||||
|
return &jsonnetPlugin{
|
||||||
|
enabled: enabled,
|
||||||
|
repos: &repo{files: service},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type jsonnetPlugin struct {
|
||||||
|
enabled bool
|
||||||
|
repos *repo
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *jsonnetPlugin) Find(ctx context.Context, req *core.ConfigArgs) (*core.Config, error) {
|
||||||
|
if p.enabled == false {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the file extension is not jsonnet we can
|
||||||
|
// skip this plugin by returning zero values.
|
||||||
|
if strings.HasSuffix(req.Repo.Config, ".jsonnet") == false {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the file contents.
|
||||||
|
config, err := p.repos.Find(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(bradrydzewski) temporarily disable file imports
|
||||||
|
// TODO(bradrydzewski) handle object vs array output
|
||||||
|
|
||||||
|
// create the jsonnet vm
|
||||||
|
vm := jsonnet.MakeVM()
|
||||||
|
vm.MaxStack = 500
|
||||||
|
vm.StringOutput = false
|
||||||
|
vm.ErrorFormatter.SetMaxStackTraceSize(20)
|
||||||
|
|
||||||
|
// convert the jsonnet file to yaml
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
docs, err := vm.EvaluateSnippetStream(req.Repo.Config, config.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// the jsonnet vm returns a stream of yaml documents
|
||||||
|
// that need to be combined into a single yaml file.
|
||||||
|
for _, doc := range docs {
|
||||||
|
buf.WriteString("---")
|
||||||
|
buf.WriteString("\n")
|
||||||
|
buf.WriteString(doc)
|
||||||
|
}
|
||||||
|
|
||||||
|
config.Data = buf.String()
|
||||||
|
return config, nil
|
||||||
|
}
|
24
plugin/config/jsonnet_oss.go
Normal file
24
plugin/config/jsonnet_oss.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package config
|
||||||
|
|
||||||
|
import "github.com/drone/drone/core"
|
||||||
|
|
||||||
|
// Jsonnet returns a no-op configuration service.
|
||||||
|
func Jsonnet(service core.FileService, enabled bool) core.ConfigService {
|
||||||
|
return new(noop)
|
||||||
|
}
|
7
plugin/config/jsonnet_test.go
Normal file
7
plugin/config/jsonnet_test.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
|
package config
|
@ -18,7 +18,7 @@ package registry
|
|||||||
|
|
||||||
import "github.com/drone/drone/core"
|
import "github.com/drone/drone/core"
|
||||||
|
|
||||||
// Endpoint returns a no-op registry credential provider.
|
// EndpointSource returns a no-op registry credential provider.
|
||||||
func Endpoint(string, string, bool) core.RegistryService {
|
func EndpointSource(string, string, bool) core.RegistryService {
|
||||||
return new(noop)
|
return new(noop)
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,6 @@ func New([]string, string) core.WebhookSender {
|
|||||||
|
|
||||||
type noop struct{}
|
type noop struct{}
|
||||||
|
|
||||||
func (noop) Send(context.Context, *WebhookData) error {
|
func (noop) Send(context.Context, *core.WebhookData) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -110,14 +110,14 @@ func (s *kubeScheduler) Schedule(ctx context.Context, stage *core.Stage) error {
|
|||||||
Namespace: s.namespace(),
|
Namespace: s.namespace(),
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"io.drone": "true",
|
"io.drone": "true",
|
||||||
"io.core.stage.created": time.Unix(stage.Created, 0).String(),
|
"io.drone.stage.created": time.Unix(stage.Created, 0).String(),
|
||||||
"io.core.stage.scheduled": time.Now().String(),
|
"io.drone.stage.scheduled": time.Now().String(),
|
||||||
"io.core.stage.id": fmt.Sprint(stage.ID),
|
"io.drone.stage.id": fmt.Sprint(stage.ID),
|
||||||
"io.core.stage.number": fmt.Sprint(stage.Number),
|
"io.drone.stage.number": fmt.Sprint(stage.Number),
|
||||||
"io.core.stage.os": fmt.Sprint(stage.OS),
|
"io.drone.stage.os": fmt.Sprint(stage.OS),
|
||||||
"io.core.stage.arch": fmt.Sprint(stage.Arch),
|
"io.drone.stage.arch": fmt.Sprint(stage.Arch),
|
||||||
"io.core.build.id": fmt.Sprint(stage.BuildID),
|
"io.drone.build.id": fmt.Sprint(stage.BuildID),
|
||||||
"io.core.repo.id": fmt.Sprint(stage.RepoID),
|
"io.drone.repo.id": fmt.Sprint(stage.RepoID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: batchv1.JobSpec{
|
Spec: batchv1.JobSpec{
|
||||||
|
@ -26,14 +26,14 @@ type noop struct{}
|
|||||||
|
|
||||||
// FromConfig returns a no-op Kubernetes scheduler.
|
// FromConfig returns a no-op Kubernetes scheduler.
|
||||||
func FromConfig(conf Config) (core.Scheduler, error) {
|
func FromConfig(conf Config) (core.Scheduler, error) {
|
||||||
return new(noop)
|
return new(noop), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (noop) Schedule(context.Context, *core.Stage) error {
|
func (noop) Schedule(context.Context, *core.Stage) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (noop) Request(context.Context, Filter) (*core.Stage, error) {
|
func (noop) Request(context.Context, core.Filter) (*core.Stage, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,14 +112,14 @@ func (s *nomadScheduler) Schedule(ctx context.Context, stage *core.Stage) error
|
|||||||
},
|
},
|
||||||
Meta: map[string]string{
|
Meta: map[string]string{
|
||||||
"io.drone": "true",
|
"io.drone": "true",
|
||||||
"io.core.stage.created": time.Unix(stage.Created, 0).String(),
|
"io.drone.stage.created": time.Unix(stage.Created, 0).String(),
|
||||||
"io.core.stage.scheduled": time.Now().String(),
|
"io.drone.stage.scheduled": time.Now().String(),
|
||||||
"io.core.stage.id": fmt.Sprint(stage.ID),
|
"io.drone.stage.id": fmt.Sprint(stage.ID),
|
||||||
"io.core.stage.number": fmt.Sprint(stage.Number),
|
"io.drone.stage.number": fmt.Sprint(stage.Number),
|
||||||
"io.core.stage.os": fmt.Sprint(stage.OS),
|
"io.drone.stage.os": fmt.Sprint(stage.OS),
|
||||||
"io.core.stage.arch": fmt.Sprint(stage.Arch),
|
"io.drone.stage.arch": fmt.Sprint(stage.Arch),
|
||||||
"io.core.build.id": fmt.Sprint(stage.BuildID),
|
"io.drone.build.id": fmt.Sprint(stage.BuildID),
|
||||||
"io.core.repo.id": fmt.Sprint(stage.RepoID),
|
"io.drone.repo.id": fmt.Sprint(stage.RepoID),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,14 +26,14 @@ type noop struct{}
|
|||||||
|
|
||||||
// FromConfig returns a no-op Nomad scheduler.
|
// FromConfig returns a no-op Nomad scheduler.
|
||||||
func FromConfig(conf Config) (core.Scheduler, error) {
|
func FromConfig(conf Config) (core.Scheduler, error) {
|
||||||
return new(noop)
|
return new(noop), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (noop) Schedule(context.Context, *core.Stage) error {
|
func (noop) Schedule(context.Context, *core.Stage) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (noop) Request(context.Context, Filter) (*core.Stage, error) {
|
func (noop) Request(context.Context, core.Filter) (*core.Stage, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ func Load(path string) (*core.License, error) {
|
|||||||
|
|
||||||
license := new(core.License)
|
license := new(core.License)
|
||||||
license.Expires = decoded.Exp
|
license.Expires = decoded.Exp
|
||||||
|
license.Licensor = decoded.Cus
|
||||||
|
license.Subscription = decoded.Sub
|
||||||
err = json.Unmarshal(decoded.Dat, license)
|
err = json.Unmarshal(decoded.Dat, license)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
33
service/syncer/filter_oss.go
Normal file
33
service/syncer/filter_oss.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package syncer
|
||||||
|
|
||||||
|
import "github.com/drone/drone/core"
|
||||||
|
|
||||||
|
// FilterFunc can be used to filter which repositories are
|
||||||
|
// synchronized with the local datastore.
|
||||||
|
type FilterFunc func(*core.Repository) bool
|
||||||
|
|
||||||
|
// NamespaceFilter is a no-op filter.
|
||||||
|
func NamespaceFilter(namespaces []string) FilterFunc {
|
||||||
|
return noopFilter
|
||||||
|
}
|
||||||
|
|
||||||
|
// noopFilter is a filter function that always returns true.
|
||||||
|
func noopFilter(*core.Repository) bool {
|
||||||
|
return true
|
||||||
|
}
|
@ -21,11 +21,10 @@ import (
|
|||||||
|
|
||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
"github.com/drone/drone/store/shared/db"
|
"github.com/drone/drone/store/shared/db"
|
||||||
"github.com/drone/drone/store/shared/encrypt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// New returns a new Secret database store.
|
// New returns a new Secret database store.
|
||||||
func New(db *db.DB, enc encrypt.Encrypter) core.CronStore {
|
func New(db *db.DB) core.CronStore {
|
||||||
return new(noop)
|
return new(noop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,6 @@ import (
|
|||||||
"github.com/drone/drone/core"
|
"github.com/drone/drone/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(bradrydzewski) look into the possibility of using
|
|
||||||
// s3gof3r as an alternate. github.com/rlmcpherson/s3gof3r
|
|
||||||
|
|
||||||
// NewS3Env returns a new S3 log store.
|
// NewS3Env returns a new S3 log store.
|
||||||
func NewS3Env(bucket, prefix, endpoint string, pathStyle bool) core.LogStore {
|
func NewS3Env(bucket, prefix, endpoint string, pathStyle bool) core.LogStore {
|
||||||
disableSSL := false
|
disableSSL := false
|
||||||
|
24
store/logs/s3_oss.go
Normal file
24
store/logs/s3_oss.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2019 Drone IO, Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build oss
|
||||||
|
|
||||||
|
package logs
|
||||||
|
|
||||||
|
import "github.com/drone/drone/core"
|
||||||
|
|
||||||
|
// New returns a zero value LogStore.
|
||||||
|
func NewS3Env(bucket, prefix, endpoint string, pathStyle bool) core.LogStore {
|
||||||
|
return nil
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package mysql
|
package mysql
|
||||||
|
|
||||||
//go:generate togo ddl -package mysql -dialect mysql
|
//go:generate togo ddl -package mysql -dialect mysql
|
||||||
|
@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS builds (
|
|||||||
,build_source VARCHAR(500)
|
,build_source VARCHAR(500)
|
||||||
,build_target VARCHAR(500)
|
,build_target VARCHAR(500)
|
||||||
,build_author VARCHAR(500)
|
,build_author VARCHAR(500)
|
||||||
,build_author_name VARCHAR(500)
|
,build_author_name VARCHAR(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
|
||||||
,build_author_email VARCHAR(500)
|
,build_author_email VARCHAR(500)
|
||||||
,build_author_avatar VARCHAR(1000)
|
,build_author_avatar VARCHAR(1000)
|
||||||
,build_sender VARCHAR(500)
|
,build_sender VARCHAR(500)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !oss
|
||||||
|
|
||||||
package postgres
|
package postgres
|
||||||
|
|
||||||
//go:generate togo ddl -package postgres -dialect postgres
|
//go:generate togo ddl -package postgres -dialect postgres
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
// +build !oss
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package trigger
|
package trigger
|
||||||
|
|
||||||
|
@ -30,12 +30,14 @@ func New(
|
|||||||
core.RepositoryStore,
|
core.RepositoryStore,
|
||||||
core.UserStore,
|
core.UserStore,
|
||||||
core.Triggerer,
|
core.Triggerer,
|
||||||
) *noop {
|
) *Scheduler {
|
||||||
return &noop{}
|
return &Scheduler{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type noop struct{}
|
// Schedule is a no-op cron scheduler.
|
||||||
|
type Scheduler struct{}
|
||||||
|
|
||||||
func (noop) Start(context.Context, time.Duration) error {
|
// Start is a no-op.
|
||||||
|
func (Scheduler) Start(context.Context, time.Duration) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
// Copyright 2019 Drone IO, Inc.
|
||||||
// Use of this source code is governed by the Drone Non-Commercial License
|
//
|
||||||
// that can be found in the LICENSE file.
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
// +build !oss
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package trigger
|
package trigger
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user