diff --git a/cmd/drone-server/config/config.go b/cmd/drone-server/config/config.go index 64a4ba69d..76d1ffea2 100644 --- a/cmd/drone-server/config/config.go +++ b/cmd/drone-server/config/config.go @@ -383,6 +383,48 @@ func (c *Config) String() string { 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) { if c.Server.Key != "" || c.Server.Cert != "" || c.Server.Acme { c.Server.Port = ":443" diff --git a/cmd/drone-server/inject_service.go b/cmd/drone-server/inject_service.go index df230c444..68e2cdf51 100644 --- a/cmd/drone-server/inject_service.go +++ b/cmd/drone-server/inject_service.go @@ -144,6 +144,7 @@ func provideDatadog( repos core.RepositoryStore, builds core.BuildStore, system *core.System, + license *core.License, config config.Config, ) *sink.Datadog { return sink.New( @@ -152,8 +153,21 @@ func provideDatadog( builds, *system, sink.Config{ - Endpoint: config.Datadog.Endpoint, - Token: config.Datadog.Token, + Endpoint: config.Datadog.Endpoint, + 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, }, ) } diff --git a/cmd/drone-server/wire_gen.go b/cmd/drone-server/wire_gen.go index a7c0d0192..40507b2d6 100644 --- a/cmd/drone-server/wire_gen.go +++ b/cmd/drone-server/wire_gen.go @@ -59,7 +59,8 @@ func InitializeApplication(config2 config.Config) (application, error) { triggerer := trigger.New(configService, commitService, statusService, buildStore, scheduler, repositoryStore, userStore, webhookSender) cronScheduler := cron2.New(commitService, cronStore, repositoryStore, userStore, triggerer) 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() logStore := provideLogStore(db, config2) logStream := livelog.New() @@ -75,7 +76,6 @@ func InitializeApplication(config2 config.Config) (application, error) { registryService := provideRegistryPlugin(config2) runner := provideRunner(buildManager, secretService, registryService, config2) hookService := provideHookService(client, renewer, config2) - coreLicense := provideLicense(client, config2) licenseService := license.NewService(userStore, repositoryStore, buildStore, coreLicense) permStore := perm.New(db) repositoryService := repo.New(client, renewer) diff --git a/core/license.go b/core/license.go index 9e5d64c1a..c4b76d8a7 100644 --- a/core/license.go +++ b/core/license.go @@ -45,12 +45,14 @@ var ErrBuildLimit = errors.New("Build limit exceeded") type ( // License defines software license parameters. License struct { - Expires time.Time `json:"expires_at,omitempty"` - Kind string `json:"kind,omitempty"` - Repos int64 `json:"repos,omitempty"` - Users int64 `json:"users,omitempty"` - Builds int64 `json:"builds,omitempty"` - Nodes int64 `json:"nodes,omitempty"` + Licensor string `json:"-"` + Subscription string `json:"-"` + Expires time.Time `json:"expires_at,omitempty"` + Kind string `json:"kind,omitempty"` + Repos int64 `json:"repos,omitempty"` + Users int64 `json:"users,omitempty"` + Builds int64 `json:"builds,omitempty"` + Nodes int64 `json:"nodes,omitempty"` } // LicenseService provides access to the license diff --git a/go.mod b/go.mod index c731ecb25..86cf0a24e 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/drone/drone-go v0.0.0-20190217024616-3e8b71333e59 github.com/drone/drone-runtime v0.0.0-20190210191445-ad403a0ca24e 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/go-license v1.0.2 github.com/drone/go-login v1.0.3 diff --git a/go.sum b/go.sum index 6da972017..381de027b 100644 --- a/go.sum +++ b/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 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.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/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0= github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrkok= @@ -110,6 +112,8 @@ 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-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-rootcerts v1.0.0 h1:ueI78wUjYExhCvMLow4icJnayNNFRgy0d9EGs/a1T44= +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/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/nomad v0.0.0-20190125003214-134391155854 h1:L7WhLZt2ory/kQWxqkMwOiBpIoa4BWoadN7yx8LHEtk= diff --git a/handler/api/builds/builds.go b/handler/api/builds/builds.go index 422d747b9..179816eba 100644 --- a/handler/api/builds/builds.go +++ b/handler/api/builds/builds.go @@ -2,14 +2,16 @@ // 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 import ( "net/http" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/render" "github.com/drone/drone/logger" - "github.com/drone/drone/core" ) // HandleIncomplete returns an http.HandlerFunc that writes a diff --git a/handler/api/builds/builds_oss.go b/handler/api/builds/builds_oss.go new file mode 100644 index 000000000..7da015f1f --- /dev/null +++ b/handler/api/builds/builds_oss.go @@ -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 +} diff --git a/handler/api/builds/builds_test.go b/handler/api/builds/builds_test.go index 57c477519..cbe91d183 100644 --- a/handler/api/builds/builds_test.go +++ b/handler/api/builds/builds_test.go @@ -2,6 +2,8 @@ // 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 import ( @@ -10,9 +12,9 @@ import ( "net/http/httptest" "testing" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/errors" "github.com/drone/drone/mock" - "github.com/drone/drone/core" "github.com/golang/mock/gomock" "github.com/google/go-cmp/cmp" diff --git a/handler/api/events/build.go b/handler/api/events/build.go index aa287e6c3..caa8abc52 100644 --- a/handler/api/events/build.go +++ b/handler/api/events/build.go @@ -1,6 +1,16 @@ -// 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. +// 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. package events @@ -10,9 +20,9 @@ import ( "net/http" "time" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/render" "github.com/drone/drone/logger" - "github.com/drone/drone/core" "github.com/sirupsen/logrus" "github.com/go-chi/chi" diff --git a/handler/api/events/global.go b/handler/api/events/global.go index 5feb0c470..1c271be63 100644 --- a/handler/api/events/global.go +++ b/handler/api/events/global.go @@ -1,6 +1,16 @@ -// 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. +// 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. package events @@ -10,9 +20,9 @@ import ( "net/http" "time" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/request" "github.com/drone/drone/logger" - "github.com/drone/drone/core" ) // HandleGlobal creates an http.HandlerFunc that streams builds events diff --git a/handler/api/events/logs.go b/handler/api/events/logs.go index 981784cd1..be86597ff 100644 --- a/handler/api/events/logs.go +++ b/handler/api/events/logs.go @@ -1,6 +1,16 @@ -// 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. +// 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. package events @@ -12,8 +22,8 @@ import ( "strconv" "time" - "github.com/drone/drone/handler/api/render" "github.com/drone/drone/core" + "github.com/drone/drone/handler/api/render" "github.com/go-chi/chi" ) diff --git a/handler/api/queue/items.go b/handler/api/queue/items.go index a0178ac21..c4bd42892 100644 --- a/handler/api/queue/items.go +++ b/handler/api/queue/items.go @@ -2,14 +2,16 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package queue import ( "net/http" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/render" "github.com/drone/drone/logger" - "github.com/drone/drone/core" ) // HandleItems returns an http.HandlerFunc that writes a diff --git a/handler/api/queue/items_test.go b/handler/api/queue/items_test.go index 2e8e2995a..1ef484b92 100644 --- a/handler/api/queue/items_test.go +++ b/handler/api/queue/items_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package queue import ( diff --git a/handler/api/queue/none.go b/handler/api/queue/none.go new file mode 100644 index 000000000..3aa95f7bd --- /dev/null +++ b/handler/api/queue/none.go @@ -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 +} diff --git a/handler/api/queue/pause.go b/handler/api/queue/pause.go index 21b70b53f..3a1b510d7 100644 --- a/handler/api/queue/pause.go +++ b/handler/api/queue/pause.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package queue // import ( diff --git a/handler/api/queue/pause_test.go b/handler/api/queue/pause_test.go index a68286c24..693739056 100644 --- a/handler/api/queue/pause_test.go +++ b/handler/api/queue/pause_test.go @@ -2,4 +2,6 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package queue diff --git a/handler/api/queue/resume.go b/handler/api/queue/resume.go index 834615f5a..2fd517f78 100644 --- a/handler/api/queue/resume.go +++ b/handler/api/queue/resume.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package queue // import ( diff --git a/handler/api/queue/resume_test.go b/handler/api/queue/resume_test.go index a68286c24..693739056 100644 --- a/handler/api/queue/resume_test.go +++ b/handler/api/queue/resume_test.go @@ -2,4 +2,6 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package queue diff --git a/handler/api/repos/builds/promote.go b/handler/api/repos/builds/promote.go index bee81ebd4..0696f58f5 100644 --- a/handler/api/repos/builds/promote.go +++ b/handler/api/repos/builds/promote.go @@ -2,15 +2,17 @@ // 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 import ( "net/http" "strconv" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/render" "github.com/drone/drone/handler/api/request" - "github.com/drone/drone/core" "github.com/go-chi/chi" ) diff --git a/handler/api/repos/builds/promote_oss.go b/handler/api/repos/builds/promote_oss.go new file mode 100644 index 000000000..0664cd601 --- /dev/null +++ b/handler/api/repos/builds/promote_oss.go @@ -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 +} diff --git a/handler/api/repos/builds/promote_test.go b/handler/api/repos/builds/promote_test.go index 427e7a37b..5f9db4e9b 100644 --- a/handler/api/repos/builds/promote_test.go +++ b/handler/api/repos/builds/promote_test.go @@ -2,6 +2,8 @@ // 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 import ( @@ -10,10 +12,10 @@ import ( "net/http/httptest" "testing" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/errors" "github.com/drone/drone/handler/api/request" "github.com/drone/drone/mock" - "github.com/drone/drone/core" "github.com/go-chi/chi" "github.com/golang/mock/gomock" diff --git a/handler/api/repos/builds/purge.go b/handler/api/repos/builds/purge.go index 0884f867f..070251a1b 100644 --- a/handler/api/repos/builds/purge.go +++ b/handler/api/repos/builds/purge.go @@ -2,14 +2,16 @@ // 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 import ( "net/http" "strconv" - "github.com/drone/drone/handler/api/render" "github.com/drone/drone/core" + "github.com/drone/drone/handler/api/render" "github.com/go-chi/chi" ) diff --git a/handler/api/repos/builds/purge_oss.go b/handler/api/repos/builds/purge_oss.go new file mode 100644 index 000000000..d9937051a --- /dev/null +++ b/handler/api/repos/builds/purge_oss.go @@ -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 +} diff --git a/handler/api/repos/builds/purge_test.go b/handler/api/repos/builds/purge_test.go index be09113d5..01b9bf218 100644 --- a/handler/api/repos/builds/purge_test.go +++ b/handler/api/repos/builds/purge_test.go @@ -2,6 +2,8 @@ // 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 import ( diff --git a/handler/api/repos/builds/rollback.go b/handler/api/repos/builds/rollback.go new file mode 100644 index 000000000..3047a80e9 --- /dev/null +++ b/handler/api/repos/builds/rollback.go @@ -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 diff --git a/handler/api/repos/builds/rollback_test.go b/handler/api/repos/builds/rollback_test.go new file mode 100644 index 000000000..3047a80e9 --- /dev/null +++ b/handler/api/repos/builds/rollback_test.go @@ -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 diff --git a/handler/api/repos/builds/stages/approve.go b/handler/api/repos/builds/stages/approve.go index 1e87ea55a..8f70f554b 100644 --- a/handler/api/repos/builds/stages/approve.go +++ b/handler/api/repos/builds/stages/approve.go @@ -1,6 +1,16 @@ -// 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. +// 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. package stages @@ -9,8 +19,8 @@ import ( "net/http" "strconv" - "github.com/drone/drone/handler/api/render" "github.com/drone/drone/core" + "github.com/drone/drone/handler/api/render" "github.com/go-chi/chi" ) diff --git a/handler/api/repos/builds/stages/decline.go b/handler/api/repos/builds/stages/decline.go index d72937428..7ff0c7b3c 100644 --- a/handler/api/repos/builds/stages/decline.go +++ b/handler/api/repos/builds/stages/decline.go @@ -1,6 +1,16 @@ -// 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. +// 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. package stages @@ -9,8 +19,8 @@ import ( "net/http" "strconv" - "github.com/drone/drone/handler/api/render" "github.com/drone/drone/core" + "github.com/drone/drone/handler/api/render" "github.com/go-chi/chi" ) diff --git a/handler/api/system/license.go b/handler/api/system/license.go index 668d45c56..01743c6f3 100644 --- a/handler/api/system/license.go +++ b/handler/api/system/license.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package system import ( diff --git a/handler/api/system/limits.go b/handler/api/system/limits.go index 672af9ca3..82f2daaec 100644 --- a/handler/api/system/limits.go +++ b/handler/api/system/limits.go @@ -2,4 +2,6 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package system diff --git a/handler/api/system/none.go b/handler/api/system/none.go new file mode 100644 index 000000000..ebb1e0948 --- /dev/null +++ b/handler/api/system/none.go @@ -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 +} diff --git a/handler/api/system/stats.go b/handler/api/system/stats.go index ec87b2dcd..8ff37c1b6 100644 --- a/handler/api/system/stats.go +++ b/handler/api/system/stats.go @@ -2,14 +2,16 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package system import ( "net/http" + "github.com/drone/drone/core" "github.com/drone/drone/handler/api/render" "github.com/drone/drone/logger" - "github.com/drone/drone/core" ) type ( diff --git a/handler/api/system/stats_test.go b/handler/api/system/stats_test.go index 456911e9f..03c3cb224 100644 --- a/handler/api/system/stats_test.go +++ b/handler/api/system/stats_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package system import ( diff --git a/handler/web/hook.go b/handler/web/hook.go index 70738e78f..581b39d47 100644 --- a/handler/web/hook.go +++ b/handler/web/hook.go @@ -1,6 +1,16 @@ -// 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. +// 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. package web @@ -14,8 +24,8 @@ import ( "github.com/sirupsen/logrus" - "github.com/drone/drone/logger" "github.com/drone/drone/core" + "github.com/drone/drone/logger" "github.com/drone/go-scm/scm" ) diff --git a/handler/web/landingpage/dist.go b/handler/web/landingpage/dist.go index fe05e0cfd..722a2a32e 100644 --- a/handler/web/landingpage/dist.go +++ b/handler/web/landingpage/dist.go @@ -1,6 +1,16 @@ -// 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. +// 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. package landingpage diff --git a/handler/web/login.go b/handler/web/login.go index 9e82a171d..59c15fad5 100644 --- a/handler/web/login.go +++ b/handler/web/login.go @@ -1,6 +1,16 @@ -// 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. +// 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. package web diff --git a/handler/web/pages.go b/handler/web/pages.go index aac6600d8..50f7829fd 100644 --- a/handler/web/pages.go +++ b/handler/web/pages.go @@ -1,6 +1,16 @@ -// 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. +// 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. package web diff --git a/handler/web/varz.go b/handler/web/varz.go index 95b16ec3d..6799bea04 100644 --- a/handler/web/varz.go +++ b/handler/web/varz.go @@ -1,6 +1,16 @@ -// 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. +// 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. package web diff --git a/livelog/livelog.go b/livelog/livelog.go index 58b9cd9e7..9ab27d0b1 100644 --- a/livelog/livelog.go +++ b/livelog/livelog.go @@ -1,8 +1,16 @@ -// 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 +// 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. package livelog diff --git a/livelog/stream.go b/livelog/stream.go index 2fc79a22e..eec557fdc 100644 --- a/livelog/stream.go +++ b/livelog/stream.go @@ -1,8 +1,16 @@ -// 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 +// 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. package livelog diff --git a/livelog/sub.go b/livelog/sub.go index c7bdb7006..d96460e70 100644 --- a/livelog/sub.go +++ b/livelog/sub.go @@ -1,8 +1,16 @@ -// 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 +// 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. package livelog diff --git a/metric/handler_oss.go b/metric/handler_oss.go new file mode 100644 index 000000000..a20a4e695 --- /dev/null +++ b/metric/handler_oss.go @@ -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) {} diff --git a/metric/metric_oss.go b/metric/metric_oss.go new file mode 100644 index 000000000..fbf94954c --- /dev/null +++ b/metric/metric_oss.go @@ -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) {} diff --git a/metric/sink/config.go b/metric/sink/config.go index 787c03a56..e54739f50 100644 --- a/metric/sink/config.go +++ b/metric/sink/config.go @@ -18,4 +18,18 @@ package sink type Config struct { Endpoint 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 } diff --git a/metric/sink/datadog.go b/metric/sink/datadog.go index 15c2b5437..7bebfcb8f 100644 --- a/metric/sink/datadog.go +++ b/metric/sink/datadog.go @@ -22,11 +22,11 @@ type payload struct { } type series struct { - Metric string `json:"metric"` - Points [][]int64 `json:"points"` - Host string `json:"host"` - Type string `json:"type"` - Tags map[string]string `json:"tags,omitempty"` + Metric string `json:"metric"` + Points [][]int64 `json:"points"` + Host string `json:"host"` + Type string `json:"type"` + Tags []string `json:"tags,omitempty"` } // 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 { return err } + tags := createTags(d.config) data := new(payload) data.Series = []series{ { @@ -89,18 +90,21 @@ func (d *Datadog) do(ctx context.Context, unix int64) error { Points: [][]int64{[]int64{unix, users}}, Type: "gauge", Host: d.system.Host, + Tags: tags, }, { Metric: "drone.repos", Points: [][]int64{[]int64{unix, repos}}, Type: "gauge", Host: d.system.Host, + Tags: tags, }, { Metric: "drone.builds", Points: [][]int64{[]int64{unix, builds}}, Type: "gauge", Host: d.system.Host, + Tags: tags, }, } diff --git a/metric/sink/datadog_oss.go b/metric/sink/datadog_oss.go index ccea7b0fc..d8fc44239 100644 --- a/metric/sink/datadog_oss.go +++ b/metric/sink/datadog_oss.go @@ -18,13 +18,21 @@ package sink import ( "context" + + "github.com/drone/drone/core" ) // Datadog defines a no-op sink to datadog. type Datadog struct{} // 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) } diff --git a/metric/sink/tags.go b/metric/sink/tags.go new file mode 100644 index 000000000..386e4d6fb --- /dev/null +++ b/metric/sink/tags.go @@ -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 +} diff --git a/operator/manager/manager.go b/operator/manager/manager.go index 3ed549fea..ee44d3c57 100644 --- a/operator/manager/manager.go +++ b/operator/manager/manager.go @@ -1,6 +1,16 @@ -// 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. +// 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. package manager diff --git a/operator/manager/rpc/client.go b/operator/manager/rpc/client.go index b841926a5..ef2569387 100644 --- a/operator/manager/rpc/client.go +++ b/operator/manager/rpc/client.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package rpc import ( @@ -18,8 +20,8 @@ import ( "github.com/drone/drone/operator/manager" - "github.com/drone/drone/store/shared/db" "github.com/drone/drone/core" + "github.com/drone/drone/store/shared/db" "github.com/hashicorp/go-retryablehttp" "github.com/oxtoacart/bpool" diff --git a/operator/manager/rpc/client_test.go b/operator/manager/rpc/client_test.go index 922e09989..9fcbd40f8 100644 --- a/operator/manager/rpc/client_test.go +++ b/operator/manager/rpc/client_test.go @@ -2,15 +2,17 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package rpc import ( "bytes" "testing" - "github.com/drone/drone/store/shared/db" "github.com/drone/drone/core" "github.com/drone/drone/operator/manager" + "github.com/drone/drone/store/shared/db" "github.com/google/go-cmp/cmp" "github.com/h2non/gock" diff --git a/operator/manager/rpc/error.go b/operator/manager/rpc/error.go index 1cb41e672..c742b5316 100644 --- a/operator/manager/rpc/error.go +++ b/operator/manager/rpc/error.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package rpc type serverError struct { diff --git a/operator/manager/rpc/server.go b/operator/manager/rpc/server.go index 67d4254e8..9693cbf4f 100644 --- a/operator/manager/rpc/server.go +++ b/operator/manager/rpc/server.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package rpc import ( diff --git a/operator/manager/rpc/server_oss.go b/operator/manager/rpc/server_oss.go new file mode 100644 index 000000000..c056b4c7c --- /dev/null +++ b/operator/manager/rpc/server_oss.go @@ -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) {} diff --git a/operator/manager/rpc/server_test.go b/operator/manager/rpc/server_test.go index 91dc1dab2..008899758 100644 --- a/operator/manager/rpc/server_test.go +++ b/operator/manager/rpc/server_test.go @@ -2,4 +2,6 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package rpc diff --git a/operator/manager/rpc/types.go b/operator/manager/rpc/types.go index 8a1a1c676..1ca8d9745 100644 --- a/operator/manager/rpc/types.go +++ b/operator/manager/rpc/types.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package rpc import ( diff --git a/operator/manager/setup.go b/operator/manager/setup.go index d607bfef5..284bd5912 100644 --- a/operator/manager/setup.go +++ b/operator/manager/setup.go @@ -1,6 +1,16 @@ -// 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. +// 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. package manager @@ -9,8 +19,8 @@ import ( "encoding/json" "time" - "github.com/drone/drone/store/shared/db" "github.com/drone/drone/core" + "github.com/drone/drone/store/shared/db" "github.com/hashicorp/go-multierror" "github.com/sirupsen/logrus" diff --git a/operator/manager/teardown.go b/operator/manager/teardown.go index d3c6d9477..c67b6ce26 100644 --- a/operator/manager/teardown.go +++ b/operator/manager/teardown.go @@ -1,6 +1,16 @@ -// 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. +// 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. package manager @@ -9,8 +19,8 @@ import ( "encoding/json" "time" - "github.com/drone/drone/store/shared/db" "github.com/drone/drone/core" + "github.com/drone/drone/store/shared/db" "github.com/drone/go-scm/scm" "github.com/hashicorp/go-multierror" diff --git a/operator/manager/updater.go b/operator/manager/updater.go index c8187dc05..3060a50e4 100644 --- a/operator/manager/updater.go +++ b/operator/manager/updater.go @@ -1,6 +1,16 @@ -// 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. +// 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. package manager diff --git a/operator/manager/util.go b/operator/manager/util.go index d247f9e54..3c17b8db7 100644 --- a/operator/manager/util.go +++ b/operator/manager/util.go @@ -1,6 +1,16 @@ -// 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. +// 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. package manager diff --git a/operator/runner/after.go b/operator/runner/after.go index f4b8566d0..25308ea5a 100644 --- a/operator/runner/after.go +++ b/operator/runner/after.go @@ -1,5 +1,15 @@ -// 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. +// 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. package runner diff --git a/operator/runner/before.go b/operator/runner/before.go index f4b8566d0..25308ea5a 100644 --- a/operator/runner/before.go +++ b/operator/runner/before.go @@ -1,5 +1,15 @@ -// 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. +// 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. package runner diff --git a/operator/runner/convert.go b/operator/runner/convert.go index e6ff7629e..918e33749 100644 --- a/operator/runner/convert.go +++ b/operator/runner/convert.go @@ -1,6 +1,16 @@ -// 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. +// 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. package runner diff --git a/operator/runner/env.go b/operator/runner/env.go index 0e1cc5dd9..02d54bea1 100644 --- a/operator/runner/env.go +++ b/operator/runner/env.go @@ -1,6 +1,16 @@ -// 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. +// 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. package runner diff --git a/operator/runner/machine/client.go b/operator/runner/machine/client.go index 9bef657e7..5e896f0eb 100644 --- a/operator/runner/machine/client.go +++ b/operator/runner/machine/client.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package machine // import ( diff --git a/operator/runner/machine/config.go b/operator/runner/machine/config.go index 08b978228..03d36d6da 100644 --- a/operator/runner/machine/config.go +++ b/operator/runner/machine/config.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package machine import ( diff --git a/operator/runner/machine/config_test.go b/operator/runner/machine/config_test.go index 2f19cf230..cfd1a6686 100644 --- a/operator/runner/machine/config_test.go +++ b/operator/runner/machine/config_test.go @@ -2,4 +2,6 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package machine diff --git a/operator/runner/machine/machine.go b/operator/runner/machine/machine.go index 10b22235e..a2807aa1a 100644 --- a/operator/runner/machine/machine.go +++ b/operator/runner/machine/machine.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package machine import ( diff --git a/operator/runner/machine/machine_test.go b/operator/runner/machine/machine_test.go index 1fba32449..dbbb1e6fd 100644 --- a/operator/runner/machine/machine_test.go +++ b/operator/runner/machine/machine_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package machine import ( diff --git a/operator/runner/runner.go b/operator/runner/runner.go index 84589edaf..fd903e0df 100644 --- a/operator/runner/runner.go +++ b/operator/runner/runner.go @@ -1,6 +1,16 @@ -// 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. +// 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. package runner diff --git a/operator/runner/secrets.go b/operator/runner/secrets.go index 839e95beb..d373ef9bb 100644 --- a/operator/runner/secrets.go +++ b/operator/runner/secrets.go @@ -1,6 +1,16 @@ -// 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. +// 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. package runner diff --git a/plugin/admission/nobot_oss.go b/plugin/admission/nobot_oss.go index a4aa48d83..0f06b20e9 100644 --- a/plugin/admission/nobot_oss.go +++ b/plugin/admission/nobot_oss.go @@ -16,9 +16,13 @@ package admission -import "github.com/drone/drone/core" +import ( + "time" + + "github.com/drone/drone/core" +) // 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) } diff --git a/plugin/config/global_oss.go b/plugin/config/global_oss.go index 0e79dc676..8d4243fce 100644 --- a/plugin/config/global_oss.go +++ b/plugin/config/global_oss.go @@ -24,7 +24,7 @@ import ( // Global returns a no-op configuration service. func Global(string, string, bool) core.ConfigService { - return + return new(noop) } type noop struct{} diff --git a/plugin/registry/endpoint_oss.go b/plugin/registry/endpoint_oss.go index 4fb37f494..f94c3892c 100644 --- a/plugin/registry/endpoint_oss.go +++ b/plugin/registry/endpoint_oss.go @@ -18,7 +18,7 @@ package registry import "github.com/drone/drone/core" -// Endpoint returns a no-op registry credential provider. -func Endpoint(string, string, bool) core.RegistryService { +// EndpointSource returns a no-op registry credential provider. +func EndpointSource(string, string, bool) core.RegistryService { return new(noop) } diff --git a/plugin/webhook/webhook_oss.go b/plugin/webhook/webhook_oss.go index 156e9a5a5..7f72012ab 100644 --- a/plugin/webhook/webhook_oss.go +++ b/plugin/webhook/webhook_oss.go @@ -29,6 +29,6 @@ func New([]string, string) core.WebhookSender { type noop struct{} -func (noop) Send(context.Context, *WebhookData) error { +func (noop) Send(context.Context, *core.WebhookData) error { return nil } diff --git a/scheduler/kube/kube_oss.go b/scheduler/kube/kube_oss.go index 3f935c67f..6fab9ddaf 100644 --- a/scheduler/kube/kube_oss.go +++ b/scheduler/kube/kube_oss.go @@ -26,14 +26,14 @@ type noop struct{} // FromConfig returns a no-op Kubernetes scheduler. func FromConfig(conf Config) (core.Scheduler, error) { - return new(noop) + return new(noop), nil } func (noop) Schedule(context.Context, *core.Stage) error { return nil } -func (noop) Request(context.Context, Filter) (*core.Stage, error) { +func (noop) Request(context.Context, core.Filter) (*core.Stage, error) { return nil, nil } diff --git a/scheduler/nomad/nomad_oss.go b/scheduler/nomad/nomad_oss.go index edbb9c8f1..f8c756bbd 100644 --- a/scheduler/nomad/nomad_oss.go +++ b/scheduler/nomad/nomad_oss.go @@ -26,14 +26,14 @@ type noop struct{} // FromConfig returns a no-op Nomad scheduler. func FromConfig(conf Config) (core.Scheduler, error) { - return new(noop) + return new(noop), nil } func (noop) Schedule(context.Context, *core.Stage) error { return nil } -func (noop) Request(context.Context, Filter) (*core.Stage, error) { +func (noop) Request(context.Context, core.Filter) (*core.Stage, error) { return nil, nil } diff --git a/service/license/load.go b/service/license/load.go index 0a8aa4536..c81d4c683 100644 --- a/service/license/load.go +++ b/service/license/load.go @@ -94,6 +94,8 @@ func Load(path string) (*core.License, error) { license := new(core.License) license.Expires = decoded.Exp + license.Licensor = decoded.Cus + license.Subscription = decoded.Sub err = json.Unmarshal(decoded.Dat, license) if err != nil { return nil, err diff --git a/service/syncer/filter_oss.go b/service/syncer/filter_oss.go new file mode 100644 index 000000000..db3f08ff0 --- /dev/null +++ b/service/syncer/filter_oss.go @@ -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 +} diff --git a/store/cron/cron_oss.go b/store/cron/cron_oss.go index 6fed59ba8..aff1fb76c 100644 --- a/store/cron/cron_oss.go +++ b/store/cron/cron_oss.go @@ -21,11 +21,10 @@ import ( "github.com/drone/drone/core" "github.com/drone/drone/store/shared/db" - "github.com/drone/drone/store/shared/encrypt" ) // 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) } diff --git a/store/logs/s3.go b/store/logs/s3.go index 77d4dbf40..6f5e92d08 100644 --- a/store/logs/s3.go +++ b/store/logs/s3.go @@ -21,9 +21,6 @@ import ( "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. func NewS3Env(bucket, prefix, endpoint string, pathStyle bool) core.LogStore { disableSSL := false diff --git a/store/logs/s3_oss.go b/store/logs/s3_oss.go new file mode 100644 index 000000000..9cb958468 --- /dev/null +++ b/store/logs/s3_oss.go @@ -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 +} diff --git a/store/shared/migrate/mysql/ddl.go b/store/shared/migrate/mysql/ddl.go index 5c5cddc3f..41f71516a 100644 --- a/store/shared/migrate/mysql/ddl.go +++ b/store/shared/migrate/mysql/ddl.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package mysql //go:generate togo ddl -package mysql -dialect mysql diff --git a/store/shared/migrate/postgres/ddl.go b/store/shared/migrate/postgres/ddl.go index 49a0c6864..99354fc75 100644 --- a/store/shared/migrate/postgres/ddl.go +++ b/store/shared/migrate/postgres/ddl.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Drone Non-Commercial License // that can be found in the LICENSE file. +// +build !oss + package postgres //go:generate togo ddl -package postgres -dialect postgres diff --git a/trigger/change.go b/trigger/change.go index 7fd42b298..c477b7013 100644 --- a/trigger/change.go +++ b/trigger/change.go @@ -1,8 +1,16 @@ -// 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 +// 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. package trigger diff --git a/trigger/cron/cron_oss.go b/trigger/cron/cron_oss.go index cc9b5c900..c87f9937f 100644 --- a/trigger/cron/cron_oss.go +++ b/trigger/cron/cron_oss.go @@ -30,12 +30,14 @@ func New( core.RepositoryStore, core.UserStore, core.Triggerer, -) *noop { - return &noop{} +) *Scheduler { + 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 } diff --git a/trigger/skip.go b/trigger/skip.go index c9da6e45f..497c7cf9f 100644 --- a/trigger/skip.go +++ b/trigger/skip.go @@ -1,8 +1,16 @@ -// 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 +// 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. package trigger diff --git a/trigger/trigger.go b/trigger/trigger.go index da1371050..2188dccca 100644 --- a/trigger/trigger.go +++ b/trigger/trigger.go @@ -1,8 +1,16 @@ -// 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 +// 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. package trigger