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

feat: multi-profile support for git providers(#777) #1032

Merged
merged 9 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 15 additions & 14 deletions docs/daytona_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ daytona create [REPOSITORY_URL | PROJECT_CONFIG_NAME]... [flags]
### Options

```
--blank Create a blank project without using existing configurations
--branch strings Specify the Git branches to use in the projects
--builder BuildChoice Specify the builder (currently auto/devcontainer/none)
--custom-image string Create the project with the custom image passed as the flag value; Requires setting --custom-image-user flag as well
--custom-image-user string Create the project with the custom image user passed as the flag value; Requires setting --custom-image flag as well
--devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value
--env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
-i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
--manual Manually enter the Git repository
--multi-project Workspace with multiple projects/repos
--name string Specify the workspace name
-n, --no-ide Do not open the workspace in the IDE after workspace creation
-t, --target string Specify the target (e.g. 'local')
-y, --yes Automatically confirm any prompts
--blank Create a blank project without using existing configurations
--branch strings Specify the Git branches to use in the projects
--builder BuildChoice Specify the builder (currently auto/devcontainer/none)
--custom-image string Create the project with the custom image passed as the flag value; Requires setting --custom-image-user flag as well
--custom-image-user string Create the project with the custom image user passed as the flag value; Requires setting --custom-image flag as well
--devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value
--env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
--git-provider-config-id string Specify the Git Provider Configuration Id
-i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
--manual Manually enter the Git repository
--multi-project Workspace with multiple projects/repos
--name string Specify the workspace name
-n, --no-ide Do not open the workspace in the IDE after workspace creation
-t, --target string Specify the target (e.g. 'local')
-y, --yes Automatically confirm any prompts
```

### Options inherited from parent commands
Expand Down
15 changes: 8 additions & 7 deletions docs/daytona_project-config_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ daytona project-config add [flags]
### Options

```
--builder BuildChoice Specify the builder (currently auto/devcontainer/none)
--custom-image string Create the project with the custom image passed as the flag value; Requires setting --custom-image-user flag as well
--custom-image-user string Create the project with the custom image user passed as the flag value; Requires setting --custom-image flag as well
--devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value
--env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
--manual Manually enter the Git repository
--name string Specify the project config name
--builder BuildChoice Specify the builder (currently auto/devcontainer/none)
--custom-image string Create the project with the custom image passed as the flag value; Requires setting --custom-image-user flag as well
--custom-image-user string Create the project with the custom image user passed as the flag value; Requires setting --custom-image flag as well
--devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value
--env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
--git-provider-config-id string Specify the Git Provider Configuration Id
--manual Manually enter the Git repository
--name string Specify the project config name
```

### Options inherited from parent commands
Expand Down
2 changes: 2 additions & 0 deletions hack/docs/daytona_create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ options:
default_value: '[]'
usage: |
Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
- name: git-provider-config-id
usage: Specify the Git Provider Configuration Id
- name: ide
shorthand: i
usage: |
Expand Down
2 changes: 2 additions & 0 deletions hack/docs/daytona_project-config_add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ options:
default_value: '[]'
usage: |
Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
- name: git-provider-config-id
usage: Specify the Git Provider Configuration Id
- name: manual
default_value: "false"
usage: Manually enter the Git repository
Expand Down
42 changes: 23 additions & 19 deletions internal/util/apiclient/conversion/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ func ToProject(projectDTO *apiclient.Project) *project.Project {
}

project := &project.Project{
Name: projectDTO.Name,
Image: projectDTO.Image,
User: projectDTO.User,
BuildConfig: projectBuild,
Repository: repository,
Target: projectDTO.Target,
WorkspaceId: projectDTO.WorkspaceId,
State: projectState,
Name: projectDTO.Name,
Image: projectDTO.Image,
User: projectDTO.User,
BuildConfig: projectBuild,
Repository: repository,
Target: projectDTO.Target,
WorkspaceId: projectDTO.WorkspaceId,
State: projectState,
GitProviderConfigId: projectDTO.GitProviderConfigId,
}

if projectDTO.Repository.PrNumber != nil {
Expand Down Expand Up @@ -148,9 +149,10 @@ func ToGitStatusDTO(gitStatus *project.GitStatus) *apiclient.GitStatus {

func ToProjectConfig(createProjectConfigDto pc_dto.CreateProjectConfigDTO) *config.ProjectConfig {
result := &config.ProjectConfig{
Name: createProjectConfigDto.Name,
BuildConfig: createProjectConfigDto.BuildConfig,
EnvVars: createProjectConfigDto.EnvVars,
Name: createProjectConfigDto.Name,
BuildConfig: createProjectConfigDto.BuildConfig,
EnvVars: createProjectConfigDto.EnvVars,
GitProviderConfigId: createProjectConfigDto.GitProviderConfigId,
}

result.RepositoryUrl = createProjectConfigDto.RepositoryUrl
Expand All @@ -168,10 +170,11 @@ func ToProjectConfig(createProjectConfigDto pc_dto.CreateProjectConfigDTO) *conf

func CreateDtoToProject(createProjectDto project_dto.CreateProjectDTO) *project.Project {
p := &project.Project{
Name: createProjectDto.Name,
BuildConfig: createProjectDto.BuildConfig,
Repository: createProjectDto.Source.Repository,
EnvVars: createProjectDto.EnvVars,
Name: createProjectDto.Name,
BuildConfig: createProjectDto.BuildConfig,
Repository: createProjectDto.Source.Repository,
EnvVars: createProjectDto.EnvVars,
GitProviderConfigId: createProjectDto.GitProviderConfigId,
}

if createProjectDto.Image != nil {
Expand All @@ -187,10 +190,11 @@ func CreateDtoToProject(createProjectDto project_dto.CreateProjectDTO) *project.

func CreateConfigDtoToProject(createProjectConfigDto pc_dto.CreateProjectConfigDTO) *project.Project {
return &project.Project{
Name: createProjectConfigDto.Name,
Image: *createProjectConfigDto.Image,
User: *createProjectConfigDto.User,
BuildConfig: createProjectConfigDto.BuildConfig,
Name: createProjectConfigDto.Name,
Image: *createProjectConfigDto.Image,
User: *createProjectConfigDto.User,
BuildConfig: createProjectConfigDto.BuildConfig,
GitProviderConfigId: createProjectConfigDto.GitProviderConfigId,
Repository: &gitprovider.GitRepository{
Url: createProjectConfigDto.RepositoryUrl,
},
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/controllers/gitprovider/dto/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ type RepositoryUrl struct {
} // @name RepositoryUrl

type SetGitProviderConfig struct {
Id string `json:"id" validate:"required"`
Username *string `json:"username" validate:"optional"`
Id string `json:"id" validate:"optional"`
ProviderId string `json:"providerId" validate:"required"`
Username *string `json:"username,omitempty" validate:"optional"`
Token string `json:"token" validate:"required"`
BaseApiUrl *string `json:"baseApiUrl,omitempty" validate:"optional"`
Alias *string `json:"alias,omitempty" validate:"optional"`
} // @name SetGitProviderConfig
5 changes: 5 additions & 0 deletions pkg/api/controllers/gitprovider/gitprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func SetGitProvider(ctx *gin.Context) {

gitProviderConfig := gitprovider.GitProviderConfig{
Id: setConfigDto.Id,
ProviderId: setConfigDto.ProviderId,
Token: setConfigDto.Token,
BaseApiUrl: setConfigDto.BaseApiUrl,
}
Expand All @@ -141,6 +142,10 @@ func SetGitProvider(ctx *gin.Context) {
gitProviderConfig.Username = *setConfigDto.Username
}

if setConfigDto.Alias != nil {
gitProviderConfig.Alias = *setConfigDto.Alias
}

server := server.GetInstance(nil)

err = server.GitProviderService.SetGitProviderConfig(&gitProviderConfig)
Expand Down
28 changes: 27 additions & 1 deletion pkg/api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,9 @@ const docTemplate = `{
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -1997,6 +2000,9 @@ const docTemplate = `{
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -2169,17 +2175,25 @@ const docTemplate = `{
"GitProvider": {
"type": "object",
"required": [
"alias",
"id",
"providerId",
"token",
"username"
],
"properties": {
"alias": {
"type": "string"
},
"baseApiUrl": {
"type": "string"
},
"id": {
"type": "string"
},
"providerId": {
"type": "string"
},
"token": {
"type": "string"
},
Expand Down Expand Up @@ -2443,6 +2457,9 @@ const docTemplate = `{
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -2489,6 +2506,9 @@ const docTemplate = `{
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -2700,16 +2720,22 @@ const docTemplate = `{
"SetGitProviderConfig": {
"type": "object",
"required": [
"id",
"providerId",
"token"
],
"properties": {
"alias": {
"type": "string"
},
"baseApiUrl": {
"type": "string"
},
"id": {
"type": "string"
},
"providerId": {
"type": "string"
},
"token": {
"type": "string"
},
Expand Down
28 changes: 27 additions & 1 deletion pkg/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,9 @@
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -1994,6 +1997,9 @@
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -2166,17 +2172,25 @@
"GitProvider": {
"type": "object",
"required": [
"alias",
"id",
"providerId",
"token",
"username"
],
"properties": {
"alias": {
"type": "string"
},
"baseApiUrl": {
"type": "string"
},
"id": {
"type": "string"
},
"providerId": {
"type": "string"
},
"token": {
"type": "string"
},
Expand Down Expand Up @@ -2440,6 +2454,9 @@
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -2486,6 +2503,9 @@
"type": "string"
}
},
"gitProviderConfigId": {
"type": "string"
},
"image": {
"type": "string"
},
Expand Down Expand Up @@ -2697,16 +2717,22 @@
"SetGitProviderConfig": {
"type": "object",
"required": [
"id",
"providerId",
"token"
],
"properties": {
"alias": {
"type": "string"
},
"baseApiUrl": {
"type": "string"
},
"id": {
"type": "string"
},
"providerId": {
"type": "string"
},
"token": {
"type": "string"
},
Expand Down
Loading
Loading