refactor(cmd/joj3): load attr in conf module
This commit is contained in:
		
							parent
							
								
									01d5c635d4
								
							
						
					
					
						commit
						8c48c0e4ee
					
				|  | @ -14,6 +14,7 @@ import ( | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/go-git/go-git/v5" | 	"github.com/go-git/go-git/v5" | ||||||
|  | 	"github.com/joint-online-judge/JOJ3/cmd/joj3/env" | ||||||
| 	"github.com/joint-online-judge/JOJ3/internal/stage" | 	"github.com/joint-online-judge/JOJ3/internal/stage" | ||||||
| 	"github.com/koding/multiconfig" | 	"github.com/koding/multiconfig" | ||||||
| ) | ) | ||||||
|  | @ -169,6 +170,7 @@ func ParseConfFile(path string) (conf *Conf, err error) { | ||||||
| 		slog.Error("validate stages conf", "error", err) | 		slog.Error("validate stages conf", "error", err) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | 	env.Attr.ConfName = conf.Name | ||||||
| 	// TODO: remove the following backward compatibility codes
 | 	// TODO: remove the following backward compatibility codes
 | ||||||
| 	if len(conf.Stage.Stages) == 0 { | 	if len(conf.Stage.Stages) == 0 { | ||||||
| 		conf.Stage.SandboxExecServer = conf.SandboxExecServer | 		conf.Stage.SandboxExecServer = conf.SandboxExecServer | ||||||
|  |  | ||||||
|  | @ -7,7 +7,6 @@ import ( | ||||||
| 	"os" | 	"os" | ||||||
| 
 | 
 | ||||||
| 	"github.com/joint-online-judge/JOJ3/cmd/joj3/conf" | 	"github.com/joint-online-judge/JOJ3/cmd/joj3/conf" | ||||||
| 	"github.com/joint-online-judge/JOJ3/cmd/joj3/env" |  | ||||||
| 	"github.com/joint-online-judge/JOJ3/cmd/joj3/stage" | 	"github.com/joint-online-judge/JOJ3/cmd/joj3/stage" | ||||||
| 	"github.com/joint-online-judge/JOJ3/cmd/joj3/teapot" | 	"github.com/joint-online-judge/JOJ3/cmd/joj3/teapot" | ||||||
| 	internalStage "github.com/joint-online-judge/JOJ3/internal/stage" | 	internalStage "github.com/joint-online-judge/JOJ3/internal/stage" | ||||||
|  | @ -87,7 +86,6 @@ func mainImpl() (err error) { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	slog.Debug("conf loaded", "conf", confObj) | 	slog.Debug("conf loaded", "conf", confObj) | ||||||
| 	env.Attr.ConfName = confObj.Name |  | ||||||
| 	if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded
 | 	if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded
 | ||||||
| 		slog.Error("setup slog", "error", err) | 		slog.Error("setup slog", "error", err) | ||||||
| 		return err | 		return err | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user