container

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GolangAlpineImage is the name of the Golang Alpine base image.
	GolangAlpineImage = "golang"
)

Variables

This section is empty.

Functions

func GetImageURL

func GetImageURL(opts *NewBaseContainerOpts) (string, error)

GetImageURL constructs the full image URL from the provided options. It returns an error if the options are nil or the image name is empty.

Parameters:

  • opts: A pointer to NewBaseContainerOpts containing the image name and version.

Returns:

  • A string containing the full image URL in the format "image:version".
  • An error if the options are nil or the image name is empty.

Example:

opts := &NewBaseContainerOpts{
    Image:   "golang",
    Version: "1.16",
}
imageURL, err := GetImageURL(opts)
if err != nil {
    // handle error
}
fmt.Println(imageURL) // Output: "golang:1.16"

func NewBase

func NewBase(opts *NewBaseContainerOpts) (*dagger.Container, error)

NewBase creates a new base container from the specified image and version. It returns an error if the options are nil or the image name is empty.

Parameters:

  • opts: A pointer to NewBaseContainerOpts containing the image name and version.

Returns:

  • A pointer to the Dagger container created from the specified image and version.
  • An error if the options are nil or the image name is empty.

Example:

opts := &NewBaseContainerOpts{
    Image:   "golang",
    Version: "1.16",
}
container, err := NewBase(opts)
if err != nil {
    // handle error
}
// Use the container, e.g., fmt.Println(container)

func NewGolangAlpineContainer

func NewGolangAlpineContainer(version string) (*dagger.Container, error)

NewGolangAlpineContainer creates a new container based on the Golang Alpine image with the specified version. It returns an error if the version is not provided or if the base container cannot be created.

Parameters:

  • version: The version of the Golang Alpine image to use. If empty, a default version is used.

Returns:

  • A pointer to the Dagger container created from the specified Golang Alpine image and version.
  • An error if the version is not provided or if the base container cannot be created.

Example:

// Create a new Golang Alpine container with a specific version
container, err := NewGolangAlpineContainer("1.16-alpine")
if err != nil {
    // handle error
}
// Use the container, e.g., fmt.Println(container)

// Create a new Golang Alpine container with the default version
container, err = NewGolangAlpineContainer("")
if err != nil {
    // handle error
}
// Use the container, e.g., fmt.Println(container)

Types

type NewBaseContainerOpts

type NewBaseContainerOpts struct {
	Image   string // The name of the base image.
	Version string // The version of the base image. If empty, a default version is used.
}

NewBaseContainerOpts contains options for creating a new base container.

Jump to

Keyboard shortcuts

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