Excoriate / daggerx

DaggerX is a Go package πŸ“¦ that helps you avoid DRY while developing Dagger modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

A collection of utility functions that works well when using Dagger and Go


Go Reference Contributors Activity

Why πŸ€”

This library is a set of reusable functions that can be used when developing Dagger modules or functions using Go. The objective is to speed up the development process and make it easier to write Dagger modules using Go.

Installation πŸ› οΈ

Install it using Go get:

go get github.com/Excoriate/daggerx

Pre-requisites πŸ“‹

  • Go >= ~1.22

NOTE: For the tools used in this project, please check the Makefile, and the Taskfile files. You'll also need pre-commit installed.


Usage πŸš€

Convert map to slice of DaggerEnvVars

package main

import (
    "fmt"
    "github.com/Excoriate/daggerx/pkg/envvars"
    "github.com/Excoriate/daggerx/pkg/types"
)

func main() {
    envVarsMap := map[string]string{
        "key1": "value1",
        "key2": "value2",
        "key3": "value3",
    }

    envVarsSlice, err := envvars.ToDaggerEnvVarsFromMap(envVarsMap)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }

    fmt.Println("Environment Variables Slice:", envVarsSlice)
}

Generate validated Dagger commands

package main

import (
    "fmt"
    "github.com/Excoriate/daggerx/pkg/execmd"
)

func main() {
    cmd, err := execmd.GenerateCommand("terraform", "plan", "-var", "foo=bar")
    if err != nil {
        fmt.Println("Error:", err)
        return
    }

    fmt.Println("Generated Command:", *cmd)
}

Convert slice of key=value strings to slice of DaggerEnvVars

package main

import (
    "fmt"
    "github.com/Excoriate/daggerx/pkg/envvars"
    "github.com/Excoriate/daggerx/pkg/types"
)

func main() {
    envVarsSlice := []string{"key1=value1", "key2=value2", "key3=value3"}

    daggerEnvVarsSlice, err := envvars.ToDaggerEnvVarsFromSlice(envVarsSlice)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }

    fmt.Println("Dagger Environment Variables Slice:", daggerEnvVarsSlice)
}

Contributing

Please read our contributing guide.

About

DaggerX is a Go package πŸ“¦ that helps you avoid DRY while developing Dagger modules.

License:Apache License 2.0


Languages

Language:Go 98.3%Language:Shell 1.7%