go
Copyright © 2024 Patrick Hermann patrick.hermann@sva.de
Installation
dagger install github.com/stuttgart-things/dagger/go@v0.5.0
Entrypoint
Return Type
Go !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
goLangContainer | Container | - | golang container It need contain golang |
koContainer | Container | - | No description provided |
goLangVersion | String | "1.23.6" | No description provided |
src | Directory | - | No description provided |
Example
func (m *myModule) example() *Go {
return dag.
Go()
}
Types
Go 🔗
src() 🔗
Return Type
Directory !
Example
func (m *myModule) example() *Directory {
return dag.
Go().
Src()
}
goLangContainer() 🔗
Return Type
Container !
Example
func (m *myModule) example() *Container {
return dag.
Go().
GoLangContainer()
}
koContainer() 🔗
Return Type
Container !
Example
func (m *myModule) example() *Container {
return dag.
Go().
KoContainer()
}
getGoLangContainer() 🔗
GetGoLangContainer returns the default image for golang
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
goVersion | String ! | - | No description provided |
Example
func (m *myModule) example(goVersion string) *Container {
return dag.
Go().
GetGoLangContainer(goVersion)
}
getKoContainer() 🔗
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
koVersion | String | "v0.17.1" | No description provided |
Example
func (m *myModule) example() *Container {
return dag.
Go().
GetKoContainer()
}
runWorkflowEntryStage() 🔗
Return Type
File !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
lintTimeout | String | "500s" | No description provided |
goVersion | String | "1.23.6" | No description provided |
os | String | "linux" | No description provided |
arch | String | "amd64" | No description provided |
goMainFile | String | "main.go" | No description provided |
binName | String | "main" | No description provided |
ldflags | String | - | No description provided |
secureGoVersion | String | "2.22.1" | No description provided |
lintCanFail | Boolean | "false" | If true, linting can fail without stopping the workflow |
testArg | String | "./..." | Arguments for `go test` |
securityScanCanFail | Boolean | "false" | If true, security scan can fail without stopping the workflow |
trivyScanCanFail | Boolean | "false" | If true, Trivy scan can fail without stopping the workflow |
trivySeverity | String | "HIGH,CRITICAL" | Severity levels to include (e.g., "HIGH,CRITICAL") |
trivyVersion | String | "0.59.1" | No description provided |
Example
func (m *myModule) example(src *Directory) *File {
return dag.
Go().
RunWorkflowEntryStage(src)
}
lint() 🔗
Lint runs the linter on the provided source code
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
timeout | String | "500s" | No description provided |
Example
func (m *myModule) example(src *Directory) *Container {
return dag.
Go().
Lint(src)
}
scanTarBallImage() 🔗
Lint runs the linter on the provided source code
Return Type
File !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
file | File ! | - | No description provided |
Example
func (m *myModule) example(file *File) *File {
return dag.
Go().
ScanTarBallImage(file)
}
koBuildAndScan() 🔗
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
tokenName | String | "GITHUB_TOKEN" | No description provided |
token | Secret ! | - | No description provided |
repo | String | "ko.local" | No description provided |
buildArg | String | "." | No description provided |
koVersion | String | "v0.17.1" | No description provided |
push | String | "true" | No description provided |
severityFilter | String | "HIGH,CRITICAL" | Comma-separated list of severities to filter (e.g., "HIGH,CRITICAL") |
Example
func (m *myModule) example(ctx context.Context, src *Directory, token *Secret) string {
return dag.
Go().
KoBuildAndScan(ctx, src, token)
}
searchVulnerabilities() 🔗
SearchVulnerabilities parses the Trivy scan report and filters vulnerabilities by severity
Return Type
[String ! ] !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
scanOutput | String ! | - | The scan output as a string |
severityFilter | String ! | - | Comma-separated list of severities to filter (e.g., "HIGH,CRITICAL") |
Example
func (m *myModule) example(ctx context.Context, scanOutput string, severityFilter string) []string {
return dag.
Go().
SearchVulnerabilities(ctx, scanOutput, severityFilter)
}
binary() 🔗
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
goVersion | String | "1.23.6" | No description provided |
os | String | "linux" | No description provided |
arch | String | "amd64" | No description provided |
goMainFile | String | "main.go" | No description provided |
binName | String | "main" | No description provided |
ldflags | String | - | Add ldflags as an optional parameter |
Example
func (m *myModule) example(src *Directory) *Directory {
return dag.
Go().
Binary(src)
}
build() 🔗
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
opts | BuildOpts ! | - | Use the struct for parameters |
Example
func (m *myModule) example(src *Directory, opts *GoBuildOpts) *Directory {
return dag.
Go().
Build(src, opts)
}
koBuild() 🔗
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
tokenName | String | "GITHUB_TOKEN" | No description provided |
token | Secret ! | - | No description provided |
repo | String | "ko.local" | No description provided |
buildArg | String | "." | No description provided |
koVersion | String | "v0.17.1" | No description provided |
push | String | "true" | No description provided |
Example
func (m *myModule) example(ctx context.Context, src *Directory, token *Secret) string {
return dag.
Go().
KoBuild(ctx, src, token)
}
test() 🔗
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
goVersion | String ! | - | Go version to use for testing |
testArg | String | "./..." | Arguments for `go test` |
Example
func (m *myModule) example(ctx context.Context, src *Directory, goVersion string) string {
return dag.
Go().
Test(ctx, src, goVersion)
}
trivyScan() 🔗
Return Type
File !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
severity | String | "HIGH,CRITICAL" | Severity levels to include (e.g., "HIGH,CRITICAL") |
trivyVersion | String | "0.59.1" | No description provided |
Example
func (m *myModule) example(src *Directory) *File {
return dag.
Go().
TrivyScan(src)
}
securityScan() 🔗
Return Type
File !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
secureGoVersion | String | "2.22.1" | No description provided |
Example
func (m *myModule) example(src *Directory) *File {
return dag.
Go().
SecurityScan(src)
}
runWorkflowContainerStage() 🔗
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | No description provided |
tokenName | String | "GITHUB_TOKEN" | No description provided |
token | Secret ! | - | No description provided |
repo | String | "ko.local" | No description provided |
buildArg | String | "." | No description provided |
koVersion | String | "v0.17.1" | No description provided |
push | String | "true" | No description provided |
severityFilter | String | "HIGH,CRITICAL" | Comma-separated list of severities to filter (e.g., "HIGH,CRITICAL") |
Example
func (m *myModule) example(ctx context.Context, src *Directory, token *Secret) string {
return dag.
Go().
RunWorkflowContainerStage(ctx, src, token)
}
scanRemoteImage() 🔗
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
imageAddress | String ! | - | Remote image address (e.g., "ko.local/my-image:latest") |
severityFilter | String ! | - | Comma-separated list of severities to filter (e.g., "HIGH,CRITICAL") |
Example
func (m *myModule) example(ctx context.Context, imageAddress string, severityFilter string) string {
return dag.
Go().
ScanRemoteImage(ctx, imageAddress, severityFilter)
}
BuildOpts 🔗
goVersion() 🔗
Return Type
String !
Example
Function GoBuildOpts.goVersion is not accessible from the go module
os() 🔗
Return Type
String !
Example
Function GoBuildOpts.os is not accessible from the go module
arch() 🔗
Return Type
String !
Example
Function GoBuildOpts.arch is not accessible from the go module
goMainFile() 🔗
Return Type
String !
Example
Function GoBuildOpts.goMainFile is not accessible from the go module
binName() 🔗
Return Type
String !
Example
Function GoBuildOpts.binName is not accessible from the go module
ldflags() 🔗
Add this field for linker flags
Return Type
String !
Example
Function GoBuildOpts.ldflags is not accessible from the go module