gotoolbox

command module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README ΒΆ

🧰 Gotoolbox Module for Dagger

A powerful Dagger module for Go development and CI/CD workflows.

πŸ› οΈ Configuration

Through the Dagger CLI or within your module, you can configure:

  • βš™οΈ ctr: Base container (default: new container created)
  • βš™οΈ version: Go image version (default: latest)
  • βš™οΈ image: Go image (default: golang:alpine)

🌟 Features

Function Description Example
🐳 Base Set base image and version dagger call base --image-url golang:1.22-alpine
πŸ“¦ WithEnvironmentVariable Set environment variable dagger call with-environment-variable --name GO_ENV --value production
πŸ“‚ WithSource Mount source directory dagger call with-source --src . --workdir /app
πŸ”’ WithSecretAsEnvVar Set secret as env var dagger call with-secret-as-env-var --name API_KEY --secret mysecret
πŸ“₯ WithDownloadedFile Download and mount file dagger call with-downloaded-file --url https://example.com/file.txt
πŸ”„ WithClonedGitRepo Clone and mount Git repo dagger call with-cloned-git-repo --repo-url https://github.com/user/repo
πŸ”„ WithCacheBuster Add cache busting dagger call with-cache-buster
πŸ› οΈ WithGitInAlpineContainer Install Git dagger call with-git-in-alpine-container
🧰 WithUtilitiesInAlpineContainer Install common utilities dagger call with-utilities-in-alpine-container
πŸ–₯️ WithGoPlatform Set Go platform dagger call with-go-platform --platform linux/amd64
πŸ”§ WithGoCgoEnabled Enable CGO dagger call with-go-cgo-enabled
🚫 WithCgoDisabled Disable CGO dagger call with-cgo-disabled
πŸ’Ύ WithGoBuildCache Configure Go build cache dagger call with-go-build-cache
πŸ“¦ WithGoModCache Configure Go mod cache dagger call with-go-mod-cache
πŸ“₯ WithGoInstall Install Go packages dagger call with-go-install --pkgs github.com/user/pkg@latest
πŸƒ WithGoExec Execute Go command dagger call with-go-exec --args build --args ./...
πŸ› οΈ WithGoBuild Configure Go build dagger call with-go-build --pkg ./cmd/app --race
πŸ”’ WithGoPrivate Set GOPRIVATE dagger call with-go-private --private-host example.com
πŸ”§ WithGoGCCCompiler Install GCC compiler dagger call with-go-gcc-compiler
πŸ“Š WithGoTestSum Install GoTestSum dagger call with-go-test-sum
πŸš€ WithGoReleaser Install GoReleaser dagger call with-go-releaser
πŸ” WithGoLint Install golangci-lint dagger call with-go-lint --version v1.60.1
πŸ–₯️ OpenTerminal Open interactive terminal dagger call open-terminal
🐚 RunShell Run shell command dagger call run-shell --cmd "echo Hello, World!"
πŸ–¨οΈ PrintEnvVars Print environment variables dagger call print-env-vars
πŸ” InspectEnvVar Inspect specific env var dagger call inspect-env-var --key GO_VERSION
πŸƒ RunGoCMD Run Go command dagger call run-go-cmd --cmd test --cmd ./...
πŸƒ RunAnyCmd Run any command dagger call run-any-cmd --cmd go --cmd version

Using the Gotoolbox Module πŸš€

Refer to the examples in the {{.module_name_pkg}}/examples module to see how to use the module's functions.


Usage through the Dagger CLI πŸš€

List all the functions available in the module:

# enter into the module's directory
cd gotoolbox

# list all the functions available in the module
dagger develop && dagger functions

Call a function:

# call a function
# dagger call <function-name> [arguments]
dagger call github.com/excoriate/daggerverse/gotoolbox@version <function-name> [arguments]

Testing πŸ§ͺ

This module includes a testing module that aims to test the functionality of the Gotoolbox module. The tests are written in Go and can be run using the following command:

## Run the tests using the just command
just test gotoolbox

Developer Experience πŸ› οΈ

If you'd like to contribute, mostly we use Just to automate tasks and Nix to manage the development environment. You can use the following commands to get started:

# initialize the pre-commit hooks
just init
# run CI or common things locally
just golint gotoolbox
# run the tests
just test gotoolbox
# Run the entire CI tasks locally
just cilocal gotoolbox
Examples (aka Recipes) 🍲

Additionally, this module brings a new Daggerverse functionality that allows to automatically generate the module's documentation using an special (sub) module called {{.module_name_pkg}}/examples/sdk. This module contains a set of examples hat demonstrate how to use the module's functions.

To generate the documentation It's important to notice that each example function in order to be rendered in the documentation, it must be preprocessed by module's name, in this case (camelCase) gotoolbox.

NOTE: The just command entails the use of the Justfile for task automation. If you don't have it, don't worry, you just need Nix to run the tasks using the dev-shell built-in command: nix develop --impure --extra-experimental-features nix-command --extra-experimental-features flakes

Documentation ΒΆ

Overview ΒΆ

Package main provides methods for setting up and managing a container environment. This includes setting environment variables, mounting directories and files, and configuring services such as Docker within the container.

Copyright: Excoriate alex_torres@outlook.com License: MIT

Package main provides utility functions for working with Docker containers.

This package includes constants and a function for getting the Docker-in-Docker image.

Copyright: Excoriate License: Apache-2.0

Package main provides the Gotoolbox Dagger module and related functions.

This module has been generated via dagger init and serves as a reference to basic module structure as you get started with Dagger. The module demonstrates 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.

Directories ΒΆ

Path Synopsis
examples
go module
tests module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL