Skip to content

Commit

Permalink
Fix whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bkneis authored and pascalbreuninger committed Jan 9, 2025
1 parent f9147bd commit dda1a05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import { TWorkspaceSourceType } from "@/types"

// WARN: Make sure these match the regexes in /pkg/git/git.go
const GIT_REPOSITORY_PATTERN =
"((?:(?:https?|git|ssh|file):\/\/)?\/?(?:[^@\/\n]+@)?(?:[^:\/\n]+)(?:[:\/][^\/\n]+)+(?:\.git)?)"
"((?:(?:https?|git|ssh)://)?(?:[^@/\\n]+@)?(?:[^:/\\n]+)(?:[:/][^/\\n]+)+(?:\\.git)?)"
const GIT_REPOSITORY_REGEX = new RegExp(GIT_REPOSITORY_PATTERN)
const BRANCH_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}(?:@([a-zA-Z0-9\./\-\_]+))?$`)
const BRANCH_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@([a-zA-Z0-9\\./\\-\\_]+)$`)
const COMMIT_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@sha256:([a-zA-Z0-9]+)$`)
const PR_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@pull\\/([0-9]+)\\/head$`)
const SUBPATH_REGEX = new RegExp(`^${GIT_REPOSITORY_PATTERN}@subpath:([a-zA-Z0-9\\./\\-\\_]+)$`)
Expand Down
7 changes: 7 additions & 0 deletions pkg/devcontainer/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,12 @@ func (r *runner) buildAndExtendDockerCompose(
} else {
dockerFilePath = filepath.Join(composeService.Build.Context, composeService.Build.Dockerfile)
}

originalDockerfile, err := os.ReadFile(dockerFilePath)
if err != nil {
return "", "", nil, "", err
}

// Determine build target, if a multi stage build ensure it is valid and modify the Dockerfile if necessary
originalTarget := composeService.Build.Target
if originalTarget != "" {
Expand All @@ -439,6 +441,7 @@ func (r *runner) buildAndExtendDockerCompose(
if err != nil {
return "", "", nil, "", err
}

buildTarget = lastStageName
// Override Dockerfile if it was modified, otherwise use the original
if modifiedDockerfile != "" {
Expand Down Expand Up @@ -468,6 +471,7 @@ func (r *runner) buildAndExtendDockerCompose(
if dockerfileContents == "" {
dockerfileContents = fmt.Sprintf("FROM %s AS %s\n", composeService.Image, buildTarget)
}

// Write the final Dockerfile with features
extendedDockerfilePath, extendedDockerfileContent := r.extendedDockerfile(
extendImageBuildInfo.FeaturesBuildInfo,
Expand All @@ -486,6 +490,7 @@ func (r *runner) buildAndExtendDockerCompose(
if err != nil {
return "", "", nil, "", errors.Wrap(err, "write Dockerfile with features")
}

// Write the final docker-compose referencing the modified Dockerfile or Image
dockerComposeFilePath, err = r.extendedDockerComposeBuild(
composeService,
Expand All @@ -496,6 +501,7 @@ func (r *runner) buildAndExtendDockerCompose(
return buildImageName, "", nil, "", err
}
}

// Prepare the docker-compose build arguments
buildArgs := []string{"--project-name", project.Name}
buildArgs = append(buildArgs, globalArgs...)
Expand All @@ -506,6 +512,7 @@ func (r *runner) buildAndExtendDockerCompose(
if extendImageBuildInfo == nil {
buildArgs = append(buildArgs, "--pull")
}

// Only run the services defined in .devcontainer.json runServices
if len(parsedConfig.Config.RunServices) > 0 {
buildArgs = append(buildArgs, composeService.Name)
Expand Down

0 comments on commit dda1a05

Please sign in to comment.