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
27 changes: 4 additions & 23 deletions future/helper-cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,29 +274,10 @@ Function surface:
dagger functions --progress=plain
```

Init generation smoke, from a git-initialized empty repo:
Init generation smoke, from a git-initialized empty repo using a Dagger CLI
with positional SDK init:

```sh
dagger -m /path/to/go-sdk call init --name foo added-paths
dagger -m /path/to/go-sdk call init --name foo --path ./foo/bar added-paths
```

Local dependency add/remove smoke:

```sh
dagger -m /path/to/go-sdk call mod --path app deps add --source ../lib --name lib modified-paths
dagger -m /path/to/go-sdk call mod --path app deps remove --name lib modified-paths
```

Dependency update smoke:

```sh
dagger -m /path/to/go-sdk call mod --path app deps update modified-paths
```

Named local dependency update should still fail with core's unsupported-local
message:

```sh
dagger -m /path/to/go-sdk call mod --path app deps update --name lib modified-paths
dagger sdk install /path/to/go-sdk --name go
dagger module init go foo --auto-apply
```
53 changes: 16 additions & 37 deletions go-sdk.dang
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ type GoSdk {
pub skipGenerateFilename: String! = ".dagger-go-sdk-skip-generate"

"""
Return every Dagger module whose sdk.source is "go".
Runtime source to write into modules created by this SDK.
"""
pub targetRuntime: String! { "go" }

"""
Return every legacy dagger.json Dagger module whose sdk.source is "go".
"""
pub modules(ws: Workspace!): [Mod!]! {
ws
Expand Down Expand Up @@ -99,35 +104,13 @@ type GoSdk {
}

"""
Create a new Go SDK Dagger module and return the files to write.

By default, the new module is created under the nearest `.dagger` directory
visible from the current workspace path:

<nearest .dagger>/modules/<name>

Pass `path` to choose a different module location. The target path must not
already contain a Dagger module.
Initialize Go-owned files for a new Dagger module.

Pass `template` to materialize files from templates/<template>. The empty
default uses this module's minimal template.

By default, future generated SDK files are checked into version control. Pass
`ignoreGenerated` to configure generation to add generated SDK paths to
.gitignore instead.
"""
pub init(ws: Workspace!, name: String!, path: String! = "", template: String! = "", ignoreGenerated: Boolean! = false): Changeset! {
let rawPath = if (path == "") {
let daggerDir = ws.findUp(".dagger", ".")
if (daggerDir == null) {
".dagger/modules/" + name
} else {
daggerDir.trimPrefix("/") + "/modules/" + name
}
} else {
path.trimPrefix("./").trimPrefix("/")
}

pub initModule(ws: Workspace!, name: String!, path: String!, template: String! = ""): Changeset! {
let rawPath = path.trimPrefix("./").trimPrefix("/")
let modPath = if (rawPath == "" or rawPath == ".") {
"."
} else if (rawPath == ".." or rawPath.trimPrefix("../") != rawPath) {
Expand All @@ -136,26 +119,18 @@ type GoSdk {
rawPath.trimSuffix("/")
}

let configPath = if (modPath == ".") { "dagger.json" } else { modPath + "/dagger.json" }
let selectedTemplate = if (template == "") { "minimal" } else { template }
let fork = polyfill.workspace(ws).fork

if (ws.directory("/", include: [configPath]).exists(configPath)) {
raise "module already exists: " + modPath
} else if (currentModule.source.exists("templates/" + selectedTemplate) == false) {
if (currentModule.source.exists("templates/" + selectedTemplate) == false) {
raise "unknown init template: " + template
} else {
let config = "{\n \"name\": " + toJSON(name) + ",\n \"engineVersion\": \"latest\",\n \"sdk\": {\n \"source\": \"go\"\n },\n \"codegen\": {\n \"automaticGitignore\": " + toJSON(ignoreGenerated) + "\n }\n}\n"
let templateSource = if (selectedTemplate == "legacy") {
renderedLegacyTemplate(name)
} else {
currentModule.source.directory("templates/" + selectedTemplate)
}
let seeded = fork
.withDirectory(modPath, templateSource)
.withNewFile(configPath, config)

seeded.changes
fork.withDirectory(modPath, templateSource).changes
}
}

Expand All @@ -177,7 +152,11 @@ type GoSdk {
}

"""
Generate all discovered Go SDK modules.
Generate all discovered legacy dagger.json Go SDK modules.

This discovery path is obsolete for workspace-managed modules; the engine
owns the modules.<sdk>.as-sdk.modules source of truth.

Modules with the generate skip marker are skipped.
"""
pub generateAll(ws: Workspace!): Changeset! @generate {
Expand Down
43 changes: 0 additions & 43 deletions mod-deps.dang

This file was deleted.

42 changes: 0 additions & 42 deletions mod-engine.dang

This file was deleted.

20 changes: 0 additions & 20 deletions mod.dang
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ type Mod {
hasMarker(ws, skipGenerateFilename)
}

"""
Manage this module's Dagger dependencies.
"""
pub deps: ModDeps! {
ModDeps(
path: path,
ws: ws,
)
}

"""
Manage the Dagger engine version required by this module.
"""
pub engine: ModEngine! {
ModEngine(
path: path,
ws: ws,
)
}

"""
Whether this module root or an ancestor contains a marker filename.
"""
Expand Down