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

Change paths to use woodpecker instead of drone #494

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion charts/woodpecker-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extraSecretNamesForEnvFrom:
persistentVolume:
enabled: true
size: 10Gi
mountPath: "/var/lib/drone"
mountPath: "/var/lib/woodpecker"
storageClass: "gp2"

imagePullSecrets: []
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ var flags = []cli.Flag{
EnvVars: []string{"WOODPECKER_DATABASE_DATASOURCE"},
Name: "datasource",
Usage: "database driver configuration string",
Value: "drone.sqlite",
Value: "woodpecker.sqlite",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_PROMETHEUS_AUTH_TOKEN"},
Expand Down
30 changes: 30 additions & 0 deletions cmd/server/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"fmt"
"os"
"time"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -45,6 +46,10 @@ import (
)

func setupStore(c *cli.Context) (store.Store, error) {
if err := migrateSqlFile(c); err != nil {
log.Fatal().Err(err).Msg("could not migrate legacy sqlite file")
}

opts := &datastore.Opts{
Driver: c.String("driver"),
Config: c.String("datasource"),
Expand All @@ -53,6 +58,31 @@ func setupStore(c *cli.Context) (store.Store, error) {
return datastore.New(opts)
}

// TODO Remove this once we are sure users aren't attempting to migrate from Drone to Woodpecker (possibly never)
func migrateSqlFile(c *cli.Context) error {
// default config for docker containers
if c.String("datasource") == "/var/lib/woodpecker/woodpecker.sqlite" {
_, err := os.Stat("/var/lib/drone/drone.sqlite")
if err == nil {
return os.Rename("/var/lib/drone/drone.sqlite", "/var/lib/woodpecker/woodpecker.sqlite")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the best sol. since if you mout volume at /var/lib/drone it will move the DB outside of the volume!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of renaming I would propose to detect on driver=sqlite3 where the file could be on following order:

  1. /var/lib/woodpecker/woodpecker.sqlite -> All fine
  2. /var/lib/woodpecker/drone.sqlite -> rename to /var/lib/woodpecker/woodpecker.sqlite (print a warining(renamed ...))
  3. /var/lib/drone/drone.sqlite -> do nothing just use it and print a error!

} else if !os.IsNotExist(err) {
return err
}
}

// default config for standalone installations
if c.String("datasource") == "woodpecker.sqlite" {
_, err := os.Stat("drone.sqlite")
if err == nil {
return os.Rename("drone.sqlite", "woodpecker.sqlite")
} else if err != nil && !os.IsNotExist(err) {
return err
}
}

return nil
}

func setupQueue(c *cli.Context, s store.Store) queue.Queue {
return model.WithTaskStore(queue.New(), s)
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
ports:
- 8000:8000
volumes:
- /var/lib/drone:/var/lib/drone/
- /var/lib/woodpecker:/var/lib/woodpecker/
environment:
- WOODPECKER_OPEN=true
- WOODPECKER_ADMIN=laszlocph
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.
EXPOSE 8000 9000 80 443

ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/woodpecker/woodpecker.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3
ENV XDG_CACHE_HOME=/var/lib/drone
ENV XDG_CACHE_HOME=/var/lib/woodpecker

ADD dist/server/linux_amd64/woodpecker-server /bin/

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.server.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ RUN apk add -U --no-cache ca-certificates
EXPOSE 8000 9000 80 443

ENV GODEBUG=netdns=go
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/drone/drone.sqlite
ENV WOODPECKER_DATABASE_DATASOURCE=/var/lib/woodpecker/woodpecker.sqlite
ENV WOODPECKER_DATABASE_DRIVER=sqlite3
ENV XDG_CACHE_HOME=/var/lib/drone
ENV XDG_CACHE_HOME=/var/lib/woodpecker

ADD dist/server/linux_amd64/woodpecker-server /bin/

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-administration/00-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
ports:
- 8000:8000
volumes:
- woodpecker-server-data:/var/lib/drone/
- woodpecker-server-data:/var/lib/woodpecker/
environment:
- WOODPECKER_OPEN=true
- WOODPECKER_HOST=${WOODPECKER_HOST}
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/30-administration/30-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The default database engine of Woodpecker is an embedded SQLite database which r

## Configure sqlite

By default Woodpecker uses a sqlite database stored under `/var/lib/drone/`. You can mount a [data volume](https://docs.docker.com/storage/volumes/#create-and-manage-volumes) to persist the sqlite database.
By default Woodpecker uses a sqlite database stored under `/var/lib/woodpecker/`. You can mount a [data volume](https://docs.docker.com/storage/volumes/#create-and-manage-volumes) to persist the sqlite database.

```diff
# docker-compose.yml
Expand All @@ -14,7 +14,7 @@ services:
woodpecker-server:
[...]
+ volumes:
+ - woodpecker-server-data:/var/lib/drone/
+ - woodpecker-server-data:/var/lib/woodpecker/
```

## Configure MySQL
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-administration/60-ssl.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Note that Woodpecker uses the hostname from the `WOODPECKER_HOST` environment va
Woodpecker writes the certificates to the below directory:

```
/var/lib/drone/golang-autocert
/var/lib/woodpecker/golang-autocert
```

### Certificate Updates
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-administration/80-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
value: "xxx"
volumeMounts:
- name: sqlite-volume
mountPath: /var/lib/drone
mountPath: /var/lib/woodpecker
volumes:
- name: sqlite-volume
persistentVolumeClaim:
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/91-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Some versions need some changes to the server configuration or the pipeline conf

- Prometheus metrics have been changed from `drone_*` to `woodpecker_*`

- Base path has moved from `/var/lib/drone` to `/var/lib/woodpecker`

- Default SQLite database location has changed:
- `/var/lib/drone/drone.sqlite` -> `/var/lib/woodpecker/woodpecker.sqlite`
- `drone.sqlite` -> `woodpecker.sqlite`

- ...

## 0.14.0
Expand Down
2 changes: 1 addition & 1 deletion server/shared/procBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (b *ProcBuilder) toInternalRepresentation(parsed *yaml.Config, environ map[
),
),
compiler.WithProxy(),
compiler.WithWorkspaceFromURL("/drone", b.Repo.Link),
compiler.WithWorkspaceFromURL("/woodpecker", b.Repo.Link),
compiler.WithMetadata(metadata),
).Compile(parsed)
}
Expand Down