Skip to content

Commit

Permalink
Merge branch 'daytonaio:main' into option-ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
divanshu-go authored Oct 21, 2024
2 parents 86a2d8d + b8f214f commit 56e72be
Show file tree
Hide file tree
Showing 72 changed files with 2,238 additions and 180 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Trigger External Workflow on Release

on:
release:
types: [published]

jobs:
trigger-external-workflow:
runs-on: ubuntu-latest
steps:
- name: Trigger release workflow
if: github.event.release.prerelease == false
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GITHUBBOT_TOKEN }}
repository: daytonaio/daytona-release
event-type: new-release
client-payload: '{"release_tag": "${{ github.event.release.tag_name }}"}'

- name: Trigger prerelease workflow
if: github.event.release.prerelease == true
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GITHUBBOT_TOKEN }}
repository: daytonaio/daytona-release
event-type: new-prerelease
client-payload: '{"prerelease_tag": "${{ github.event.release.tag_name }}"}'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Set up a development environment on any infrastructure, with a single command.
* __Configuration File Support__: Initially support for [dev container](https://containers.dev/), ability to expand to DevFile, Nix & Flox (Contributions welcome here!).
* __Prebuilds System__: Drastically improve environment setup times (Contributions welcome here!).
* __IDE Support__ : Seamlessly supports [VS Code](https://github.com/microsoft/vscode) & [JetBrains](https://www.jetbrains.com/remote-development/gateway/) locally, ready to use without configuration. Includes a built-in Web IDE for added convenience.
* __Git Provider Integration__: GitHub, GitLab, Bitbucket, Bitbucket Server, Gitea, Gitness, Azure DevOps & AWS CodeCommit can be connected, allowing easy repo branch or PR pull and commit back from the workspaces.
* __Git Provider Integration__: GitHub, GitLab, Bitbucket, Bitbucket Server, Gitea, Gitness, Azure DevOps, AWS CodeCommit & Gogs can be connected, allowing easy repo branch or PR pull and commit back from the workspaces.
* __Multiple Project Workspace__: Support for multiple project repositories in the same workspace, making it easy to develop using a micro-service architecture.
* __Reverse Proxy Integration__: Enable collaboration and streamline feedback loops by leveraging reverse proxy functionality. Access preview ports and the Web IDE seamlessly, even behind firewalls.
* __Extensibility__: Enable extensibility with plugin or provider development. Moreover, in any dynamic language, not just Go(Contributions welcome here!).
Expand Down Expand Up @@ -165,7 +165,7 @@ This initiates the Daytona Server in daemon mode. Use the command:
daytona server
```
__2. Add Your Git Provider of Choice:__
Daytona supports GitHub, GitLab, Bitbucket, Bitbucket Server, Gitea, Gitness, AWS CodeCommit and Azure DevOps. To add them to your profile, use the command:
Daytona supports GitHub, GitLab, Bitbucket, Bitbucket Server, Gitea, Gitness, AWS CodeCommit, Azure DevOps and Gogs. To add them to your profile, use the command:
```bash
daytona git-providers add
Expand Down
7 changes: 7 additions & 0 deletions cmd/daytona/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func GetSupportedGitProviders() []GitProvider {
{"gitness", "Gitness"},
{"azure-devops", "Azure DevOps"},
{"aws-codecommit", "AWS CodeCommit"},
{"gogs", "Gogs"},
}
}

Expand Down Expand Up @@ -84,6 +85,8 @@ func GetDocsLinkFromGitProvider(providerId string) string {
return "https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows#create-a-pat"
case "aws-codecommit":
return "https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html and to configure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY & AWS_DEFAULT_REGION read https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html"
case "gogs":
return "https://www.daytona.io/docs/configuration/git-providers/#gogs"
default:
return ""
}
Expand Down Expand Up @@ -130,6 +133,8 @@ func GetRequiredScopesFromGitProviderId(providerId string) string {
return "Code (Status, Read & Write); User Profile (Read); Project and Team (Read)"
case "aws-codecommit":
return "/"
case "gogs":
fallthrough
default:
return ""
}
Expand Down Expand Up @@ -164,6 +169,8 @@ func GetWebhookEventHeaderKeyFromGitProvider(providerId string) string {
return "X-Gitea-Event"
case "azure-devops":
return "X-AzureDevops-Event"
case "gitness":
return "X-Gitness-Trigger"
default:
return ""
}
Expand Down
1 change: 1 addition & 0 deletions docs/daytona_git-providers_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ daytona git-providers delete [flags]

```
-a, --all Remove all Git providers
-y, --yes Confirm deletion without prompt
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/daytona_target.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Manage provider targets
* [daytona target list](daytona_target_list.md) - List targets
* [daytona target remove](daytona_target_remove.md) - Remove target
* [daytona target set](daytona_target_set.md) - Set provider target
* [daytona target set-default](daytona_target_set-default.md) - Set target to be used by default

18 changes: 18 additions & 0 deletions docs/daytona_target_set-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## daytona target set-default

Set target to be used by default

```
daytona target set-default [TARGET_NAME] [flags]
```

### Options inherited from parent commands

```
--help help for daytona
```

### SEE ALSO

* [daytona target](daytona_target.md) - Manage provider targets

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/go-git/go-git/v5 v5.12.1-0.20240617075238-c127d1b35535
github.com/go-playground/validator/v10 v10.19.0
github.com/go-playground/webhooks/v6 v6.4.0
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.1
github.com/hashicorp/go-hclog v1.6.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85 h1:UjoPNDAQ5JPCjlxoJd6K8ALZqSDDhk2ymieAZOVaDg0=
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85/go.mod h1:fR6z1Ie6rtF7kl/vBYMfgD5/G5B1blui7z426/sj2DU=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
Expand Down
4 changes: 4 additions & 0 deletions hack/docs/daytona_git-providers_delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ options:
shorthand: a
default_value: "false"
usage: Remove all Git providers
- name: "yes"
shorthand: "y"
default_value: "false"
usage: Confirm deletion without prompt
inherited_options:
- name: help
default_value: "false"
Expand Down
1 change: 1 addition & 0 deletions hack/docs/daytona_target.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ see_also:
- daytona target list - List targets
- daytona target remove - Remove target
- daytona target set - Set provider target
- daytona target set-default - Set target to be used by default
9 changes: 9 additions & 0 deletions hack/docs/daytona_target_set-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: daytona target set-default
synopsis: Set target to be used by default
usage: daytona target set-default [TARGET_NAME] [flags]
inherited_options:
- name: help
default_value: "false"
usage: help for daytona
see_also:
- daytona target - Manage provider targets
54 changes: 43 additions & 11 deletions internal/testing/provider/targets/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package targets

import (
"fmt"

"github.com/daytonaio/daytona/pkg/provider"
)

Expand All @@ -19,22 +21,20 @@ func NewInMemoryTargetStore() provider.TargetStore {
}
}

func (s *InMemoryTargetStore) List() ([]*provider.ProviderTarget, error) {
targets := []*provider.ProviderTarget{}
for _, t := range s.targets {
targets = append(targets, t)
}

return targets, nil
func (s *InMemoryTargetStore) List(filter *provider.TargetFilter) ([]*provider.ProviderTarget, error) {
return s.processFilters(filter)
}

func (s *InMemoryTargetStore) Find(targetName string) (*provider.ProviderTarget, error) {
target, ok := s.targets[targetName]
if !ok {
func (s *InMemoryTargetStore) Find(filter *provider.TargetFilter) (*provider.ProviderTarget, error) {
targets, err := s.processFilters(filter)
if err != nil {
return nil, err
}
if len(targets) == 0 {
return nil, provider.ErrTargetNotFound
}

return target, nil
return targets[0], nil
}

func (s *InMemoryTargetStore) Save(target *provider.ProviderTarget) error {
Expand All @@ -46,3 +46,35 @@ func (s *InMemoryTargetStore) Delete(target *provider.ProviderTarget) error {
delete(s.targets, target.Name)
return nil
}

func (s *InMemoryTargetStore) processFilters(filter *provider.TargetFilter) ([]*provider.ProviderTarget, error) {
var result []*provider.ProviderTarget
filteredTargets := make(map[string]*provider.ProviderTarget)
for k, v := range s.targets {
filteredTargets[k] = v
}

if filter != nil {
if filter.Name != nil {
target, ok := s.targets[*filter.Name]
if ok {
return []*provider.ProviderTarget{target}, nil
} else {
return []*provider.ProviderTarget{}, fmt.Errorf("target with name %s not found", *filter.Name)
}
}
if filter.Default != nil {
for _, target := range filteredTargets {
if target.IsDefault != *filter.Default {
delete(filteredTargets, target.Name)
}
}
}
}

for _, target := range filteredTargets {
result = append(result, target)
}

return result, nil
}
17 changes: 17 additions & 0 deletions internal/util/apiclient/conversion/target.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 Daytona Platforms Inc.
// SPDX-License-Identifier: Apache-2.0

package conversion

import (
"github.com/daytonaio/daytona/pkg/provider"
"github.com/daytonaio/daytona/pkg/server/providertargets/dto"
)

func ToProviderTarget(createProviderTargetDto dto.CreateProviderTargetDTO) *provider.ProviderTarget {
return &provider.ProviderTarget{
Name: createProviderTargetDto.Name,
ProviderInfo: createProviderTargetDto.ProviderInfo,
Options: createProviderTargetDto.Options,
}
}
2 changes: 1 addition & 1 deletion pkg/api/controllers/target/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
func ListTargets(ctx *gin.Context) {
server := server.GetInstance(nil)

targets, err := server.ProviderTargetService.List()
targets, err := server.ProviderTargetService.List(nil)
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to list targets: %w", err))
return
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/controllers/target/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/http"

"github.com/daytonaio/daytona/pkg/provider"
"github.com/daytonaio/daytona/pkg/server"
"github.com/gin-gonic/gin"
)
Expand All @@ -26,7 +27,9 @@ func RemoveTarget(ctx *gin.Context) {

server := server.GetInstance(nil)

target, err := server.ProviderTargetService.Find(targetName)
target, err := server.ProviderTargetService.Find(&provider.TargetFilter{
Name: &targetName,
})
if err != nil {
ctx.AbortWithError(http.StatusNotFound, fmt.Errorf("failed to find target: %w", err))
return
Expand Down
46 changes: 37 additions & 9 deletions pkg/api/controllers/target/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"fmt"
"net/http"

"github.com/daytonaio/daytona/internal/util/apiclient/conversion"
"github.com/daytonaio/daytona/pkg/provider"
"github.com/daytonaio/daytona/pkg/server"
"github.com/daytonaio/daytona/pkg/server/providertargets/dto"
"github.com/gin-gonic/gin"
)

Expand All @@ -17,13 +19,13 @@ import (
// @Tags target
// @Summary Set a target
// @Description Set a target
// @Param target body ProviderTarget true "Target to set"
// @Param target body CreateProviderTargetDTO true "Target to set"
// @Success 201
// @Router /target [put]
//
// @id SetTarget
func SetTarget(ctx *gin.Context) {
var req provider.ProviderTarget
var req dto.CreateProviderTargetDTO
err := ctx.BindJSON(&req)
if err != nil {
ctx.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid request body: %w", err))
Expand All @@ -32,13 +34,7 @@ func SetTarget(ctx *gin.Context) {

server := server.GetInstance(nil)

target, err := server.ProviderTargetService.Find(req.Name)
if err == nil {
target.Options = req.Options
target.ProviderInfo = req.ProviderInfo
} else {
target = &req
}
target := conversion.ToProviderTarget(req)

err = server.ProviderTargetService.Save(target)
if err != nil {
Expand All @@ -48,3 +44,35 @@ func SetTarget(ctx *gin.Context) {

ctx.Status(201)
}

// SetDefaultTarget godoc
//
// @Tags target
// @Summary Set target to default
// @Description Set target to default
// @Param target path string true "Target name"
// @Success 200
// @Router /target/{target}/set-default [patch]
//
// @id SetDefaultTarget
func SetDefaultTarget(ctx *gin.Context) {
targetName := ctx.Param("target")

server := server.GetInstance(nil)

target, err := server.ProviderTargetService.Find(&provider.TargetFilter{
Name: &targetName,
})
if err != nil {
ctx.AbortWithError(http.StatusNotFound, fmt.Errorf("failed to find target: %w", err))
return
}

err = server.ProviderTargetService.SetDefault(target)
if err != nil {
ctx.AbortWithError(http.StatusNotFound, fmt.Errorf("failed to set project config to default: %s", err.Error()))
return
}

ctx.Status(200)
}
Loading

0 comments on commit 56e72be

Please sign in to comment.