deref / exo

A process manager & log viewer for dev

Home Page:https://exo.deref.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Creating a project from a template does not apply the manifest

BenElgar opened this issue · comments

When we create a project using one of the templates that templates manifest should be automatically applied upon creation.

There are two reasons this doesn't happen right now:

  1. #482, which means that we would start all of the components, which isn't what we want.
  2. I'm not clear on how to best get a handle on a workspace from within a kernel function. Specifically, I'm not sure how to get a reference to a relevant Workspace struct from within here:
    func (kern *Kernel) CreateProject(ctx context.Context, input *api.CreateProjectInput) (*api.CreateProjectOutput, error) {
    projectDir := input.Root
    if !filepath.IsAbs(projectDir) {
    return nil, errors.New("path must be absolute")
    }
    var templateDir string
    if input.TemplateURL != nil {
    var err error
    templateDir, err = template.GetTemplateFiles(ctx, *input.TemplateURL)
    if err != nil {
    return nil, fmt.Errorf("getting template files: %w", err)
    }
    }
    if templateDir != "" {
    err := os.Rename(templateDir, projectDir)
    if err != nil {
    if os.IsExist(err) {
    return nil, dirExistsErr
    }
    return nil, fmt.Errorf("moving project dir: %w", err)
    }
    } else {
    if err := os.Mkdir(projectDir, 0750); err != nil {
    if os.IsExist(err) {
    return nil, dirExistsErr
    }
    return nil, fmt.Errorf("making project dir: %w", err)
    }
    }
    result, err := kern.CreateWorkspace(ctx, &api.CreateWorkspaceInput{Root: projectDir})
    if err != nil {
    return nil, fmt.Errorf("creating workspace: %w", err)
    }
    return &api.CreateProjectOutput{WorkspaceID: result.ID}, err
    }

See also #305