Skip to content

Commit

Permalink
refactor: 重构项目结构,移动文件到相应的目录并更新包名;新增请求工具函数
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Dec 8, 2024
1 parent 39b1542 commit 3a1379d
Showing 15 changed files with 411 additions and 609 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions config.go → config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package config

import (
"encoding/json"
@@ -95,9 +95,9 @@ func (c *GithubConfig) MergeDefault(defaultConf *DefaultConfig) {
}

type SyncConfig struct {
DefaultConf *DefaultConfig `json:"default_conf"`
Targets []GithubConfig `json:"targets"`
Cron string `json:"cron"`
DefaultConf *DefaultConfig `json:"default_conf"`
Targets []*GithubConfig `json:"targets"`
Cron string `json:"cron"`
}

func ConvertToBackupProviderConfig[T any](raw any) (*T, error) {
8 changes: 5 additions & 3 deletions config_test.go → config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package main
package config

import (
"encoding/json"
"fmt"
"github.com/TBXark/github-backup/provider/file"
"github.com/TBXark/github-backup/provider/gitea"
"testing"
)

@@ -13,7 +15,7 @@ func TestSyncConfig(t *testing.T) {
RepoOwner: "BACKUP_TARGET_REPO_OWNER",
Backup: &BackupProviderConfig{
Type: "gitea",
Config: &GiteaConf{
Config: &gitea.Config{
Host: "GITEA_HOST",
Token: "GITEA_TOKEN",
AuthUsername: "GITEA_USERNAME",
@@ -42,7 +44,7 @@ func TestSyncConfig(t *testing.T) {
RepoOwner: "BACKUP_TARGET_REPO_OWNER",
Backup: &BackupProviderConfig{
Type: "file",
Config: &FileBackupConfig{
Config: &file.FileBackupConfig{
Dir: "SAVE_DIR",
History: "FILE_HISTORY_JSON_PATH",
},
210 changes: 0 additions & 210 deletions file.go

This file was deleted.

Loading

0 comments on commit 3a1379d

Please sign in to comment.