-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61543d5
commit 0ee9a47
Showing
1 changed file
with
47 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -20,17 +20,60 @@ dagger call -m github.com/jpadams/daggerverse/[email protected] scan-image --image-re | |
``` | ||
|
||
|
||
## CREATE A PIPELINE | ||
## FUNCTIONS | ||
|
||
### INIT PIPELINE | ||
### CREATE A NEW FUNCTION | ||
|
||
```bash | ||
dagger init --sdk=go --source=./dagger | ||
``` | ||
|
||
### CALL A FUNCTION | ||
### CREATE FUNCTION WITH RETURN | ||
|
||
the following function is using a golang base image and builds a binary | ||
|
||
```go | ||
// dagger call build --progress plain --src ./ export --path build (returned dir(path)) | ||
func (m *Clusterbook) Build(ctx context.Context, src *dagger.Directory) *dagger.Directory { | ||
|
||
// get `golang` image | ||
golang := dag.Container().From("golang:latest") | ||
|
||
// mount cloned repository into `golang` image | ||
golang = golang.WithDirectory("/src", src).WithWorkdir("/src") | ||
|
||
// define the application build command | ||
path := "build/" | ||
golang = golang.WithExec([]string{"env", "GOOS=linux", "GOARCH=amd64", "go", "build", "-o", path, "./main.go"}) | ||
} | ||
``` | ||
|
||
### CALL FUNCTION | ||
|
||
```bash | ||
dagger functions | ||
dagger call container-echo --string-arg world | ||
dagger call build --progress plain --src ./ export --path build | ||
``` | ||
|
||
### CREATE FUNCTION WHICH IS BASED ON A IMPORT WITHOUT A RETURN | ||
|
||
```go | ||
func (m *Clusterbook) Scan(ctx context.Context, image string) { | ||
|
||
golang := dag.Container().From(image) | ||
|
||
scanResult, _ := dag.Trivy().ScanContainer(ctx, golang, dagger.TrivyScanContainerOpts{ | ||
TrivyImageTag: trivyImageTag, | ||
Severity: "HIGH,CRITICAL", | ||
Format: "table", | ||
ExitCode: 0, | ||
}) | ||
|
||
fmt.Println(scanResult) | ||
} | ||
``` | ||
|
||
``` | ||
dagger install github.com/jpadams/daggerverse/trivy | ||
dagger call scan --progress plain --image nginx:latest | ||
``` |