Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use forge from db #1417

Merged
merged 59 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
6ab8e1b
use forge from db
anbraten Nov 15, 2022
69c5387
Merge branch 'master' into repo-forge
anbraten Nov 15, 2022
f6d3a29
Merge remote-tracking branch 'upstream/master' into repo-forge
anbraten Nov 15, 2022
ac34221
Merge branch 'repo-forge' of github.com:anbraten/woodpecker into repo…
anbraten Nov 15, 2022
6360787
Merge branch 'master' into repo-forge
anbraten Nov 15, 2022
36bba76
Merge remote-tracking branch 'upstream/master' into repo-forge
anbraten May 31, 2023
d214070
undo change
anbraten May 31, 2023
bc13295
fix middleware
anbraten May 31, 2023
be69da6
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Jul 30, 2023
d48751c
update generated files
anbraten Jul 30, 2023
6ffe83d
adjust code
anbraten Jul 30, 2023
643a015
remove unused code
anbraten Jul 30, 2023
844d201
cleanup code
anbraten Jul 30, 2023
e1bb7ec
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Oct 9, 2023
5d6a63c
fixes
anbraten Oct 9, 2023
ce27362
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Nov 4, 2023
eba9654
fix
anbraten Nov 4, 2023
a46b85c
update comment
anbraten Nov 4, 2023
82e901f
some fixes
anbraten Nov 4, 2023
987a5ac
remove comment
anbraten Nov 4, 2023
672649f
use loading cache
anbraten Nov 4, 2023
f594355
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Nov 23, 2023
f175f10
update imports
anbraten Nov 23, 2023
09e66d4
update
anbraten Nov 23, 2023
08a35b8
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Jan 9, 2024
4b2842e
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Jan 13, 2024
d17021b
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Mar 21, 2024
9645b74
cleanup setup
anbraten Mar 21, 2024
3ee0026
fix imports
anbraten Mar 21, 2024
563d639
fixes
anbraten Mar 21, 2024
0c858a6
fix login
anbraten Mar 21, 2024
86fd8bc
add forge 0 from env
anbraten Mar 27, 2024
04fc03f
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Mar 27, 2024
2c5ee58
set default forge id
anbraten Mar 27, 2024
06fec24
cleanup and some test
anbraten Mar 27, 2024
79375d5
Merge branch 'main' into repo-forge
anbraten Mar 28, 2024
75aa8ce
fix lint and test
anbraten Mar 28, 2024
33e3f61
Merge branch 'repo-forge' of github.com:anbraten/woodpecker into repo…
anbraten Mar 28, 2024
d57dc0b
rename file
anbraten Mar 28, 2024
163d117
move forge service into service manager
anbraten Mar 28, 2024
a7c347b
Merge branch 'main' into repo-forge
anbraten Mar 28, 2024
a1b007e
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Mar 29, 2024
7438208
correct web use config forge
anbraten Mar 29, 2024
6e9c5ff
Merge branch 'main' into repo-forge
anbraten Apr 10, 2024
0fbdfc1
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Apr 15, 2024
e3db123
add addon forge
anbraten Apr 15, 2024
e51977a
Merge branch 'repo-forge' of github.com:anbraten/woodpecker into repo…
anbraten Apr 15, 2024
a3e88e1
add addon
anbraten Apr 15, 2024
a995fbc
fix lint
anbraten Apr 15, 2024
aa59c8d
Merge remote-tracking branch 'upstream/main' into repo-forge
anbraten Apr 15, 2024
cf091aa
some tweaks
anbraten Apr 15, 2024
00108dc
improve forge loading
anbraten Apr 15, 2024
028271a
Merge branch 'main' into repo-forge
anbraten Apr 15, 2024
3f3d575
migrate orgs
anbraten Apr 15, 2024
e02f3c6
Merge branch 'repo-forge' of github.com:anbraten/woodpecker into repo…
anbraten Apr 15, 2024
fcc93b5
update license
anbraten Apr 15, 2024
1e9679e
trigger ci
anbraten Apr 15, 2024
e255378
update swagger
anbraten Apr 15, 2024
811bc86
Merge branch 'main' into repo-forge
qwerty287 Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3891,6 +3891,9 @@ const docTemplate = `{
"Org": {
"type": "object",
"properties": {
"forge_id": {
"type": "integer"
},
"id": {
"type": "integer"
},
Expand Down Expand Up @@ -4122,6 +4125,9 @@ const docTemplate = `{
"default_branch": {
"type": "string"
},
"forge_id": {
"type": "integer"
},
"forge_remote_id": {
"description": "ForgeRemoteID is the unique identifier for the repository on the forge.",
"type": "string"
Expand Down Expand Up @@ -4418,6 +4424,9 @@ const docTemplate = `{
"description": "Email is the email address for this user.\n\nrequired: true",
"type": "string"
},
"forge_id": {
"type": "integer"
},
"id": {
"description": "the id for this user.\n\nrequired: true",
"type": "integer"
Expand Down
132 changes: 29 additions & 103 deletions cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ var flags = append([]cli.Flag{
Usage: "Disable version check in admin web ui.",
Name: "skip-version-check",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_ADDON_FORGE"},
Name: "addon-forge",
Usage: "forge addon",
},
//
// backend options for pipeline compiler
//
Expand Down Expand Up @@ -309,30 +304,41 @@ var flags = append([]cli.Flag{
Usage: "set the cpus allowed to execute containers",
},
//
// GitHub
//
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_GITHUB"},
Name: "github",
Usage: "github driver is enabled",
&cli.StringFlag{
Name: "forge-url",
Usage: "url of the forge",
EnvVars: []string{"WOODPECKER_FORGE_URL", "WOODPECKER_GITHUB_URL", "WOODPECKER_GITLAB_URL", "WOODPECKER_GITEA_URL", "WOODPECKER_BITBUCKET_URL"},
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITHUB_URL"},
Name: "github-server",
Usage: "github server address",
Value: "https://github.com",
Name: "forge-oauth-client",
Usage: "oauth2 client id",
EnvVars: []string{"WOODPECKER_FORGE_CLIENT", "WOODPECKER_GITHUB_CLIENT", "WOODPECKER_GITLAB_CLIENT", "WOODPECKER_GITEA_CLIENT", "WOODPECKER_BITBUCKET_CLIENT", "WOODPECKER_BITBUCKET_DC_CLIENT_ID"},
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITHUB_CLIENT"},
Name: "github-client",
Usage: "github oauth2 client id",
FilePath: os.Getenv("WOODPECKER_GITHUB_CLIENT_FILE"),
Name: "forge-oauth-secret",
Usage: "oauth2 client secret",
EnvVars: []string{"WOODPECKER_FORGE_SECRET", "WOODPECKER_GITHUB_SECRET", "WOODPECKER_GITLAB_SECRET", "WOODPECKER_GITEA_SECRET", "WOODPECKER_BITBUCKET_SECRET", "WOODPECKER_BITBUCKET_DC_CLIENT_SECRET"},
},
&cli.BoolFlag{
Name: "forge-skip-verify",
Usage: "skip ssl verification",
EnvVars: []string{"WOODPECKER_FORGE_SKIP_VERIFY", "WOODPECKER_GITHUB_SKIP_VERIFY", "WOODPECKER_GITLAB_SKIP_VERIFY", "WOODPECKER_GITEA_SKIP_VERIFY", "WOODPECKER_BITBUCKET_SKIP_VERIFY"},
},
//
// Addon
//
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITHUB_SECRET"},
Name: "github-secret",
Usage: "github oauth2 client secret",
FilePath: os.Getenv("WOODPECKER_GITHUB_SECRET_FILE"),
EnvVars: []string{"WOODPECKER_ADDON_FORGE"},
Name: "addon-forge",
Usage: "path to forge addon executable",
},
//
// GitHub
//
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_GITHUB"},
Name: "github",
Usage: "github driver is enabled",
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_GITHUB_MERGE_REF"},
Expand All @@ -346,11 +352,6 @@ var flags = append([]cli.Flag{
Usage: "github tokens should only get access to public repos",
Value: false,
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_GITHUB_SKIP_VERIFY"},
Name: "github-skip-verify",
Usage: "github skip ssl verification",
},
//
// Gitea
//
Expand All @@ -359,29 +360,6 @@ var flags = append([]cli.Flag{
Name: "gitea",
Usage: "gitea driver is enabled",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITEA_URL"},
Name: "gitea-server",
Usage: "gitea server address",
Value: "https://try.gitea.io",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITEA_CLIENT"},
Name: "gitea-client",
Usage: "gitea oauth2 client id",
FilePath: os.Getenv("WOODPECKER_GITEA_CLIENT_FILE"),
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITEA_SECRET"},
Name: "gitea-secret",
Usage: "gitea oauth2 client secret",
FilePath: os.Getenv("WOODPECKER_GITEA_SECRET_FILE"),
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_GITEA_SKIP_VERIFY"},
Name: "gitea-skip-verify",
Usage: "gitea skip ssl verification",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_DEV_GITEA_OAUTH_URL"},
Name: "gitea-oauth-server",
Expand All @@ -395,18 +373,6 @@ var flags = append([]cli.Flag{
Name: "bitbucket",
Usage: "bitbucket driver is enabled",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_BITBUCKET_CLIENT"},
Name: "bitbucket-client",
Usage: "bitbucket oauth2 client id",
FilePath: os.Getenv("WOODPECKER_BITBUCKET_CLIENT_FILE"),
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_BITBUCKET_SECRET"},
Name: "bitbucket-secret",
Usage: "bitbucket oauth2 client secret",
FilePath: os.Getenv("WOODPECKER_BITBUCKET_SECRET_FILE"),
},
//
// Gitlab
//
Expand All @@ -415,29 +381,6 @@ var flags = append([]cli.Flag{
Name: "gitlab",
Usage: "gitlab driver is enabled",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITLAB_URL"},
Name: "gitlab-server",
Usage: "gitlab server address",
Value: "https://gitlab.com",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITLAB_CLIENT"},
Name: "gitlab-client",
Usage: "gitlab oauth2 client id",
FilePath: os.Getenv("WOODPECKER_GITLAB_CLIENT_FILE"),
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_GITLAB_SECRET"},
Name: "gitlab-secret",
Usage: "gitlab oauth2 client secret",
FilePath: os.Getenv("WOODPECKER_GITLAB_SECRET_FILE"),
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_GITLAB_SKIP_VERIFY"},
Name: "gitlab-skip-verify",
Usage: "gitlab skip ssl verification",
},
//
// Bitbucket DataCenter/Server (previously Stash)
//
Expand All @@ -446,23 +389,6 @@ var flags = append([]cli.Flag{
Name: "bitbucket-dc",
Usage: "Bitbucket DataCenter/Server driver is enabled",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_BITBUCKET_DC_URL"},
Name: "bitbucket-dc-server",
Usage: "Bitbucket DataCenter/Server server address",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_BITBUCKET_DC_CLIENT_ID"},
Name: "bitbucket-dc-client-id",
Usage: "Bitbucket DataCenter/Server OAuth 2.0 client id",
FilePath: os.Getenv("WOODPECKER_BITBUCKET_DC_CLIENT_ID_FILE"),
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_BITBUCKET_DC_CLIENT_SECRET"},
Name: "bitbucket-dc-client-secret",
Usage: "Bitbucket DataCenter/Server OAuth 2.0 client secret",
FilePath: os.Getenv("WOODPECKER_BITBUCKET_DC_CLIENT_SECRET_FILE"),
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_BITBUCKET_DC_GIT_USERNAME"},
Name: "bitbucket-dc-git-username",
Expand Down
22 changes: 6 additions & 16 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"go.woodpecker-ci.org/woodpecker/v2/pipeline/rpc/proto"
"go.woodpecker-ci.org/woodpecker/v2/server"
"go.woodpecker-ci.org/woodpecker/v2/server/cron"
"go.woodpecker-ci.org/woodpecker/v2/server/forge"
"go.woodpecker-ci.org/woodpecker/v2/server/forge/setup"
woodpeckerGrpcServer "go.woodpecker-ci.org/woodpecker/v2/server/grpc"
"go.woodpecker-ci.org/woodpecker/v2/server/logging"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
Expand Down Expand Up @@ -82,11 +82,6 @@ func run(c *cli.Context) error {
)
}

_forge, err := setupForge(c)
if err != nil {
return fmt.Errorf("can't setup forge: %w", err)
}

_store, err := setupStore(c)
if err != nil {
return fmt.Errorf("can't setup store: %w", err)
Expand All @@ -97,7 +92,7 @@ func run(c *cli.Context) error {
}
}()

err = setupEvilGlobals(c, _store, _forge)
err = setupEvilGlobals(c, _store)
if err != nil {
return fmt.Errorf("can't setup globals: %w", err)
}
Expand All @@ -107,7 +102,7 @@ func run(c *cli.Context) error {
setupMetrics(&g, _store)

g.Go(func() error {
return cron.Start(c.Context, _store, _forge)
return cron.Start(c.Context, _store)
})

// start the grpc server
Expand All @@ -130,7 +125,6 @@ func run(c *cli.Context) error {
)

woodpeckerServer := woodpeckerGrpcServer.NewWoodpeckerServer(
_forge,
server.Config.Services.Queue,
server.Config.Services.Logs,
server.Config.Services.Pubsub,
Expand Down Expand Up @@ -270,17 +264,13 @@ func run(c *cli.Context) error {
return g.Wait()
}

func setupEvilGlobals(c *cli.Context, s store.Store, f forge.Forge) error {
// forge
server.Config.Services.Forge = f

func setupEvilGlobals(c *cli.Context, s store.Store) error {
// services
server.Config.Services.Queue = setupQueue(c, s)
server.Config.Services.Logs = logging.New()
server.Config.Services.Pubsub = pubsub.New()
server.Config.Services.Membership = setupMembershipService(c, f)

serviceMangager, err := services.NewManager(c, s)
server.Config.Services.Membership = setupMembershipService(c, s)
serviceMangager, err := services.NewManager(c, s, setup.Forge)
if err != nil {
return fmt.Errorf("could not setup service manager: %w", err)
}
Expand Down
Loading