refactor(internal): 分离runner
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type GithubMakeRepositoryPublicRuleValidator struct{}
|
||||
|
||||
func (v *GithubMakeRepositoryPublicRuleValidator) GetType() string {
|
||||
return "github_make_repository_public"
|
||||
}
|
||||
|
||||
func (v *GithubMakeRepositoryPublicRuleValidator) Validate(configJSON string) error {
|
||||
var config GithubReposConfig
|
||||
if err := json.Unmarshal([]byte(configJSON), &config); err != nil {
|
||||
return fmt.Errorf("解析 GitHub 规则配置失败: %v", err)
|
||||
}
|
||||
|
||||
if len(config.Repos) == 0 {
|
||||
return fmt.Errorf("GitHub 规则配置错误: 至少需要指定一个仓库")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/ssdomei232/goodBaby/model"
|
||||
)
|
||||
|
||||
// GithubMakeRepoPublicExecutor GitHub仓库公开执行器
|
||||
type GithubMakeRepoPublicExecutor struct{}
|
||||
|
||||
func (e *GithubMakeRepoPublicExecutor) GetType() string {
|
||||
return "github-make-repo-public"
|
||||
}
|
||||
|
||||
func (e *GithubMakeRepoPublicExecutor) Execute(rule *model.Rule) error {
|
||||
log.Printf("执行GitHub仓库公开规则: %s (ID: %d)", rule.Name, rule.ID)
|
||||
|
||||
MakeRepositoryPublic(rule)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user