Dagger
Search

dagger-module-demo

This module has been generated via dagger init and serves as a reference to
basic module structure as you get started with Dagger.

Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.

The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.

Installation

dagger install github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591

Entrypoint

Return Type
DaggerModuleDemo
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
func (m *myModule) example() *dagger.DaggerModuleDemo  {
	return dag.
			DaggerModuleDemo()
}
@function
def example() -> dagger.DaggerModuleDemo:
	return (
		dag.dagger_module_demo()
	)
@func()
example(): DaggerModuleDemo {
	return dag
		.daggerModuleDemo()
}

Types

DaggerModuleDemo 🔗

containerEcho() 🔗

Returns a container that echoes whatever string argument is provided

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
stringArgString !-No description provided
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 container-echo --string-arg string
func (m *myModule) example(stringArg string) *dagger.Container  {
	return dag.
			DaggerModuleDemo().
			ContainerEcho(stringArg)
}
@function
def example(string_arg: str) -> dagger.Container:
	return (
		dag.dagger_module_demo()
		.container_echo(string_arg)
	)
@func()
example(stringArg: string): Container {
	return dag
		.daggerModuleDemo()
		.containerEcho(stringArg)
}

grepDir() 🔗

Returns lines that match a pattern in the files of the provided Directory

Return Type
String !
Arguments
NameTypeDefault ValueDescription
directoryArgDirectory !-No description provided
patternString !-No description provided
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 grep-dir --directory-arg DIR_PATH --pattern string
func (m *myModule) example(ctx context.Context, directoryArg *dagger.Directory, pattern string) string  {
	return dag.
			DaggerModuleDemo().
			GrepDir(ctx, directoryArg, pattern)
}
@function
async def example(directory_arg: dagger.Directory, pattern: str) -> str:
	return await (
		dag.dagger_module_demo()
		.grep_dir(directory_arg, pattern)
	)
@func()
async example(directoryArg: Directory, pattern: string): Promise<string> {
	return dag
		.daggerModuleDemo()
		.grepDir(directoryArg, pattern)
}

createCluster() 🔗

CreateCluster spins up a k3s single-node cluster, deploys a simple pod, and polls for pod readiness.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 create-cluster
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			CreateCluster(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.create_cluster()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.createCluster()
}

runThreeContainers() 🔗

RunThreeContainers demonstrates running three containers concurrently and collating their outputs.

Return Type
DaggerModuleDemoMultiContainerResult !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 run-three-containers
func (m *myModule) example() *dagger.DaggerModuleDemoMultiContainerResult  {
	return dag.
			DaggerModuleDemo().
			RunThreeContainers()
}
@function
def example() -> dagger.DaggerModuleDemoMultiContainerResult:
	return (
		dag.dagger_module_demo()
		.run_three_containers()
	)
@func()
example(): DaggerModuleDemoMultiContainerResult {
	return dag
		.daggerModuleDemo()
		.runThreeContainers()
}

listGithubRepos() 🔗

ListGitHubRepos takes a GitHub token (as an ordered argument) and uses the GitHub CLI to list repositories. The token is passed in via an environment variable.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 list-github-repos
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			ListGithubRepos(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.list_github_repos()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.listGithubRepos()
}

parseBase64Json() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 parse-base-6-4-json
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			ParseBase64Json(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.parse_base64_json()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.parseBase64Json()
}

loggingTest() 🔗

ParseBase64JSON demonstrates internal logging and capturing logs from two containers. The function returns a Base64 encoded JSON string that combines logs from container1 and container2.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 logging-test
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			LoggingTest(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.logging_test()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.loggingTest()
}

parseMultipleLogs() 🔗

ParseMultipleLogs runs a container that outputs multiple log lines. The function logs internal messages (sent to stderr) and returns the container’s stdout.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 parse-multiple-logs
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			ParseMultipleLogs(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.parse_multiple_logs()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.parseMultipleLogs()
}

parseSingleLog() 🔗

ParseSingleLog runs a container that outputs a single log message. The function logs diagnostic information and returns the container’s stdout.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 parse-single-log
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			ParseSingleLog(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.parse_single_log()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.parseSingleLog()
}

runContainerWithLogging() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 run-container-with-logging
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			RunContainerWithLogging(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.run_container_with_logging()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.runContainerWithLogging()
}

loggingExample() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 logging-example
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			LoggingExample(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.logging_example()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.loggingExample()
}

interactiveTerminal() 🔗

InteractiveTerminal demonstrates a basic interactive terminal in a Dagger function. It prints a simple menu, reads user input, and then uses the selection to run a container that echoes the chosen message. DOESN’T WORK

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 interactive-terminal
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			InteractiveTerminal(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.interactive_terminal()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.interactiveTerminal()
}

deployAndPollK8S() 🔗

DeployAndPollK8s demonstrates asynchronous orchestration in a Dagger function. It starts a k0s Kubernetes cluster as a service, polls for its readiness asynchronously, deploys a simple pod, and then polls the cluster for that pod.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 deploy-and-poll-k-8-s
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			DeployAndPollK8S(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.deploy_and_poll_k8_s()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.deployAndPollK8S()
}

startK0Scluster() 🔗

StartK0sCluster starts a k0s cluster and then blocks to keep it running. For demonstration purposes, it sleeps for 5 minutes before returning.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 start-k-0-s-cluster
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			StartK0SCluster(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.start_k0_s_cluster()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.startK0SCluster()
}

deployK3SandApp() 🔗

DeployK3sAndApp deploys a k3s cluster, installs an app via Helm, tests the app via curl, and returns the output.

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 deploy-k-3-s-and-app
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			DeployK3SAndApp(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.deploy_k3_s_and_app()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.deployK3SAndApp()
}

startK3SandOutputKubectlCommands() 🔗

StartK3SAndOutputKubectlCommands starts a k3s cluster, retrieves the kubeconfig, and outputs a set of kubectl one-liners that you can use to interact with the cluster.

Return Type
Container !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 start-k-3-sand-output-kubectl-commands
func (m *myModule) example() *dagger.Container  {
	return dag.
			DaggerModuleDemo().
			StartK3SandOutputKubectlCommands()
}
@function
def example() -> dagger.Container:
	return (
		dag.dagger_module_demo()
		.start_k3_sand_output_kubectl_commands()
	)
@func()
example(): Container {
	return dag
		.daggerModuleDemo()
		.startK3SandOutputKubectlCommands()
}

DaggerModuleDemoMultiContainerResult 🔗

MultiContainerResult holds the outputs from three containers and a collated string.

output1() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 run-three-containers \
 output-1
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			RunThreeContainers().
			Output1(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.run_three_containers()
		.output1()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.runThreeContainers()
		.output1()
}

output2() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 run-three-containers \
 output-2
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			RunThreeContainers().
			Output2(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.run_three_containers()
		.output2()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.runThreeContainers()
		.output2()
}

output3() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 run-three-containers \
 output-3
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			RunThreeContainers().
			Output3(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.run_three_containers()
		.output3()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.runThreeContainers()
		.output3()
}

collatedOutput() 🔗

Return Type
String !
Example
dagger -m github.com/rianfowler/dagger-module-demo@6bd71ad2c6c6001161062216087130032a186591 call \
 run-three-containers \
 collated-output
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			DaggerModuleDemo().
			RunThreeContainers().
			CollatedOutput(ctx)
}
@function
async def example() -> str:
	return await (
		dag.dagger_module_demo()
		.run_three_containers()
		.collated_output()
	)
@func()
async example(): Promise<string> {
	return dag
		.daggerModuleDemo()
		.runThreeContainers()
		.collatedOutput()
}