github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/testing_utils/cdc_state_checker/main.go (about) 1 // Copyright 2020 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package main 15 16 import ( 17 "context" 18 "flag" 19 "strings" 20 21 "github.com/pingcap/ticdc/pkg/security" 22 23 "github.com/pingcap/log" 24 "go.uber.org/zap" 25 "go.uber.org/zap/zapcore" 26 ) 27 28 var ( 29 pd = flag.String("pd", "http://127.0.0.1:2379", "PD address and port") 30 caPath = flag.String("ca", "", "CA certificate path for TLS connection") 31 certPath = flag.String("cert", "", "Certificate path for TLS connection") 32 keyPath = flag.String("key", "", "Private key path for TLS connection") 33 allowedCertCN = flag.String("cert-allowed-cn", "", "Verify caller's identity "+ 34 "(cert Common Name). Use `,` to separate multiple CN") 35 ) 36 37 func main() { 38 flag.Parse() 39 log.SetLevel(zapcore.DebugLevel) 40 41 cdcMonitor, err := newCDCMonitor(context.TODO(), *pd, getCredential()) 42 if err != nil { 43 log.Panic("Error creating CDCMonitor", zap.Error(err)) 44 } 45 46 err = cdcMonitor.run(context.TODO()) 47 log.Panic("cdcMonitor exited", zap.Error(err)) 48 } 49 50 func getCredential() *security.Credential { 51 var certAllowedCN []string 52 if len(*allowedCertCN) != 0 { 53 certAllowedCN = strings.Split(*allowedCertCN, ",") 54 } 55 return &security.Credential{ 56 CAPath: *caPath, 57 CertPath: *certPath, 58 KeyPath: *keyPath, 59 CertAllowedCN: certAllowedCN, 60 } 61 }