Skip to content

Commit

Permalink
Rename remote to forge (#1357)
Browse files Browse the repository at this point in the history
As of #745

Co-authored-by: Anbraten <anton@ju60.de>
  • Loading branch information
qwerty287 and anbraten authored Nov 4, 2022
1 parent 2ee75db commit 3372d1a
Show file tree
Hide file tree
Showing 135 changed files with 738 additions and 686 deletions.
8 changes: 4 additions & 4 deletions cli/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) frontend.Metadata {

return frontend.Metadata{
Repo: frontend.Repo{
Name: c.String("repo-name"),
Link: c.String("repo-link"),
Remote: c.String("repo-remote-url"),
Private: c.Bool("repo-private"),
Name: c.String("repo-name"),
Link: c.String("repo-link"),
CloneURL: c.String("repo-clone-url"),
Private: c.Bool("repo-private"),
},
Curr: frontend.Pipeline{
Number: c.Int64("pipeline-number"),
Expand Down
4 changes: 2 additions & 2 deletions cli/exec/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ var flags = []cli.Flag{
Name: "repo-link",
},
&cli.StringFlag{
EnvVars: []string{"CI_REPO_REMOTE"},
Name: "repo-remote-url",
EnvVars: []string{"CI_REPO_CLONE_URL", "CI_REPO_REMOTE"},
Name: "repo-clone-url",
},
&cli.StringFlag{
EnvVars: []string{"CI_REPO_PRIVATE"},
Expand Down
2 changes: 1 addition & 1 deletion cli/repo/repo_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ Visibility: {{ .Visibility }}
Private: {{ .IsSCMPrivate }}
Trusted: {{ .IsTrusted }}
Gated: {{ .IsGated }}
Remote: {{ .Clone }}
Forge: {{ .Clone }}
`
2 changes: 1 addition & 1 deletion cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ var flags = []cli.Flag{
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_FLAT_PERMISSIONS"},
Name: "flat-permissions",
Usage: "no remote call for permissions should be made",
Usage: "no forge call for permissions should be made",
Hidden: true,
// TODO(485) temporary workaround to not hit api rate limits
},
Expand Down
18 changes: 9 additions & 9 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import (
"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto"
"github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/cron"
"github.com/woodpecker-ci/woodpecker/server/forge"
woodpeckerGrpcServer "github.com/woodpecker-ci/woodpecker/server/grpc"
"github.com/woodpecker-ci/woodpecker/server/logging"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/plugins/config"
"github.com/woodpecker-ci/woodpecker/server/pubsub"
"github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/router"
"github.com/woodpecker-ci/woodpecker/server/router/middleware"
"github.com/woodpecker-ci/woodpecker/server/store"
Expand Down Expand Up @@ -101,7 +101,7 @@ func run(c *cli.Context) error {
)
}

_remote, err := setupRemote(c)
_forge, err := setupForge(c)
if err != nil {
log.Fatal().Err(err).Msg("")
}
Expand All @@ -116,14 +116,14 @@ func run(c *cli.Context) error {
}
}()

setupEvilGlobals(c, _store, _remote)
setupEvilGlobals(c, _store, _forge)

var g errgroup.Group

setupMetrics(&g, _store)

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

// start the grpc server
Expand All @@ -144,7 +144,7 @@ func run(c *cli.Context) error {
}),
)
woodpeckerServer := woodpeckerGrpcServer.NewWoodpeckerServer(
_remote,
_forge,
server.Config.Services.Queue,
server.Config.Services.Logs,
server.Config.Services.Pubsub,
Expand Down Expand Up @@ -253,12 +253,12 @@ func run(c *cli.Context) error {
return g.Wait()
}

func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
func setupEvilGlobals(c *cli.Context, v store.Store, f forge.Forge) {
// storage
server.Config.Storage.Files = v

// remote
server.Config.Services.Remote = r
// forge
server.Config.Services.Forge = f

// services
server.Config.Services.Queue = setupQueue(c, v)
Expand All @@ -270,7 +270,7 @@ func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
server.Config.Services.Registries = setupRegistryService(c, v)
server.Config.Services.Secrets = setupSecretService(c, v)
server.Config.Services.Environ = setupEnvironService(c, v)
server.Config.Services.Membership = setupMembershipService(c, r)
server.Config.Services.Membership = setupMembershipService(c, f)

server.Config.Services.SignaturePrivateKey, server.Config.Services.SignaturePublicKey = setupSignatureKeys(v)

Expand Down
62 changes: 31 additions & 31 deletions cmd/server/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ import (

"github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/cache"
"github.com/woodpecker-ci/woodpecker/server/forge"
"github.com/woodpecker-ci/woodpecker/server/forge/bitbucket"
"github.com/woodpecker-ci/woodpecker/server/forge/bitbucketserver"
"github.com/woodpecker-ci/woodpecker/server/forge/coding"
"github.com/woodpecker-ci/woodpecker/server/forge/gitea"
"github.com/woodpecker-ci/woodpecker/server/forge/github"
"github.com/woodpecker-ci/woodpecker/server/forge/gitlab"
"github.com/woodpecker-ci/woodpecker/server/forge/gogs"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/plugins/environments"
"github.com/woodpecker-ci/woodpecker/server/plugins/registry"
"github.com/woodpecker-ci/woodpecker/server/plugins/secrets"
"github.com/woodpecker-ci/woodpecker/server/queue"
"github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver"
"github.com/woodpecker-ci/woodpecker/server/remote/coding"
"github.com/woodpecker-ci/woodpecker/server/remote/gitea"
"github.com/woodpecker-ci/woodpecker/server/remote/github"
"github.com/woodpecker-ci/woodpecker/server/remote/gitlab"
"github.com/woodpecker-ci/woodpecker/server/remote/gogs"
"github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/woodpecker/server/store/datastore"
"github.com/woodpecker-ci/woodpecker/server/store/types"
Expand Down Expand Up @@ -182,12 +182,12 @@ func setupEnvironService(c *cli.Context, s store.Store) model.EnvironService {
return environments.Parse(c.StringSlice("environment"))
}

func setupMembershipService(_ *cli.Context, r remote.Remote) cache.MembershipService {
func setupMembershipService(_ *cli.Context, r forge.Forge) cache.MembershipService {
return cache.NewMembershipService(r)
}

// setupRemote helper function to setup the remote from the CLI arguments.
func setupRemote(c *cli.Context) (remote.Remote, error) {
// setupForge helper function to setup the forge from the CLI arguments.
func setupForge(c *cli.Context) (forge.Forge, error) {
switch {
case c.Bool("github"):
return setupGithub(c)
Expand All @@ -208,31 +208,31 @@ func setupRemote(c *cli.Context) (remote.Remote, error) {
}
}

// helper function to setup the Bitbucket remote from the CLI arguments.
func setupBitbucket(c *cli.Context) (remote.Remote, error) {
// helper function to setup the Bitbucket forge from the CLI arguments.
func setupBitbucket(c *cli.Context) (forge.Forge, error) {
opts := &bitbucket.Opts{
Client: c.String("bitbucket-client"),
Secret: c.String("bitbucket-secret"),
}
log.Trace().Msgf("Remote (bitbucket) opts: %#v", opts)
log.Trace().Msgf("Forge (bitbucket) opts: %#v", opts)
return bitbucket.New(opts)
}

// helper function to setup the Gogs remote from the CLI arguments.
func setupGogs(c *cli.Context) (remote.Remote, error) {
// helper function to setup the Gogs forge from the CLI arguments.
func setupGogs(c *cli.Context) (forge.Forge, error) {
opts := gogs.Opts{
URL: c.String("gogs-server"),
Username: c.String("gogs-git-username"),
Password: c.String("gogs-git-password"),
PrivateMode: c.Bool("gogs-private-mode"),
SkipVerify: c.Bool("gogs-skip-verify"),
}
log.Trace().Msgf("Remote (gogs) opts: %#v", opts)
log.Trace().Msgf("Forge (gogs) opts: %#v", opts)
return gogs.New(opts)
}

// helper function to setup the Gitea remote from the CLI arguments.
func setupGitea(c *cli.Context) (remote.Remote, error) {
// helper function to setup the Gitea forge from the CLI arguments.
func setupGitea(c *cli.Context) (forge.Forge, error) {
server, err := url.Parse(c.String("gitea-server"))
if err != nil {
return nil, err
Expand All @@ -246,12 +246,12 @@ func setupGitea(c *cli.Context) (remote.Remote, error) {
if len(opts.URL) == 0 {
log.Fatal().Msg("WOODPECKER_GITEA_URL must be set")
}
log.Trace().Msgf("Remote (gitea) opts: %#v", opts)
log.Trace().Msgf("Forge (gitea) opts: %#v", opts)
return gitea.New(opts)
}

// helper function to setup the Stash remote from the CLI arguments.
func setupStash(c *cli.Context) (remote.Remote, error) {
// helper function to setup the Stash forge from the CLI arguments.
func setupStash(c *cli.Context) (forge.Forge, error) {
opts := bitbucketserver.Opts{
URL: c.String("stash-server"),
Username: c.String("stash-git-username"),
Expand All @@ -261,12 +261,12 @@ func setupStash(c *cli.Context) (remote.Remote, error) {
ConsumerRSAString: c.String("stash-consumer-rsa-string"),
SkipVerify: c.Bool("stash-skip-verify"),
}
log.Trace().Msgf("Remote (bitbucketserver) opts: %#v", opts)
log.Trace().Msgf("Forge (bitbucketserver) opts: %#v", opts)
return bitbucketserver.New(opts)
}

// helper function to setup the Gitlab remote from the CLI arguments.
func setupGitlab(c *cli.Context) (remote.Remote, error) {
// helper function to setup the Gitlab forge from the CLI arguments.
func setupGitlab(c *cli.Context) (forge.Forge, error) {
return gitlab.New(gitlab.Opts{
URL: c.String("gitlab-server"),
ClientID: c.String("gitlab-client"),
Expand All @@ -275,21 +275,21 @@ func setupGitlab(c *cli.Context) (remote.Remote, error) {
})
}

// helper function to setup the GitHub remote from the CLI arguments.
func setupGithub(c *cli.Context) (remote.Remote, error) {
// helper function to setup the GitHub forge from the CLI arguments.
func setupGithub(c *cli.Context) (forge.Forge, error) {
opts := github.Opts{
URL: c.String("github-server"),
Client: c.String("github-client"),
Secret: c.String("github-secret"),
SkipVerify: c.Bool("github-skip-verify"),
MergeRef: c.Bool("github-merge-ref"),
}
log.Trace().Msgf("Remote (github) opts: %#v", opts)
log.Trace().Msgf("Forge (github) opts: %#v", opts)
return github.New(opts)
}

// helper function to setup the Coding remote from the CLI arguments.
func setupCoding(c *cli.Context) (remote.Remote, error) {
// helper function to setup the Coding forge from the CLI arguments.
func setupCoding(c *cli.Context) (forge.Forge, error) {
opts := coding.Opts{
URL: c.String("coding-server"),
Client: c.String("coding-client"),
Expand All @@ -299,7 +299,7 @@ func setupCoding(c *cli.Context) (remote.Remote, error) {
Password: c.String("coding-git-password"),
SkipVerify: c.Bool("coding-skip-verify"),
}
log.Trace().Msgf("Remote (coding) opts: %#v", opts)
log.Trace().Msgf("Forge (coding) opts: %#v", opts)
return coding.New(opts)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/20-usage/25-multi-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Multi-Pipeline feature allows the pipeline to be split into several files an

## Rational

- faster lint/test feedback, the pipeline doesn't have to run fully to have a lint status pushed to the remote
- faster lint/test feedback, the pipeline doesn't have to run fully to have a lint status pushed to the forge
- better organization of the pipeline along various concerns: testing, linting, feature apps
- utilizing more agents to speed up build

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/20-usage/50-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This is the reference list of all environment variables available to your pipeli
| `CI_REPO_NAME` | repository name |
| `CI_REPO_SCM` | repository SCM (git) |
| `CI_REPO_LINK` | repository link |
| `CI_REPO_REMOTE` | repository clone URL |
| `CI_REPO_CLONE_URL` | repository clone URL |
| `CI_REPO_DEFAULT_BRANCH` | repository default branch (master) |
| `CI_REPO_PRIVATE` | repository is private |
| `CI_REPO_TRUSTED` | repository is trusted |
Expand All @@ -68,7 +68,7 @@ This is the reference list of all environment variables available to your pipeli
| `CI_COMMIT_TARGET_BRANCH` | commit target branch |
| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) |
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (empty if event is not `pull_request`) |
| `CI_COMMIT_LINK` | commit link in remote |
| `CI_COMMIT_LINK` | commit link in forge |
| `CI_COMMIT_MESSAGE` | commit message |
| `CI_COMMIT_AUTHOR` | commit author username |
| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address |
Expand All @@ -95,7 +95,7 @@ This is the reference list of all environment variables available to your pipeli
| `CI_PREV_COMMIT_BRANCH` | previous commit branch |
| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch |
| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch |
| `CI_PREV_COMMIT_LINK` | previous commit link in remote |
| `CI_PREV_COMMIT_LINK` | previous commit link in forge |
| `CI_PREV_COMMIT_MESSAGE` | previous commit message |
| `CI_PREV_COMMIT_AUTHOR` | previous commit author username |
| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ WOODPECKER_CONFIG_SERVICE_ENDPOINT=https://example.com/ciconfig
"parent": 0,
"ref": "refs/heads/master",
"refspec": "",
"remote": "",
"clone_url": "",
"reviewed_at": 0,
"reviewed_by": "",
"sender": "myUser",
Expand Down
1 change: 1 addition & 0 deletions docs/docs/91-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Some versions need some changes to the server configuration or the pipeline conf
- Renamed step environment variable `CI_SYSTEM_ARCH` to `CI_SYSTEM_PLATFORM`. Same applies for the cli exec variable.
- Renamed environment variables `CI_BUILD_*` and `CI_PREV_BUILD_*` to `CI_PIPELINE_*` and `CI_PREV_PIPELINE_*`, old ones are still available but deprecated
- Renamed environment variables `CI_JOB_*` to `CI_STEP_*`, old ones are still available but deprecated
- Renamed environment variable `CI_REPO_REMOTE` to `CI_REPO_CLONE_URL`
- Renamed API endpoints for pipelines (`<owner>/<repo>/builds/<buildId>` -> `<owner>/<repo>/pipelines/<pipelineId>`), old ones are still available but deprecated
- Updated Prometheus gauge `build_*` to `pipeline_*`
- Updated Prometheus gauge `*_job_*` to `*_step_*`
Expand Down
34 changes: 17 additions & 17 deletions docs/docs/92-development/05-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@

### Server

| package | meaning | imports
|---------------------|-------------------------------------------------|----------
| `server/api/**` | handle web requests from `server/router` | `pipeline`, `../badges`, `../ccmenue`, `../logging`, `../model`, `../pubsub`, `../queue`, `../remote`, `../shared`, `../store`, `shared`, (TODO: mv `server/router/middleware/session`)
| `server/badges/**` | generate svg badges for pipelines | `../model`
| `server/ccmenu/**` | generate xml ccmenu for pipelines | `../model`
| `server/grpc/**` | gRPC server agents can connect to | `pipeline/rpc/**`, `../logging`, `../model`, `../pubsub`, `../queue`, `../remote`, `../pipeline`, `../store`
| `server/logging/**` | logging lib for gPRC server to stream logs while running | std
| `server/model/**` | structs for store (db) and api (json) | std
| `server/plugins/**` | plugins for server | `../model`, `../remote`
| `server/pipeline/**`| orchestrate pipelines | `pipeline`, `../model`, `../pubsub`, `../queue`, `../remote`, `../store`, `../plugins`
| `server/pubsub/**` | pubsub lib for server to push changes to the WebUI | std
| `server/queue/**` | queue lib for server where agents pull new pipelines from via gRPC | `server/model`
| `server/remote/**` | remote lib for server to connect and handle forge specific stuff | `shared`, `server/model`
| `server/router/**` | handle requests to REST API (and all middleware) and serve UI and WebUI config | `shared`, `../api`, `../model`, `../remote`, `../store`, `../web`
| `server/store/**` | handle database | `server/model`
| `server/shared/**` | TODO: move and split [#974](https://github.com/woodpecker-ci/woodpecker/issues/974) |
| `server/web/**` | server SPA |
| package | meaning | imports
|----------------------|-------------------------------------------------------------------------------------|----------
| `server/api/**` | handle web requests from `server/router` | `pipeline`, `../badges`, `../ccmenue`, `../logging`, `../model`, `../pubsub`, `../queue`, `../forge`, `../shared`, `../store`, `shared`, (TODO: mv `server/router/middleware/session`)
| `server/badges/**` | generate svg badges for pipelines | `../model`
| `server/ccmenu/**` | generate xml ccmenu for pipelines | `../model`
| `server/grpc/**` | gRPC server agents can connect to | `pipeline/rpc/**`, `../logging`, `../model`, `../pubsub`, `../queue`, `../forge`, `../pipeline`, `../store`
| `server/logging/**` | logging lib for gPRC server to stream logs while running | std
| `server/model/**` | structs for store (db) and api (json) | std
| `server/plugins/**` | plugins for server | `../model`, `../forge`
| `server/pipeline/**` | orchestrate pipelines | `pipeline`, `../model`, `../pubsub`, `../queue`, `../forge`, `../store`, `../plugins`
| `server/pubsub/**` | pubsub lib for server to push changes to the WebUI | std
| `server/queue/**` | queue lib for server where agents pull new pipelines from via gRPC | `server/model`
| `server/forge/**` | forge lib for server to connect and handle forge specific stuff | `shared`, `server/model`
| `server/router/**` | handle requests to REST API (and all middleware) and serve UI and WebUI config | `shared`, `../api`, `../model`, `../forge`, `../store`, `../web`
| `server/store/**` | handle database | `server/model`
| `server/shared/**` | TODO: move and split [#974](https://github.com/woodpecker-ci/woodpecker/issues/974) |
| `server/web/**` | server SPA |

* `../` = `server/`

Expand Down
Loading

0 comments on commit 3372d1a

Please sign in to comment.