-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add services section to cookbook (#7442)
* docs: Add services section to cookbook Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Update copy Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Update text Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Updated paths Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Update text Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Update comments Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Add feedback Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix rebase Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix linter Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Updated heading Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Cleanup go files for existing snippets Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Update code comments format Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix linter Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix code, rebase Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix linter Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Move recipe location Signed-off-by: Vikram Vaswani <vikram@dagger.io> --------- Signed-off-by: Vikram Vaswani <vikram@dagger.io>
- Loading branch information
1 parent
cc37cb6
commit c236d32
Showing
50 changed files
with
529 additions
and
184 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
docs/current_docs/manuals/developer/cookbook/snippets/cache-dependencies/python/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
docs/current_docs/manuals/developer/cookbook/snippets/copy-dir/go/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type MyModule struct{} | ||
|
||
// Return a container with a specified directory | ||
func (m *MyModule) CopyDirectory( | ||
ctx context.Context, | ||
// Source directory | ||
source *Directory, | ||
) *Container { | ||
return dag.Container(). | ||
From("alpine:latest"). | ||
WithDirectory("/src", source) | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/current_docs/manuals/developer/cookbook/snippets/copy-dir/python/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Annotated | ||
|
||
import dagger | ||
from dagger import Doc, dag, function, object_type | ||
|
||
|
||
@object_type | ||
class MyModule: | ||
@function | ||
def copy_directory( | ||
self, source: Annotated[dagger.Directory, Doc("Source directory")] | ||
) -> dagger.Container: | ||
"""Return a container with a specified directory""" | ||
return dag.container().from_("alpine:latest").with_directory("/src", source) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
docs/current_docs/manuals/developer/cookbook/snippets/copy-file/python/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
from typing import Annotated | ||
|
||
import dagger | ||
from dagger import dag, function, object_type | ||
from dagger import Doc, dag, function, object_type | ||
|
||
|
||
@object_type | ||
class MyModule: | ||
@function | ||
async def copy_file(self, f: dagger.File) -> dagger.Container: | ||
async def copy_file( | ||
self, | ||
f: Annotated[dagger.File, Doc("Source file")], | ||
) -> dagger.Container: | ||
"""Return a container with a specified file""" | ||
name = await f.name() | ||
return dag.container().from_("alpine:latest").with_file(f"/src/{name}", f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
docs/current_docs/manuals/developer/cookbook/snippets/copy-modify-dir/go/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dagger.gen.go | ||
/internal/dagger | ||
/internal/querybuilder | ||
/internal/telemetry |
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
docs/current_docs/manuals/developer/cookbook/snippets/copy-modify-dir/go/main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type MyModule struct{} | ||
|
||
// Return a container with a specified directory and an additional file | ||
func (m *MyModule) CopyAndModifyDirectory( | ||
ctx context.Context, | ||
// Source directory | ||
source *Directory, | ||
) *Container { | ||
return dag.Container(). | ||
From("alpine:latest"). | ||
WithDirectory("/src", source). | ||
WithExec([]string{"/bin/sh", "-c", `echo foo > /src/foo`}) | ||
} |
19 changes: 19 additions & 0 deletions
19
docs/current_docs/manuals/developer/cookbook/snippets/copy-modify-dir/python/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Annotated | ||
|
||
import dagger | ||
from dagger import Doc, dag, function, object_type | ||
|
||
|
||
@object_type | ||
class MyModule: | ||
@function | ||
def copy_and_modify_directory( | ||
self, source: Annotated[dagger.Directory, Doc("Source directory")] | ||
) -> dagger.Container: | ||
"""Return a container with a specified directory and an additional file""" | ||
return ( | ||
dag.container() | ||
.from_("alpine:latest") | ||
.with_directory("/src", source) | ||
.with_exec(["/bin/sh", "-c", "`echo foo > /src/foo`"]) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
docs/current_docs/manuals/developer/cookbook/snippets/modify-dir/go/main.go
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
docs/current_docs/manuals/developer/cookbook/snippets/modify-dir/python/main.py
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
docs/current_docs/manuals/developer/cookbook/snippets/set-env-vars/go/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dagger.gen.go | ||
/internal/dagger | ||
/internal/querybuilder | ||
/internal/telemetry |
14 changes: 0 additions & 14 deletions
14
docs/current_docs/manuals/developer/cookbook/snippets/write-dir/go/main.go
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
docs/current_docs/manuals/developer/cookbook/snippets/write-dir/python/main.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...ent_docs/manuals/developer/snippets/services/expose-dagger-services-to-host/go/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dagger.gen.go | ||
/internal/dagger | ||
/internal/querybuilder | ||
/internal/telemetry |
6 changes: 6 additions & 0 deletions
6
...nt_docs/manuals/developer/snippets/services/expose-dagger-services-to-host/go/dagger.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "my-module", | ||
"sdk": "go", | ||
"source": ".", | ||
"engineVersion": "v0.11.3" | ||
} |
13 changes: 13 additions & 0 deletions
13
...current_docs/manuals/developer/snippets/services/expose-dagger-services-to-host/go/go.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module main | ||
|
||
go 1.21.7 | ||
|
||
require ( | ||
github.com/99designs/gqlgen v0.17.31 | ||
github.com/Khan/genqlient v0.6.0 | ||
github.com/vektah/gqlparser/v2 v2.5.6 | ||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa | ||
golang.org/x/sync v0.6.0 | ||
) | ||
|
||
require github.com/stretchr/testify v1.8.3 // indirect |
35 changes: 35 additions & 0 deletions
35
...current_docs/manuals/developer/snippets/services/expose-dagger-services-to-host/go/go.sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
github.com/99designs/gqlgen v0.17.31 h1:VncSQ82VxieHkea8tz11p7h/zSbvHSxSDZfywqWt158= | ||
github.com/99designs/gqlgen v0.17.31/go.mod h1:i4rEatMrzzu6RXaHydq1nmEPZkb3bKQsnxNRHS4DQB4= | ||
github.com/Khan/genqlient v0.6.0 h1:Bwb1170ekuNIVIwTJEqvO8y7RxBxXu639VJOkKSrwAk= | ||
github.com/Khan/genqlient v0.6.0/go.mod h1:rvChwWVTqXhiapdhLDV4bp9tz/Xvtewwkon4DpWWCRM= | ||
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= | ||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= | ||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= | ||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= | ||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= | ||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= | ||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||
github.com/vektah/gqlparser/v2 v2.5.6 h1:Ou14T0N1s191eRMZ1gARVqohcbe1e8FrcONScsq8cRU= | ||
github.com/vektah/gqlparser/v2 v2.5.6/go.mod h1:z8xXUff237NntSuH8mLFijZ+1tjV1swDbpDqjJmk6ME= | ||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= | ||
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= | ||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= | ||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.