create

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package create provides the container config for the wrapped client. it is built to be created in a declarative way.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContainerConfig = errors.New("container config has errors")
	ErrHostConfig      = errors.New("host config has errors")
	ErrNetworkConfig   = errors.New("network config has errors")
	ErrPlatformConfig  = errors.New("platform config has errors")
	ErrServiceConfig   = errors.New("service config has errors")
	ErrProjectConfig   = errors.New("project config has errors")
	ErrValidation      = errors.New("container has errors")
)

Functions

func IsContainerConfigError

func IsContainerConfigError(err error) bool

func IsHostConfigError

func IsHostConfigError(err error) bool

func IsNetworkConfigError

func IsNetworkConfigError(err error) bool

func IsPlatformConfigError

func IsPlatformConfigError(err error) bool

func IsProjectConfigError

func IsProjectConfigError(err error) bool

func IsServiceConfigError

func IsServiceConfigError(err error) bool

Types

type Container

type Container struct {
	Warnings []string
	Errors   []error
	Config   *mergedConfig
}

func NewContainer

func NewContainer(name string) *Container

func (*Container) GetWarnings

func (c *Container) GetWarnings() string

func (*Container) Validate

func (c *Container) Validate() error

Validate validates the container config. It will return an error if the container has errors.

func (*Container) WithContainerConfig

func (c *Container) WithContainerConfig(setters ...SetContainerConfig) *Container

WithContainerConfig sets the container config via the setter functions. It will return a container with the container config set. If any of the setters return an error, that setter will be skipped and an error will be appended to the container's error slice. parameters:

  • setters: the setters to set the container config

func (*Container) WithHostConfig

func (c *Container) WithHostConfig(setters ...SetHostConfig) *Container

WithHostConfig sets the host config via the setter functions. It will return a container with the host config set. If any of the setters return an error, that setter will be skipped and an error will be appended to the container's error slice. parameters:

  • setters: the setters to set the host config

func (*Container) WithNetworkConfig

func (c *Container) WithNetworkConfig(setters ...SetNetworkConfig) *Container

WithNetworkConfig sets the network config via the setter functions. It will return a container with the network config set. If any of the setters return an error, that setter will be skipped and an error will be appended to the container's error slice. parameters:

  • setters: the setters to set the network config

func (*Container) WithPlatformConfig

func (c *Container) WithPlatformConfig(setters ...SetPlatformConfig) *Container

WithPlatformConfig sets the platform config via the setter functions. It will return a container with the platform config set. If any of the setters return an error, that setter will be skipped and an error will be appended to the container's error slice. parameters:

  • setters: the setters to set the platform config

type ContainerConfig

type ContainerConfig struct {
	*c.Config
}

type ContainerConfigError

type ContainerConfigError struct {
	Field   string
	Message string
}

func NewContainerConfigError

func NewContainerConfigError(field, message string) *ContainerConfigError

func (*ContainerConfigError) Error

func (e *ContainerConfigError) Error() string

func (*ContainerConfigError) Unwrap

func (e *ContainerConfigError) Unwrap() error

type HostConfig

type HostConfig struct {
	*c.HostConfig
}

type HostConfigError

type HostConfigError struct {
	Field   string
	Message string
}

func NewHostConfigError

func NewHostConfigError(field, message string) *HostConfigError

func (*HostConfigError) Error

func (e *HostConfigError) Error() string

func (*HostConfigError) Unwrap

func (e *HostConfigError) Unwrap() error

type NetworkConfig

type NetworkConfig struct {
	*n.NetworkingConfig
}

type NetworkConfigError

type NetworkConfigError struct {
	Field   string
	Message string
}

func NewNetworkConfigError

func NewNetworkConfigError(field, message string) *NetworkConfigError

func (*NetworkConfigError) Error

func (e *NetworkConfigError) Error() string

func (*NetworkConfigError) Unwrap

func (e *NetworkConfigError) Unwrap() error

type PlatformConfig

type PlatformConfig struct {
	*p.Platform
}

type PlatformConfigError

type PlatformConfigError struct {
	Field   string
	Message string
}

func NewPlatformConfigError

func NewPlatformConfigError(field, message string) *PlatformConfigError

func (*PlatformConfigError) Error

func (e *PlatformConfigError) Error() string

func (*PlatformConfigError) Unwrap

func (e *PlatformConfigError) Unwrap() error

type Project

type Project struct {
	// contains filtered or unexported fields
}

Project is a wrapper around types.Project It provides methods to create and manage a docker Compose project.

func NewProject

func NewProject(name string) *Project

NewProject creates a new project with the given name. It initializes the project with an empty service list. The name is used as the project name in the compose file.

func (*Project) Export

func (p *Project) Export(file string, perm os.FileMode) error

Export exports the project to a file parameters:

  • file: the file path to export the project to
  • perm: the permission of the file

func (*Project) ForEachService

func (p *Project) ForEachService(fn func(name string, service *types.ServiceConfig) error) error

func (*Project) Marshal

func (p *Project) Marshal() ([]byte, error)

Marshal marshals the project to a yaml bytes slice

func (*Project) Unwrap

func (p *Project) Unwrap() *types.Project

Unwrap returns the underlying types.Project

func (*Project) Validate

func (p *Project) Validate() error

Validate validates the project returns an error if the project has errors

func (*Project) WithNetwork

func (p *Project) WithNetwork(name string, setters ...network.SetNetworkProjectConfig) *Project

WithNetwork defines a new network in the project

func (*Project) WithSecret

func (p *Project) WithSecret(key string, setters ...projectsecret.SetProjectSecretConfig) *Project

WithSecret defines a new secret in the project

func (*Project) WithService

func (p *Project) WithService(name string, service *Container, setters ...SetServiceConfig) *Project

WithService defines a new service in the project parameters:

  • name: the name of the service
  • service: the container to create the service from
  • setters: the setters to apply to the service

func (*Project) WithVolume

func (p *Project) WithVolume(name string, setters ...volume.SetVolumeProjectConfig) *Project

WithVolume defines a new volume in the project parameters:

  • name: the name of the volume
  • volume: the volume to create the volume from

type ProjectConfigError

type ProjectConfigError struct {
	Field   string
	Message string
}

func NewProjectConfigError

func NewProjectConfigError(field, message string) *ProjectConfigError

func (*ProjectConfigError) Error

func (e *ProjectConfigError) Error() string

func (*ProjectConfigError) Unwrap

func (e *ProjectConfigError) Unwrap() error

type ServiceConfigError

type ServiceConfigError struct {
	Field   string
	Message string
}

func NewServiceConfigError

func NewServiceConfigError(field, message string) *ServiceConfigError

func (*ServiceConfigError) Error

func (e *ServiceConfigError) Error() string

func (*ServiceConfigError) Unwrap

func (e *ServiceConfigError) Unwrap() error

type SetContainerConfig

type SetContainerConfig func(config *ContainerConfig) error

SetContainerConfig is a function that sets the container config

type SetHostConfig

type SetHostConfig func(config *HostConfig) error

SetHostConfig is a function that sets the host config

type SetNetworkConfig

type SetNetworkConfig func(config *NetworkConfig) error

SetNetworkConfig is a function that sets the network config

type SetPlatformConfig

type SetPlatformConfig func(config *PlatformConfig) error

SetPlatformConfig is a function that sets the platform config

type SetServiceConfig

type SetServiceConfig func(service *types.ServiceConfig) error

SetServiceConfig is a function that sets the service config

Directories

Path Synopsis
config
cc
Package cc provides the options for the container config.
Package cc provides the options for the container config.
hc
Package hc provides the options for the host config.
Package hc provides the options for the host config.
hc/mount
Package mount provides the options for the mount config in the host config.
Package mount provides the options for the mount config in the host config.
nc
Package nc provides the options for the network config.
Package nc provides the options for the network config.
nc/endpoint
Package endpoint provides the options for the endpoint config in the network config.
Package endpoint provides the options for the endpoint config in the network config.
nc/endpoint/ipam
Package ipam provides the options for the IPAM config in the endpoint config.
Package ipam provides the options for the IPAM config in the endpoint config.
pc
Package pc provides the options for the platform config.
Package pc provides the options for the platform config.
sc
Package sc provides functions to set the service config
Package sc provides functions to set the service config
sc/build
Package build provides functions to set the build config for a service
Package build provides functions to set the build config for a service
sc/build/ulimit
Package ulimit provides a set of functions to configure the ulimits for the build
Package ulimit provides a set of functions to configure the ulimits for the build
sc/deploy
Package deploy provides functions to set the deploy configuration for a service
Package deploy provides functions to set the deploy configuration for a service
sc/deploy/resource
Package resource provides functions to set the resource configuration for a service deploy
Package resource provides functions to set the resource configuration for a service deploy
sc/deploy/resource/device
Package device provides functions to set the device configuration for a service deploys resource
Package device provides functions to set the device configuration for a service deploys resource
sc/deploy/update
Package update provides functions to set the update configuration for a service deploy
Package update provides functions to set the update configuration for a service deploy
sc/network
Package network provides functions to set the network configuration for a project
Package network provides functions to set the network configuration for a project
sc/network/pool
Package pool provides functions to set the ipam pool configuration for a project
Package pool provides functions to set the ipam pool configuration for a project
sc/secrets/projectsecret
Package projectsecret provides a set of functions to configure the secret for the project
Package projectsecret provides a set of functions to configure the secret for the project
sc/secrets/secretservice
Package secretservice provides a set of functions to configure the secrets for the service
Package secretservice provides a set of functions to configure the secrets for the service
sc/volume
Package volume provides functions to set the volume configuration for a project
Package volume provides functions to set the volume configuration for a project

Jump to

Keyboard shortcuts

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