func NewProject()

in astro/astro.go [48:90]


func NewProject(opts ...Option) (*Project, error) {
	project := &Project{}

	logger.Trace.Println("astro: initializing")

	if err := project.applyOptions(opts...); err != nil {
		return nil, err
	}

	versionRepo, err := tvm.NewVersionRepoForCurrentSystem("")
	if err != nil {
		return nil, fmt.Errorf("failed to initialize tvm: %v", err)
	}
	project.terraformVersions = versionRepo

	sessionRepoPath := filepath.Join(project.config.SessionRepoDir, ".astro")
	sessions, err := NewSessionRepo(project, sessionRepoPath, utils.ULIDString)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize session repository: %v", err)
	}
	project.sessions = sessions

	// check dependency graph is all good
	if _, err := project.executions(NoExecutionParameters()).graph(); err != nil {
		return nil, err
	}

	if project.config.Hooks.Startup == nil {
		return project, nil
	}

	session, err := project.sessions.Current()
	if err != nil {
		return nil, err
	}
	for _, hook := range project.config.Hooks.Startup {
		if err := runCommandkAndSetEnvironment(session.path, hook); err != nil {
			return nil, fmt.Errorf("error running Startup hook: %v", err)
		}
	}

	return project, nil
}