audit headers

pull/2624/head
Brad Rydzewski 2019-03-13 14:47:47 -07:00
parent 55abbdb5d3
commit ff8f29df53
88 changed files with 1024 additions and 146 deletions

View File

@ -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"

View File

@ -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,
},
)
}

View File

@ -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)

View File

@ -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

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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

View 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
}

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"
)

View File

@ -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

View File

@ -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 (

32
handler/api/queue/none.go Normal file
View 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
}

View File

@ -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 (

View File

@ -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

View File

@ -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 (

View File

@ -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

View File

@ -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"
)

View 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
}

View File

@ -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"

View File

@ -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"
)

View 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
}

View File

@ -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 (

View 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

View 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

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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 (

View File

@ -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

View 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
}

View File

@ -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 (

View File

@ -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 (

View File

@ -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"
)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

35
metric/handler_oss.go Normal file
View 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
View 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) {}

View File

@ -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
}

View File

@ -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,
},
}

View File

@ -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)
}

61
metric/sink/tags.go Normal file
View 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
}

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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 (

View 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) {}

View File

@ -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

View File

@ -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 (

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 (

View File

@ -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 (

View File

@ -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

View File

@ -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 (

View File

@ -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 (

View File

@ -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

View File

@ -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

View File

@ -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)
}

View File

@ -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{}

View File

@ -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)
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View 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
}

View File

@ -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)
}

View File

@ -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

24
store/logs/s3_oss.go Normal file
View 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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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