package loader
import "github.com/compose-spec/compose-go/loader"
Index ¶
- Variables
- func InvalidProjectNameErr(v string) error
- func IsServiceDependency(ref string) (string, bool)
- func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.Project, error)
- func LoadConfigObjs(source map[string]interface{}) (map[string]types.ConfigObjConfig, error)
- func LoadIncludeConfig(source []interface{}) ([]types.IncludeConfig, error)
- func LoadNetworks(source map[string]interface{}) (map[string]types.NetworkConfig, error)
- func LoadSecrets(source map[string]interface{}) (map[string]types.SecretConfig, error)
- func LoadService(name string, serviceDict map[string]interface{}) (*types.ServiceConfig, error)
- func LoadServices(ctx context.Context, filename string, servicesDict map[string]interface{}, workingDir string, lookupEnv template.Mapping, opts *Options) ([]types.ServiceConfig, error)
- func LoadVolumes(source map[string]interface{}) (map[string]types.VolumeConfig, error)
- func LoadWithContext(ctx context.Context, configDetails types.ConfigDetails, options ...func(*Options)) (*types.Project, error)
- func Normalize(project *types.Project) error
- func NormalizeProjectName(s string) string
- func ParseShortSSHSyntax(value string) ([]types.SSHKey, error)
- func ParseVolume(spec string) (types.ServiceVolumeConfig, error)
- func ParseYAML(source []byte) (map[string]interface{}, error)
- func ResolveRelativePaths(project *types.Project) error
- func ResolveServiceRelativePaths(workingDir string, s *types.ServiceConfig)
- func Transform(source interface{}, target interface{}, additionalTransformers ...Transformer) error
- func WithDiscardEnvFiles(opts *Options)
- func WithProfiles(profiles []string) func(*Options)
- func WithSkipValidation(opts *Options)
- type ForbiddenPropertiesError
- type Options
- func (o Options) GetProjectName() (string, bool)
- func (o *Options) SetProjectName(name string, imperativelySet bool)
- type PostProcessor
- type ResetProcessor
- func (p *ResetProcessor) Apply(target *types.Config) error
- func (p *ResetProcessor) UnmarshalYAML(value *yaml.Node) error
- type ResourceLoader
- type Transformer
- type TransformerFunc
Variables ¶
var Propagations = []string{ types.PropagationRPrivate, types.PropagationPrivate, types.PropagationRShared, types.PropagationShared, types.PropagationRSlave, types.PropagationSlave, }
Functions ¶
func InvalidProjectNameErr ¶
func IsServiceDependency ¶
IsServiceDependency check the relation set by ref refers to a service
func Load ¶
Load reads a ConfigDetails and returns a fully loaded configuration. Deprecated: use LoadWithContext.
func LoadConfigObjs ¶
func LoadConfigObjs(source map[string]interface{}) (map[string]types.ConfigObjConfig, error)
LoadConfigObjs produces a ConfigObjConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadIncludeConfig ¶
func LoadIncludeConfig(source []interface{}) ([]types.IncludeConfig, error)
LoadIncludeConfig parse the require config from raw yaml
func LoadNetworks ¶
func LoadNetworks(source map[string]interface{}) (map[string]types.NetworkConfig, error)
LoadNetworks produces a NetworkConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadSecrets ¶
func LoadSecrets(source map[string]interface{}) (map[string]types.SecretConfig, error)
LoadSecrets produces a SecretConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadService ¶
func LoadService(name string, serviceDict map[string]interface{}) (*types.ServiceConfig, error)
LoadService produces a single ServiceConfig from a compose file Dict the serviceDict is not validated if directly used. Use Load() to enable validation
func LoadServices ¶
func LoadServices(ctx context.Context, filename string, servicesDict map[string]interface{}, workingDir string, lookupEnv template.Mapping, opts *Options) ([]types.ServiceConfig, error)
LoadServices produces a ServiceConfig map from a compose file Dict the servicesDict is not validated if directly used. Use Load() to enable validation
func LoadVolumes ¶
func LoadVolumes(source map[string]interface{}) (map[string]types.VolumeConfig, error)
LoadVolumes produces a VolumeConfig map from a compose file Dict the source Dict is not validated if directly used. Use Load() to enable validation
func LoadWithContext ¶
func LoadWithContext(ctx context.Context, configDetails types.ConfigDetails, options ...func(*Options)) (*types.Project, error)
LoadWithContext reads a ConfigDetails and returns a fully loaded configuration
func Normalize ¶
Normalize compose project by moving deprecated attributes to their canonical position and injecting implicit defaults
func NormalizeProjectName ¶
func ParseShortSSHSyntax ¶
ParseShortSSHSyntax parse short syntax for SSH authentications
func ParseVolume ¶
func ParseVolume(spec string) (types.ServiceVolumeConfig, error)
ParseVolume parses a volume spec without any knowledge of the target platform
func ParseYAML ¶
ParseYAML reads the bytes from a file, parses the bytes into a mapping structure, and returns it.
func ResolveRelativePaths ¶
ResolveRelativePaths resolves relative paths based on project WorkingDirectory
func ResolveServiceRelativePaths ¶
func ResolveServiceRelativePaths(workingDir string, s *types.ServiceConfig)
func Transform ¶
func Transform(source interface{}, target interface{}, additionalTransformers ...Transformer) error
Transform converts the source into the target struct with compose types transformer and the specified transformers if any.
func WithDiscardEnvFiles ¶
func WithDiscardEnvFiles(opts *Options)
WithDiscardEnvFiles sets the Options to discard the `env_file` section after resolving to the `environment` section
func WithProfiles ¶
WithProfiles sets profiles to be activated
func WithSkipValidation ¶
func WithSkipValidation(opts *Options)
WithSkipValidation sets the Options to skip validation when loading sections
Types ¶
type ForbiddenPropertiesError ¶
ForbiddenPropertiesError is returned when there are properties in the Compose file that are forbidden.
func (*ForbiddenPropertiesError) Error ¶
func (e *ForbiddenPropertiesError) Error() string
type Options ¶
type Options struct { // Skip schema validation SkipValidation bool // Skip interpolation SkipInterpolation bool // Skip normalization SkipNormalization bool // Resolve paths ResolvePaths bool // Convert Windows paths ConvertWindowsPaths bool // Skip consistency check SkipConsistencyCheck bool // Skip extends SkipExtends bool // SkipInclude will ignore `include` and only load model from file(s) set by ConfigDetails SkipInclude bool // SkipResolveEnvironment will ignore computing `environment` for services SkipResolveEnvironment bool // Interpolation options Interpolate *interp.Options // Profiles set profiles to enable Profiles []string // ResourceLoaders manages support for remote resources ResourceLoaders []ResourceLoader // contains filtered or unexported fields }
Options supported by Load
func (Options) GetProjectName ¶
func (*Options) SetProjectName ¶
type PostProcessor ¶
type PostProcessor interface { yaml.Unmarshaler // Apply changes to compose model based on recorder metadata Apply(config *types.Config) error }
PostProcessor is used to tweak compose model based on metadata extracted during yaml Unmarshal phase that hardly can be implemented using go-yaml and mapstructure
type ResetProcessor ¶
type ResetProcessor struct {
// contains filtered or unexported fields
}
func (*ResetProcessor) Apply ¶
func (p *ResetProcessor) Apply(target *types.Config) error
Apply finds the go attributes matching recorded paths and reset them to zero value
func (*ResetProcessor) UnmarshalYAML ¶
func (p *ResetProcessor) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implement yaml.Unmarshaler
type ResourceLoader ¶
type ResourceLoader interface { // Accept returns `true` is the resource reference matches ResourceLoader supported protocol(s) Accept(path string) bool // Load returns the path to a local copy of remote resource identified by `path`. Load(ctx context.Context, path string) (string, error) }
ResourceLoader is a plugable remote resource resolver
type Transformer ¶
type Transformer struct { TypeOf reflect.Type Func TransformerFunc }
Transformer defines a map to type transformer
type TransformerFunc ¶
type TransformerFunc func(interface{}) (interface{}, error)
TransformerFunc defines a function to perform the actual transformation
Source Files ¶
include.go interpolate.go loader.go mapstructure.go merge.go normalize.go null.go paths.go validate.go volume.go windows_path.go
- Version
- v1.20.2 (latest)
- Published
- Nov 21, 2023
- Platform
- js/wasm
- Imports
- 27 packages
- Last checked
- 23 hours ago –
Tools for package owners.