chore: remove time validation
This commit is contained in:
		
							parent
							
								
									e1e49fb05a
								
							
						
					
					
						commit
						fce18b60cf
					
				| 
						 | 
					@ -13,7 +13,6 @@ import (
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/go-git/go-git/v5"
 | 
						"github.com/go-git/go-git/v5"
 | 
				
			||||||
	"github.com/koding/multiconfig"
 | 
						"github.com/koding/multiconfig"
 | 
				
			||||||
| 
						 | 
					@ -179,19 +178,6 @@ func GetConfPath(confRoot, confName, fallbackConfName, msg, tag string) (
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func CheckValid(conf *Conf) error {
 | 
					 | 
				
			||||||
	now := time.Now().Unix()
 | 
					 | 
				
			||||||
	if conf.EffectiveUnixTimestamp > 0 &&
 | 
					 | 
				
			||||||
		conf.EffectiveUnixTimestamp > now {
 | 
					 | 
				
			||||||
		return fmt.Errorf("config file not effective now: %d", now)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if conf.ExpireUnixTimestamp > 0 &&
 | 
					 | 
				
			||||||
		conf.ExpireUnixTimestamp < now {
 | 
					 | 
				
			||||||
		return fmt.Errorf("config file expired now: %d", now)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
 | 
					func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
 | 
				
			||||||
	seen := make(map[string]bool)
 | 
						seen := make(map[string]bool)
 | 
				
			||||||
	keywords := []string{}
 | 
						keywords := []string{}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,8 +24,6 @@ type Conf struct {
 | 
				
			||||||
	Name          string `default:"unknown"`
 | 
						Name          string `default:"unknown"`
 | 
				
			||||||
	LogPath       string `default:""`
 | 
						LogPath       string `default:""`
 | 
				
			||||||
	ActorCsvPath  string `default:""`
 | 
						ActorCsvPath  string `default:""`
 | 
				
			||||||
	EffectiveUnixTimestamp int64  `default:"-1"`
 | 
					 | 
				
			||||||
	ExpireUnixTimestamp    int64  `default:"-1"`
 | 
					 | 
				
			||||||
	MaxTotalScore int    `default:"-1"`
 | 
						MaxTotalScore int    `default:"-1"`
 | 
				
			||||||
	Stage         struct {
 | 
						Stage         struct {
 | 
				
			||||||
		SandboxExecServer string `default:"localhost:5051"`
 | 
							SandboxExecServer string `default:"localhost:5051"`
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,14 +92,6 @@ func showConfStat(confPath string, confStat fs.FileInfo) error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func validateConf(conf *joj3Conf.Conf) error {
 | 
					 | 
				
			||||||
	if err := joj3Conf.CheckValid(conf); err != nil {
 | 
					 | 
				
			||||||
		slog.Error("conf not valid now", "error", err)
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func run(conf *joj3Conf.Conf, conventionalCommit *joj3Conf.ConventionalCommit) error {
 | 
					func run(conf *joj3Conf.Conf, conventionalCommit *joj3Conf.ConventionalCommit) error {
 | 
				
			||||||
	groups := joj3Conf.MatchGroups(conf, conventionalCommit)
 | 
						groups := joj3Conf.MatchGroups(conf, conventionalCommit)
 | 
				
			||||||
	env.SetGroups(strings.Join(groups, ","))
 | 
						env.SetGroups(strings.Join(groups, ","))
 | 
				
			||||||
| 
						 | 
					@ -143,9 +135,6 @@ func mainImpl() (err error) {
 | 
				
			||||||
	if err := setupSlog(conf); err != nil {
 | 
						if err := setupSlog(conf); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := validateConf(conf); err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if err := run(conf, conventionalCommit); err != nil {
 | 
						if err := run(conf, conventionalCommit); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user