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 1 commit
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
24 changes: 24 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(); 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,25 @@ 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() error {
anbraten marked this conversation as resolved.
Show resolved Hide resolved
_, err := os.Stat("/var/lib/drone/drone.sqlite")
if err == nil {
return os.Rename("/var/lib/drone/drone.sqlite", "/var/lib/woodpecker/woodpecker.sqlite")
} else if !os.IsNotExist(err) {
return err
}

_, 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
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