Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace Management Rework #1729

Merged
merged 76 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
e089497
refactor: rename Target to Target Config (#1292)
Tpuljak Oct 25, 2024
dcd8b1b
refactor: rename Workspace to Target (#1297)
Tpuljak Oct 25, 2024
b53cfee
refactor: rename project to workspace (#1299)
idagelic Oct 28, 2024
940a090
refactor: detach workspace from target
Tpuljak Nov 4, 2024
7a48032
feat: target & target config rework
idagelic Nov 6, 2024
018635c
fix: multi select and info workspace view (#1321, #1322)
lbrecic Nov 7, 2024
78cbd1b
feat: add multi-select to restart cmd (#1328)
lbrecic Nov 12, 2024
b9589d5
refactor: remove database DTOs
Tpuljak Nov 12, 2024
ba8a528
refactor: service and store restructure
Tpuljak Nov 13, 2024
3bb2849
feat: resource state management using jobs (#1351)
idagelic Nov 27, 2024
56b8745
fix: implement correct multi-create output (#1368)
lbrecic Nov 28, 2024
9aaaedb
refactor: add workspace deletion option to target removal (#1333)
lbrecic Nov 28, 2024
8476d9c
refactor: add target config reference to target (#1340)
lbrecic Nov 28, 2024
431c845
refactor: change profile data to server env vars (#1361)
lbrecic Nov 28, 2024
e91fdec
refactor: rename workspace config to workspace template (#1389)
idagelic Nov 29, 2024
9bef381
fix: disallow concurrent jobs (#1405)
Tpuljak Dec 2, 2024
a111348
telemetry: disable polling requests
Tpuljak Dec 4, 2024
86ffaad
refactor: build runner with states (#1410)
idagelic Dec 4, 2024
62bee0e
fix: api hide env vars for nested targets or workspaces (#1415)
idagelic Dec 4, 2024
cb5d3a7
feat: disable items for selection when in invalid state (#1412)
lbrecic Dec 4, 2024
48e97e1
feat: target ssh command (#1404)
Tpuljak Dec 5, 2024
71df1e1
fix: start job runner after server
Tpuljak Dec 5, 2024
a55e01e
refactor: move target and workspacetemplate dtos into service files
Tpuljak Dec 5, 2024
c004e92
refactor: enable container registry setting through env-vars (#1406)
lbrecic Dec 5, 2024
adeac5d
refactor: update gorm decorators (#1420)
lbrecic Dec 5, 2024
35d92e5
feat: db transaction support (#1411)
Tpuljak Dec 5, 2024
bd385e9
refactor: db store interface
Tpuljak Dec 6, 2024
0650dd5
fix: target set default commit tx
Tpuljak Dec 6, 2024
e9e459a
fix: properly handle no target mode agent in providers (#1421)
idagelic Dec 6, 2024
871e8de
fix: set builder registry server to default frpc domain (#1449)
lbrecic Dec 13, 2024
8a6a04d
feat: implement docker creds helper (#1427)
lbrecic Dec 13, 2024
850333b
fix: db store AutoMigrate type
Tpuljak Dec 17, 2024
31484e6
refactor: parametrize headscale user methods
Tpuljak Dec 19, 2024
14f260f
feat: remote runners (#1462)
idagelic Dec 23, 2024
62adfcb
fix: target config deletion and agentless prop (#1693)
idagelic Jan 8, 2025
12fa401
fix: agentmode (#1500)
lbrecic Jan 10, 2025
10e52e1
refactor: move agent_mode util to common
Tpuljak Jan 10, 2025
435ec3a
fix: create target dto param (#1694)
idagelic Jan 10, 2025
3d40f5b
refactor: abstract api key generation methods (#1701)
Tpuljak Jan 10, 2025
d8d9ff9
feat: auto-create docker default target
Tpuljak Jan 10, 2025
4913c34
fix: purge (#1456)
lbrecic Jan 13, 2025
e9d4471
telemetry: refactor and add more events (#1691)
Tpuljak Jan 13, 2025
73265f3
fix: remove key hash when listing api-keys (#1703)
lbrecic Jan 13, 2025
2bcc390
fix: make prebuild ID optional for build (#1706)
lbrecic Jan 13, 2025
5ca2e81
fix: tests and minor issues (#1707)
Tpuljak Jan 13, 2025
b41b70b
fix: global verb consistency, cli aliases
idagelic Jan 13, 2025
c2667d4
refactor: service method naming consistency
Tpuljak Jan 14, 2025
6a66e8a
docs: add conventions to contributing guide
Tpuljak Jan 14, 2025
e0f3d34
fix: gorm foreign key relations
Tpuljak Dec 23, 2024
31ec48f
fix: last job ID foreign key
Tpuljak Dec 23, 2024
29a0e50
fix: metadata save order
Tpuljak Dec 23, 2024
01b46c1
fix: restart methods (#1685)
idagelic Jan 9, 2025
5c47745
fix: command naming
idagelic Jan 14, 2025
f624bb4
fix: local docker target check
Tpuljak Jan 14, 2025
48b6d89
fix: sigkill on workspace stop
Tpuljak Jan 14, 2025
9e822d9
fix: template import export and cli docs
idagelic Jan 14, 2025
e5cb7ca
fix: set correct error on job
Tpuljak Jan 15, 2025
d55690a
fix: leftover in initial screen
idagelic Jan 15, 2025
ca5b6b9
fix: target config create non-interactive (#1714)
lbrecic Jan 15, 2025
1dcfbf4
fix: set docker cred helper config (#1717)
lbrecic Jan 16, 2025
dd3584d
fix: ssh edit command (#1716)
lbrecic Jan 16, 2025
da71dbe
fix: config alias
idagelic Jan 16, 2025
f3269a0
feat: workspace labels (#1718)
Tpuljak Jan 16, 2025
28084ac
fix: tui clearing labels
idagelic Jan 16, 2025
2b1951f
fix: hide empty field in target info
idagelic Jan 16, 2025
4cf2622
fix: ghost default target (#1726)
lbrecic Jan 16, 2025
5eda5c2
fix: create tui fails on label required
idagelic Jan 17, 2025
480e944
feat: readme rework (#1724)
idagelic Jan 17, 2025
af5183d
fix: readme demo url
idagelic Jan 17, 2025
fbd049f
refactor: long polling for runner jobs (#1727)
idagelic Jan 17, 2025
e089967
fix: license header
idagelic Jan 17, 2025
129a54d
fix: generate cli docs
idagelic Jan 17, 2025
9c2da10
feat: get state for resource, get runner providers endpoints (#1730)
idagelic Jan 20, 2025
1b401df
refactor: make provider manifests fetch through API only (#1725)
lbrecic Jan 21, 2025
1f39b4c
fix: toolbox session import
Tpuljak Jan 21, 2025
e47fe21
fix: relative asset url
idagelic Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: add target config reference to target (#1340)
Signed-off-by: Luka Brecic <[email protected]>
lbrecic authored and Tpuljak committed Jan 21, 2025
commit 8476d9cf52d6fb1d64466c8c44294bdfaf89065b
2 changes: 1 addition & 1 deletion docs/daytona_target-config.md
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ Manage target configs
### SEE ALSO

* [daytona](daytona.md) - Daytona is a Dev Environment Manager
* [daytona target-config add](daytona_target-config_add.md) - Add target config
* [daytona target-config list](daytona_target-config_list.md) - List target configs
* [daytona target-config remove](daytona_target-config_remove.md) - Remove target config
* [daytona target-config set](daytona_target-config_set.md) - Set target config

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## daytona target-config set
## daytona target-config add

Set target config
Add target config

```
daytona target-config set [flags]
daytona target-config add [flags]
```

### Options inherited from parent commands
2 changes: 1 addition & 1 deletion docs/daytona_target-config_remove.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
Remove target config

```
daytona target-config remove [CONFIG_NAME] [flags]
daytona target-config remove [TARGET_CONFIG] [flags]
```

### Options
2 changes: 1 addition & 1 deletion hack/docs/daytona_target-config.yaml
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ inherited_options:
usage: help for daytona
see_also:
- daytona - Daytona is a Dev Environment Manager
- daytona target-config add - Add target config
- daytona target-config list - List target configs
- daytona target-config remove - Remove target config
- daytona target-config set - Set target config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: daytona target-config set
synopsis: Set target config
usage: daytona target-config set [flags]
name: daytona target-config add
synopsis: Add target config
usage: daytona target-config add [flags]
inherited_options:
- name: help
default_value: "false"
2 changes: 1 addition & 1 deletion hack/docs/daytona_target-config_remove.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: daytona target-config remove
synopsis: Remove target config
usage: daytona target-config remove [CONFIG_NAME] [flags]
usage: daytona target-config remove [TARGET_CONFIG] [flags]
options:
- name: "yes"
shorthand: "y"
45 changes: 22 additions & 23 deletions internal/testing/server/targetconfigs/store.go
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@
package targetconfigs

import (
"fmt"

"github.com/daytonaio/daytona/pkg/models"
"github.com/daytonaio/daytona/pkg/stores"
)
@@ -22,12 +20,12 @@ func NewInMemoryTargetConfigStore() stores.TargetConfigStore {
}
}

func (s *InMemoryTargetConfigStore) List(filter *stores.TargetConfigFilter) ([]*models.TargetConfig, error) {
return s.processFilters(filter)
func (s *InMemoryTargetConfigStore) List(allowDeleted bool) ([]*models.TargetConfig, error) {
return s.processFilters("", allowDeleted)
}

func (s *InMemoryTargetConfigStore) Find(filter *stores.TargetConfigFilter) (*models.TargetConfig, error) {
targets, err := s.processFilters(filter)
func (s *InMemoryTargetConfigStore) Find(idOrName string, allowDeleted bool) (*models.TargetConfig, error) {
targets, err := s.processFilters(idOrName, allowDeleted)
if err != nil {
return nil, err
}
@@ -40,31 +38,32 @@ func (s *InMemoryTargetConfigStore) Find(filter *stores.TargetConfigFilter) (*mo
}

func (s *InMemoryTargetConfigStore) Save(targetConfig *models.TargetConfig) error {
s.targetConfigs[targetConfig.Name] = targetConfig
return nil
}

func (s *InMemoryTargetConfigStore) Delete(targetConfig *models.TargetConfig) error {
delete(s.targetConfigs, targetConfig.Name)
s.targetConfigs[targetConfig.Id] = targetConfig
return nil
}

func (s *InMemoryTargetConfigStore) processFilters(filter *stores.TargetConfigFilter) ([]*models.TargetConfig, error) {
func (s *InMemoryTargetConfigStore) processFilters(idOrName string, allowDeleted bool) ([]*models.TargetConfig, error) {
var result []*models.TargetConfig

if filter != nil {
if filter.Name != nil {
t, ok := s.targetConfigs[*filter.Name]
if ok {
return []*models.TargetConfig{t}, nil
} else {
return nil, fmt.Errorf("target config with id or name %s not found", *filter.Name)
}
if idOrName != "" {
t, ok := s.targetConfigs[idOrName]
if ok {
result = append(result, t)
}
} else {
for _, targetConfig := range s.targetConfigs {
result = append(result, targetConfig)
}
}

for _, targetConfig := range s.targetConfigs {
result = append(result, targetConfig)
if !allowDeleted {
notDeleted := []*models.TargetConfig{}
for _, targetConfig := range result {
if !targetConfig.Deleted {
notDeleted = append(notDeleted, targetConfig)
}
}
result = notDeleted
}

return result, nil
17 changes: 0 additions & 17 deletions internal/util/apiclient/conversion/target_config.go

This file was deleted.

11 changes: 9 additions & 2 deletions pkg/agent/agent_test.go
Original file line number Diff line number Diff line change
@@ -34,14 +34,21 @@ var workspace1 = &models.Workspace{
},
}

var target1 = &models.Target{
Id: "123",
var targetConfig1 = &models.TargetConfig{
Name: "test",
ProviderInfo: models.ProviderInfo{
Name: "test-provider",
Version: "test",
},
Options: "test-options",
Deleted: false,
}

var target1 = &models.Target{
Id: "123",
Name: "test",
TargetConfigId: targetConfig1.Id,
TargetConfig: *targetConfig1,
}

var gitStatus1 = &models.GitStatus{
6 changes: 3 additions & 3 deletions pkg/api/controllers/target/create.go
Original file line number Diff line number Diff line change
@@ -40,11 +40,11 @@ func CreateTarget(ctx *gin.Context) {
return
}

maskedOptions, err := util.GetMaskedOptions(server, t.ProviderInfo.Name, t.Options)
maskedOptions, err := util.GetMaskedOptions(server, t.TargetConfig.ProviderInfo.Name, t.TargetConfig.Options)
if err != nil {
t.Options = fmt.Sprintf("Error: %s", err.Error())
t.TargetConfig.Options = fmt.Sprintf("Error: %s", err.Error())
} else {
t.Options = maskedOptions
t.TargetConfig.Options = maskedOptions
}

ctx.JSON(200, t)
12 changes: 6 additions & 6 deletions pkg/api/controllers/target/target.go
Original file line number Diff line number Diff line change
@@ -54,11 +54,11 @@ func GetTarget(ctx *gin.Context) {
return
}

maskedOptions, err := util.GetMaskedOptions(server, t.ProviderInfo.Name, t.Options)
maskedOptions, err := util.GetMaskedOptions(server, t.TargetConfig.ProviderInfo.Name, t.TargetConfig.Options)
if err != nil {
t.Options = fmt.Sprintf("Error: %s", err.Error())
t.TargetConfig.Options = fmt.Sprintf("Error: %s", err.Error())
} else {
t.Options = maskedOptions
t.TargetConfig.Options = maskedOptions
}

util.HideDaytonaEnvVars(&t.EnvVars)
@@ -99,13 +99,13 @@ func ListTargets(ctx *gin.Context) {
}

for i, t := range targetList {
maskedOptions, err := util.GetMaskedOptions(server, t.ProviderInfo.Name, t.Options)
maskedOptions, err := util.GetMaskedOptions(server, t.TargetConfig.ProviderInfo.Name, t.TargetConfig.Options)
if err != nil {
targetList[i].Options = fmt.Sprintf("Error: %s", err.Error())
targetList[i].TargetConfig.Options = fmt.Sprintf("Error: %s", err.Error())
continue
}

targetList[i].Options = maskedOptions
targetList[i].TargetConfig.Options = maskedOptions
util.HideDaytonaEnvVars(&targetList[i].EnvVars)
}

Original file line number Diff line number Diff line change
@@ -7,25 +7,24 @@ import (
"fmt"
"net/http"

"github.com/daytonaio/daytona/internal/util/apiclient/conversion"
"github.com/daytonaio/daytona/pkg/api/util"
"github.com/daytonaio/daytona/pkg/server"
"github.com/daytonaio/daytona/pkg/server/targetconfigs/dto"
"github.com/daytonaio/daytona/pkg/services"
"github.com/gin-gonic/gin"
)

// SetTargetConfig godoc
// AddTargetConfig godoc
//
// @Tags target-config
// @Summary Set a target config
// @Description Set a target config
// @Param targetConfig body CreateTargetConfigDTO true "Target config to set"
// @Summary Add a target config
// @Description Add a target config
// @Param targetConfig body AddTargetConfigDTO true "Target config to add"
// @Success 200 {object} TargetConfig
// @Router /target-config [put]
//
// @id SetTargetConfig
func SetTargetConfig(ctx *gin.Context) {
var req dto.CreateTargetConfigDTO
// @id AddTargetConfig
func AddTargetConfig(ctx *gin.Context) {
var req services.AddTargetConfigDTO
err := ctx.BindJSON(&req)
if err != nil {
ctx.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid request body: %w", err))
@@ -34,9 +33,7 @@ func SetTargetConfig(ctx *gin.Context) {

server := server.GetInstance(nil)

targetConfig := conversion.ToTargetConfig(req)

err = server.TargetConfigService.Save(targetConfig)
targetConfig, err := server.TargetConfigService.Add(req)
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to set target config: %w", err))
return
2 changes: 1 addition & 1 deletion pkg/api/controllers/targetconfig/list.go
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ import (
func ListTargetConfigs(ctx *gin.Context) {
server := server.GetInstance(nil)

targetConfigs, err := server.TargetConfigService.List(nil)
targetConfigs, err := server.TargetConfigService.List()
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to list target configs: %w", err))
return
17 changes: 4 additions & 13 deletions pkg/api/controllers/targetconfig/remove.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
"net/http"

"github.com/daytonaio/daytona/pkg/server"
"github.com/daytonaio/daytona/pkg/stores"
"github.com/gin-gonic/gin"
)

@@ -17,25 +16,17 @@ import (
// @Tags target-config
// @Summary Remove a target config
// @Description Remove a target config
// @Param configName path string true "Target Config name"
// @Param configId path string true "Target Config Id"
// @Success 204
// @Router /target-config/{configName} [delete]
// @Router /target-config/{configId} [delete]
//
// @id RemoveTargetConfig
func RemoveTargetConfig(ctx *gin.Context) {
configName := ctx.Param("configName")
configId := ctx.Param("configId")

server := server.GetInstance(nil)

targetConfig, err := server.TargetConfigService.Find(&stores.TargetConfigFilter{
Name: &configName,
})
if err != nil {
ctx.AbortWithError(http.StatusNotFound, fmt.Errorf("failed to find target config: %w", err))
return
}

err = server.TargetConfigService.Delete(targetConfig)
err := server.TargetConfigService.Delete(configId)
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to remove target config: %w", err))
return
Loading