* refactor(report): LocalFileWriter * refactor -format-json * refacotr: -format-one-email * refactor: -format-csv * refactor: -gzip * refactor: -format-full-text * refactor: -format-one-line-text * refactor: -format-list * refacotr: remove -to-* from config * refactor: IgnoreGitHubDismissed * refactor: GitHub * refactor: IgnoreUnsocred * refactor: diff * refacotr: lang * refacotr: cacheDBPath * refactor: Remove config references * refactor: ScanResults * refacotr: constant pkg * chore: comment * refactor: scanner * refactor: scanner * refactor: serverapi.go * refactor: serverapi * refactor: change pkg structure * refactor: serverapi.go * chore: remove emtpy file * fix(scan): remove -ssh-native-insecure option * fix(scan): remove the deprecated option `keypassword`
		
			
				
	
	
		
			34 lines
		
	
	
		
			666 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			666 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package config
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/asaskevich/govalidator"
 | 
						|
	"golang.org/x/xerrors"
 | 
						|
)
 | 
						|
 | 
						|
// TelegramConf is Telegram config
 | 
						|
type TelegramConf struct {
 | 
						|
	Token   string `json:"-"`
 | 
						|
	ChatID  string `json:"-"`
 | 
						|
	Enabled bool   `toml:"-" json:"-"`
 | 
						|
}
 | 
						|
 | 
						|
// Validate validates configuration
 | 
						|
func (c *TelegramConf) Validate() (errs []error) {
 | 
						|
	if !c.Enabled {
 | 
						|
		return
 | 
						|
	}
 | 
						|
	if len(c.ChatID) == 0 {
 | 
						|
		errs = append(errs, xerrors.New("TelegramConf.ChatID must not be empty"))
 | 
						|
	}
 | 
						|
 | 
						|
	if len(c.Token) == 0 {
 | 
						|
		errs = append(errs, xerrors.New("TelegramConf.Token must not be empty"))
 | 
						|
	}
 | 
						|
 | 
						|
	_, err := govalidator.ValidateStruct(c)
 | 
						|
	if err != nil {
 | 
						|
		errs = append(errs, err)
 | 
						|
	}
 | 
						|
	return
 | 
						|
}
 |