Skip to content

Commit

Permalink
Switch label to use "metadata" instead of "json", fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuxel authored Jun 17, 2022
1 parent e022036 commit c177c7a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The Buildpacks are written in Go and take advantage of [libcnb](https://pkg.go.d

4. The buildpacks can optionally place a `devcontainer.json` snippet file in their layers and add the path to it in a common `FINALIZE_JSON_SEARCH_PATH` build-time environment variable for the layer. These devcontainer.json files can include tooling settings, runtime settings like adding capabilities (e.g. ptrace or privileged), or even lifecycle commands. They're only added in devcontainer mode.

5. A `finalize` buildpack merges all devcontainer.json snippets from the `FINALIZE_JSON_SEARCH_PATH` and adds a `dev.containers.json` label on the image with their contents.
5. A `finalize` buildpack merges all devcontainer.json snippets from the `FINALIZE_JSON_SEARCH_PATH` and adds a `dev.containers.metadata` label on the image with their contents.

6. The `finalize` buildpack also removes the source code since this is expected to be mounted into the container when the image is used. As a result, `finalize` will fail detection in production mode and is last in the ordering in the devcontainer builder. It also overrides the default launch step to one that sleeps infinitely to prevent it from shutting down (though this last part is technically optional).

Expand Down
4 changes: 2 additions & 2 deletions devpacks/internal/common/devcontainer/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package devcontainer
const DEFAULT_CONTAINER_IMAGE_BUILD_MODE = "production"

// Label and metadata keys
const METADATA_ID_PREFIX = "dev.container"
const DEVCONTAINER_JSON_LABEL_NAME = METADATA_ID_PREFIX + ".json"
const METADATA_ID_PREFIX = "dev.containers"
const DEVCONTAINER_JSON_LABEL_NAME = METADATA_ID_PREFIX + ".metadata"

// ENV variables
const CONTAINER_IMAGE_BUILD_MODE_ENV_VAR_NAME = "BP_DCNB_BUILD_MODE"
Expand Down
8 changes: 4 additions & 4 deletions devpacks/internal/common/devcontainer/devcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,27 @@ func (devContainer *DevContainer) ConvertUnsupportedPropertiesToRunArgs() {

if _, hasKey := devContainer.Properties["privileged"]; hasKey {
runArgs = utils.AddToSliceIfUnique(runArgs, "--privileged")
devContainer.Properties["privileged"] = nil
delete(devContainer.Properties, "privileged")
}

if _, hasKey := devContainer.Properties["init"]; hasKey {
runArgs = utils.AddToSliceIfUnique(runArgs, "--init")
devContainer.Properties["init"] = nil
delete(devContainer.Properties, "init")
}

if inter, hasKey := devContainer.Properties["capAdd"]; hasKey {
capAdd := utils.InterfaceToStringSlice(inter)
for _, cap := range capAdd {
runArgs = utils.AddToSliceIfUnique(runArgs, "--cap-add="+cap)
devContainer.Properties["capAdd"] = nil
delete(devContainer.Properties, "capAdd")
}
}

if inter, hasKey := devContainer.Properties["securityOpt"]; hasKey {
capAdd := utils.InterfaceToStringSlice(inter)
for _, cap := range capAdd {
runArgs = utils.AddToSliceIfUnique(runArgs, "--security-op="+cap)
devContainer.Properties["securityOpt"] = nil
delete(devContainer.Properties, "securityOpt")
}
}

Expand Down

0 comments on commit c177c7a

Please sign in to comment.