This is an automated email from the ASF dual-hosted git repository.

miaoliyao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git


The following commit(s) were added to refs/heads/main by this push:
     new 58c7988  feat:process pgdata values (#215)
58c7988 is described below

commit 58c7988873074134e9fc48427dd2df9456f5be54
Author: lltgo <[email protected]>
AuthorDate: Mon Feb 20 17:53:00 2023 +0800

    feat:process pgdata values (#215)
    
    * feat:handle pgdata value setting methods
    
    * chore:change the style of naming cli flags
---
 pitr/agent/main.go | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/pitr/agent/main.go b/pitr/agent/main.go
index a72b111..577f35f 100644
--- a/pitr/agent/main.go
+++ b/pitr/agent/main.go
@@ -49,17 +49,20 @@ var (
 var (
        logLevel string
        port     string
+       pgData   string
        tlsCrt   string
        tlsKey   string
 )
 
 func init() {
        // 参数通过 flag 输入
-       flag.StringVar(&logLevel, "logLevel", "info", "optional:log 
level,option values:info or debug")
+       flag.StringVar(&logLevel, "log-level", "info", "optional:log 
level,option values:info or debug")
        flag.StringVar(&port, "port", "443", "HTTP service port")
 
-       flag.StringVar(&tlsCrt, "tlsCrt", "", "Require:TLS certificate file 
path")
-       flag.StringVar(&tlsKey, "tlsKey", "", "Require:TLS key file path")
+       flag.StringVar(&tlsCrt, "tls-crt", "", "Require:TLS certificate file 
path")
+       flag.StringVar(&tlsKey, "tls-key", "", "Require:TLS key file path")
+
+       flag.StringVar(&pgData, "pgdata", "", "Optional:Get the value from cli 
flags or env")
 }
 
 func main() {
@@ -70,6 +73,13 @@ func main() {
                panic(fmt.Errorf("shell does not exist"))
        }
 
+       if pgData == "" {
+               pgData = os.Getenv("PGDATA")
+               if pgData == "" {
+                       panic(fmt.Errorf("PGDATA:no database directory 
specified and environment variable PGDATA unset"))
+               }
+       }
+
        if strings.Trim(tlsCrt, " ") == "" || strings.Trim(tlsKey, " ") == "" {
                panic(fmt.Errorf("lack of HTTPs certificate"))
        }

Reply via email to