Skip to content
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
31 changes: 2 additions & 29 deletions compose.dang
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,13 @@ type Compose {
prefix marks an enclosing project.
"""
pub projects(ws: Workspace!): [ComposeProject!]! {
polyfill
.workspace(ws)
.findConfigDirs(configNames)
ws
.findRoots(markers: configNames)
.map { projectPath =>
ComposeProject(path: projectPath, composeImage: composeImage, configNames: configNames)
}
}


"""
Return the number of path segments of a workspace-root-absolute file path.
"""
let depth(filePath: String!): Int! {
filePath.trimPrefix("/").split("/").length
}

"""
Return the directory of a workspace-root-absolute file path, relative to the
client's cwd: "/a/b/compose.yaml" from cwd "a" is "b", from "a/b/c" is "..".
"""
let relativeToCwd(ws: Workspace!, filePath: String!): String! {
let dirSegments = filePath.trimPrefix("/").split("/").dropLast(1)
let cwdSegments = ws.path.trimPrefix("/").split("/").filter { segment =>
segment != "" and segment != "."
}
# Longest common prefix: acc only advances while every prior segment matched.
let common = cwdSegments.map { segment, i => i }.reduce(0) { acc, i =>
if (acc == i and dirSegments[i] == cwdSegments[i]) { acc + 1 } else { acc }
}
let segments = cwdSegments.dropFirst(common).map { segment => ".." } +
dirSegments.dropFirst(common)
if (segments.length == 0) { "." } else { segments.join("/") }
}

"""
Run the services of the Compose project detected from the client's cwd,
proxied through a single service with one frontend port per compose service.
Expand Down
12 changes: 4 additions & 8 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"name": "docker",
"engineVersion": "v0.20.6",
"engineVersion": "v1.0.0-beta.10",
"sdk": {
"source": "dang"
},
"dependencies": [
{
"name": "polyfill",
"source": "github.com/dagger/polyfill@main",
"pin": "ec3ea84a2351b4beb06ecece951f2e5ef66509ff"
},
{
"name": "proxy",
"source": "./proxy"
"source": "https://github.com/dagger/proxy@main",
"pin": "3224e8981d8c8f04a0c238dc933b7415a2a6349f"
}
]
}
}
7 changes: 3 additions & 4 deletions docker.dang
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ type Docker {
marks an enclosing project.
"""
pub projects(ws: Workspace!): [DockerProject!]! {
polyfill
.workspace(ws)
.findConfigDirs(["Dockerfile"])
ws
.findRoots(markers: ["Dockerfile"])
.map { projectPath =>
DockerProject(path: projectPath, lintImage: lintImage)
}
Expand Down Expand Up @@ -53,7 +52,7 @@ type Docker {
"""
let relativeToCwd(ws: Workspace!, filePath: String!): String! {
let dirSegments = filePath.trimPrefix("/").split("/").dropLast(1)
let cwdSegments = ws.path.trimPrefix("/").split("/").filter { segment =>
let cwdSegments = ws.cwd.trimPrefix("/").split("/").filter { segment =>
segment != "" and segment != "."
}
# Longest common prefix: acc only advances while every prior segment matched.
Expand Down