Skip to content
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
34 changes: 32 additions & 2 deletions assets/go-licenses.json

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions cmd/migrate_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/fs"
"strings"
"time"

actions_model "code.gitea.io/gitea/models/actions"
"code.gitea.io/gitea/models/db"
Expand Down Expand Up @@ -125,6 +126,72 @@ var CmdMigrateStorage = &cli.Command{
Value: "",
Usage: "Azure Blob storage base path",
},
&cli.StringFlag{
Name: "goauth-secret",
Usage: "Google oauth client secret (installed.client_secret)",
Category: "Google drive",
Value: "",
},
&cli.StringFlag{
Name: "goauth-client",
Usage: "Google oauth client id (installed.client_id)",
Category: "Google drive",
Value: "",
},
&cli.StringFlag{
Name: "goauth-project",
Usage: "Google oauth project id (installed.project_id)",
Category: "Google drive",
Value: "",
},
&cli.StringFlag{
Name: "goauth-access-token",
Usage: "Google oauth access token",
Category: "Google drive",
Value: "",
},
&cli.StringFlag{
Name: "goauth-refresh-token",
Usage: "Google oauth token to refresh auth token",
Category: "Google drive",
Value: "",
},
&cli.StringFlag{
Name: "goauth-token-type",
Usage: "Google oauth token type",
Category: "Google drive",
Value: "Bearer",
},
&cli.StringFlag{
Name: "goauth-auth-endpoint",
Usage: "Google url to auth",
Category: "Google drive",
Value: "https://accounts.google.com/o/oauth2/auth",
},
&cli.StringFlag{
Name: "goauth-token-endpoint",
Usage: "Google token endpoint",
Category: "Google drive",
Value: "https://oauth2.googleapis.com/token",
},
&cli.StringFlag{
Name: "goauth-expiry",
Usage: "Google oauth token expiry date (in this layout 2006-01-02T15:04:05Z07:00)",
Category: "Google drive",
Value: "",
},
&cli.StringFlag{
Name: "gdrive-folder",
Usage: "Google drive folder id (gdrive:<Folder ID>) or path",
Category: "Google drive",
Value: "",
},
&cli.BoolFlag{
Name: "gdrive-resolve-folder",
Usage: "resolve path to File, else create file name with full path",
Category: "Google drive",
Value: true,
},
},
}

Expand Down Expand Up @@ -281,6 +348,29 @@ func runMigrateStorage(ctx *cli.Context) error {
BasePath: ctx.String("azureblob-base-path"),
},
})
case string(setting.GoogleDriveType):
var timestamp time.Time
if ctx.String("goauth-expiry") != "" {
if timestamp, err = time.Parse(time.RFC3339, ctx.String("goauth-expiry")); err != nil {
return err
}
}
dstStorage, err = storage.NewGoogleDrive(stdCtx, &setting.Storage{
GoogleDriveConfig: setting.GoogleOauthConfig{
Secret: ctx.String("goauth-secret"),
Client: ctx.String("goauth-client"),
Project: ctx.String("goauth-project"),
Redirect: "http://localhost:3081/callback",
AccessToken: ctx.String("goauth-access-token"),
RefreshToken: ctx.String("goauth-refresh-token"),
TokenType: ctx.String("goauth-token-type"),
FolderResolve: ctx.Bool("gdrive-resolve-folder"),
RootFolder: ctx.String("gdrive-folder"),
TokenURI: ctx.String("goauth-token-endpoint"),
AuthURI: ctx.String("goauth-auth-endpoint"),
Expire: timestamp,
},
})
default:
return fmt.Errorf("unsupported storage type: %s", ctx.String("storage"))
}
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ require (
golang.org/x/sys v0.21.0
golang.org/x/text v0.16.0
golang.org/x/tools v0.22.0
google.golang.org/api v0.153.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.34.2
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
Expand Down Expand Up @@ -214,6 +215,9 @@ require (
github.com/google/btree v1.1.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/go-tpm v0.9.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
Expand Down Expand Up @@ -293,6 +297,7 @@ require (
github.com/zeebo/blake3 v0.2.3 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
Expand Down
Loading