-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Problem
configure project is currently a single command that creates a project. There are no subcommands for listing existing projects or deleting them. This is inconsistent with the CRUD pattern established by configure connection (which has add, list, update, delete, test) and the restructuring planned for configure scope in #55.
Users who want to inspect what projects exist, or remove a stale project, must use the DevLake API directly (or the Config UI).
Current command tree
configure project ← RunE = create project (only action)
Desired command tree
configure project ← no RunE, prints help
├── add ← current project creation logic
├── list ← list projects
└── delete ← delete a project by name
Dependencies
Blocked by:
configure connection add: Extract connection creation intoaddsubcommand #54 (connection add) — sets the extract-to-addpattern this issue follows
Blocks: nothing directly
Parallel with: #55 (scope CRUD) — independent files, can be done in parallel
Scope of changes
1. Create cmd/configure_project_add.go
Move the current runConfigureProjects() from configure_projects.go into a new add subcommand:
func newProjectAddCmd() *cobra.Command {
var opts ProjectOpts
cmd := &cobra.Command{
Use: "add",
Short: "Create a DevLake project and start data collection",
RunE: func(cmd *cobra.Command, args []string) error {
return runProjectAdd(cmd, args, &opts)
},
}
// Move all current project flags here
cmd.Flags().StringVar(&opts.ProjectName, "project-name", "", ...)
cmd.Flags().StringVar(&opts.Cron, "cron", "0 0 * * *", ...)
// ...
return cmd
}2. Create cmd/configure_project_list.go
// gh devlake configure project listImplementation:
- Call new client method
client.ListProjects()→GET /projects - Render results as a table:
Name | Description | Blueprint ID | Blueprint Status - No flags needed — lists all projects
3. Create cmd/configure_project_delete.go
// gh devlake configure project delete --name my-project
// gh devlake configure project delete (interactive: pick from list)Implementation:
- In flag mode, require
--name - In interactive mode: list projects → pick one → confirm deletion
- Call new client method
client.DeleteProject(name)→DELETE /projects/{name} - Confirm before deletion (warn about losing blueprint and sync schedule)
4. Update configure_projects.go
- Remove
RunEfrom the parent project command - Remove flag registrations (they move to
add) - Register
add,list,deleteas subcommands
5. Add client methods to internal/devlake/client.go
// ListProjects returns all DevLake projects.
func (c *Client) ListProjects() ([]Project, error) {
result, err := doGet[struct{ Projects []Project }](c, "/projects")
if err != nil {
return nil, err
}
return result.Projects, nil
}
// DeleteProject deletes a project by name.
func (c *Client) DeleteProject(name string) error {
url := fmt.Sprintf("%s/projects/%s", c.BaseURL, name)
req, _ := http.NewRequest(http.MethodDelete, url, nil)
resp, err := c.HTTPClient.Do(req)
// ... error handling ...
}Note: The exact response shape of GET /projects should be verified against the DevLake API. The upstream code is at backend/server/api/project/project.go in the apache/incubator-devlake repo.
6. Verify orchestrators are unaffected
collectAndFinalizeProject() in helpers.go calls finalizeProject() directly — it does not invoke the Cobra command. The restructuring should not affect orchestrators.
Acceptance criteria
-
gh devlake configure projectprints help showingadd,list,delete -
gh devlake configure project addcreates a project (same as current behavior) -
gh devlake configure project add --project-name my-teamworks in flag mode -
gh devlake configure project listshows a table of all projects -
gh devlake configure project delete --name my-projectdeletes a project - Interactive delete lists projects → user picks one → confirms → deletes
- Orchestrators (
configureAllPhases,collectAndFinalizeProject) continue to work -
go build ./...andgo test ./...pass - README updated
References
cmd/configure_projects.go— current project command (to be restructured)cmd/helpers.go—collectAndFinalizeProject(),finalizeProject()(should be unaffected)internal/devlake/client.go—CreateProject(),GetProject()exist; needListProjects(),DeleteProject()- DevLake API:
GET /projects,DELETE /projects/{name} configure connection add: Extract connection creation intoaddsubcommand #54 — same pattern forconfigure connection addconfigure scope add/list/delete: Add CRUD subcommands for scope management #55 — same pattern forconfigure scope add/list/delete