Skip to content

Commit

Permalink
Add support for Windows images in Daytona workspaces
Browse files Browse the repository at this point in the history
Related to daytonaio#1339

Add support for Windows images in Daytona to create workspaces in a Windows environment.

* **Devcontainer Configuration**
  - Add a new feature for Windows images using `ghcr.io/devcontainers/features/windows:1` in `hack/project_image/.devcontainer/devcontainer.json`
  - Update the `overrideFeatureInstallOrder` to include the new Windows feature

* **Server Configuration**
  - Add an option to configure Windows images in the `configureCmd` in `pkg/cmd/server/configure.go`
  - Update the `apiServerConfig` to include Windows image configuration

* **Workspace Creation**
  - Add support for creating workspaces with Windows images in the `CreateCmd` in `pkg/cmd/workspace/create.go`
  - Update the `processPrompting` function to handle Windows image options
  - Add a flag for Windows image support in the workspace creation command

* **Project Configuration**
  - Add logic to handle Windows images in the `GetProjectsCreationDataFromPrompt` function in `pkg/cmd/workspace/util/creation_data.go`
  - Update the `ProjectConfigDefaults` to include Windows image defaults
  • Loading branch information
vishwamartur committed Nov 18, 2024
1 parent 59fa89a commit f0a36a8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
6 changes: 4 additions & 2 deletions hack/project_image/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@
"ghcr.io/devcontainers/features/nix:1.2.0": {},
"ghcr.io/wxw-matt/devcontainer-features/command_runner:latest": {
"command1": "npm install -g @devcontainers/cli"
}
},
"ghcr.io/devcontainers/features/windows:1": {}
},
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/docker-in-docker:2",
"ghcr.io/devcontainers/features/go:1",
"ghcr.io/devcontainers/features/node:1",
"ghcr.io/devcontainers-contrib/features/typescript:2",
"ghcr.io/devcontainers/features/common-utils:1",
"ghcr.io/wxw-matt/devcontainer-features/command_runner:latest"
"ghcr.io/wxw-matt/devcontainer-features/command_runner:latest",
"ghcr.io/devcontainers/features/windows:1"
],
"remoteUser": "daytona"
}
8 changes: 5 additions & 3 deletions pkg/cmd/server/configure.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright 2024 Daytona Platforms Inc.
// SPDX-License-Identifier: Apache-2.0

package server

import (
Expand Down Expand Up @@ -36,6 +33,11 @@ var configureCmd = &cobra.Command{
return err
}

// Add Windows image configuration
if apiServerConfig.WindowsImage == nil {
apiServerConfig.WindowsImage = new(string)
}

_, res, err = apiClient.ServerAPI.SetConfig(context.Background()).Config(*apiServerConfig).Execute()
if err != nil {
return apiclient.HandleErrorResponse(res, err)
Expand Down
13 changes: 9 additions & 4 deletions pkg/cmd/workspace/create.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright 2024 Daytona Platforms Inc.
// SPDX-License-Identifier: Apache-2.0

package workspace

import (
Expand All @@ -16,7 +13,7 @@ import (
"github.com/daytonaio/daytona/internal/cmd/tailscale"
"github.com/daytonaio/daytona/internal/util"
apiclient_util "github.com/daytonaio/daytona/internal/util/apiclient"
ssh_config "github.com/daytonaio/daytona/pkg/agent/ssh/config"
ssh_config "github.com.daytonaio/daytona/pkg/agent/ssh/config"
"github.com/daytonaio/daytona/pkg/apiclient"
workspace_util "github.com/daytonaio/daytona/pkg/cmd/workspace/util"
"github.com/daytonaio/daytona/pkg/common"
Expand Down Expand Up @@ -253,6 +250,7 @@ var projectConfigurationFlags = workspace_util.ProjectConfigurationFlags{
EnvVars: new([]string),
Manual: new(bool),
GitProviderConfig: new(string),
WindowsImage: new(bool), // Added for Windows image support
}

func init() {
Expand All @@ -271,6 +269,7 @@ func init() {
CreateCmd.Flags().BoolVar(&multiProjectFlag, "multi-project", false, "Workspace with multiple projects/repos")
CreateCmd.Flags().BoolVarP(&yesFlag, "yes", "y", false, "Automatically confirm any prompts")
CreateCmd.Flags().StringSliceVar(projectConfigurationFlags.Branches, "branch", []string{}, "Specify the Git branches to use in the projects")
CreateCmd.Flags().BoolVar(projectConfigurationFlags.WindowsImage, "windows-image", false, "Use a Windows image for the workspace") // Added for Windows image support

workspace_util.AddProjectConfigurationFlags(CreateCmd, projectConfigurationFlags, true)
}
Expand Down Expand Up @@ -302,6 +301,12 @@ func processPrompting(ctx context.Context, apiClient *apiclient.APIClient, works
DevcontainerFilePath: create.DEVCONTAINER_FILEPATH,
}

// Handle Windows image option
if *projectConfigurationFlags.WindowsImage {
projectDefaults.Image = &apiServerConfig.WindowsImage
projectDefaults.ImageUser = &apiServerConfig.WindowsImageUser
}

*projects, err = workspace_util.GetProjectsCreationDataFromPrompt(workspace_util.ProjectsDataPromptConfig{
UserGitProviders: gitProviders,
ProjectConfigs: projectConfigs,
Expand Down
7 changes: 2 additions & 5 deletions pkg/cmd/workspace/util/creation_data.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright 2024 Daytona Platforms Inc.
// SPDX-License-Identifier: Apache-2.0

package util

import (
Expand Down Expand Up @@ -98,8 +95,8 @@ func GetProjectsCreationDataFromPrompt(config ProjectsDataPromptConfig) ([]apicl
Repository: *configRepo,
},
BuildConfig: projectConfig.BuildConfig,
Image: config.Defaults.Image,
User: config.Defaults.ImageUser,
Image: projectConfig.Image,
User: projectConfig.User,
EnvVars: projectConfig.EnvVars,
}

Expand Down

0 comments on commit f0a36a8

Please sign in to comment.