Skip to content

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

Description

@BenElgar

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. [BUG] Can't run a single component without running everything #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
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions