From 9f9fba518b3738af2ffd2071d22a47c1d913659a Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Tue, 2 Dec 2025 10:20:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8A=A0=E5=BC=BA=E5=85=BC=E5=AE=B9):=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9Gitea/GitHub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gocos.go | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gocos.go b/gocos.go index 7a5f39e..73b86c1 100644 --- a/gocos.go +++ b/gocos.go @@ -32,25 +32,20 @@ func ErrExit(err error) { } func GetConfig(key string) string { - key = "PLUGIN_" + strings.ToUpper(key) + key = strings.ToUpper(key) + if val := os.Getenv("INPUT_" + key); val != "" { + return val + } + if val := os.Getenv("PLUGIN_" + key); val != "" { + return val + } return os.Getenv(key) } -func VarIsEmpty(a ...interface{}) bool { +func StrIsEmpty(a ...string) bool { for _, v := range a { - switch v := v.(type) { - case string: - if "" == v { - return true - } - case []byte: - if 0 == len(v) { - return true - } - case []string: - if 0 == len(v) { - return true - } + if v == "" { + return true } } return false @@ -74,8 +69,8 @@ func main() { target = GetConfig(Target) stripPrefix = GetConfig(StripPrefix) ) - if VarIsEmpty(secretID, secretKey, bucketURL, source, target) { - ErrExit(errors.New("input error")) + if StrIsEmpty(secretID, secretKey, bucketURL, source, target) { + ErrExit(errors.New("missing input parameter")) } sourceFiles := make([]string, 0, 0) if err = filepath.WalkDir(source, func(path string, d fs.DirEntry, err error) error {