v0

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpgradeConfig

func UpgradeConfig(
	cfgBytes []byte,
	projectVersionerFactory distgo.ProjectVersionerFactory,
	disterFactory distgo.DisterFactory,
	dockerBuilderFactory distgo.DockerBuilderFactory,
	publisherFactory distgo.PublisherFactory) ([]byte, error)

Types

type BuildConfig

type BuildConfig struct {
	// NameTemplate is the template used for the executable output. The following template parameters can be used in the
	// template:
	//   * {{Product}}: the name of the product
	//   * {{Version}}: the version of the project
	//
	// If a value is not specified, "{{Product}}" is used as the default value.
	NameTemplate *string `yaml:"name-template,omitempty"`

	// OutputDir specifies the default build output directory for products executables built by the "build" task. The
	// executables generated by "build" are written to "{{OutputDir}}/{{ID}}/{{Version}}/{{OSArch}}/{{NameTemplate}}".
	//
	// If not specified, "out/build" is used as the default value.
	OutputDir *string `yaml:"output-dir,omitempty"`

	// MainPkg is the location of the main package for the product relative to the project root directory. For example,
	// "./distgo/main".
	MainPkg *string `yaml:"main-pkg,omitempty"`

	// BuildArgsScript is the content of a script that is written to a file and run before this product is built
	// to provide supplemental build arguments for the product. The content of this value is written to a file and
	// executed. The script process uses the project directory as its working directory and inherits the environment
	// variables of the Go process. Each line of the output of the script is provided to the "build" command as a
	// separate argument. For example, the following script would add the arguments "-ldflags" "-X" "main.year=$YEAR" to
	// the build command:
	//
	//   #!/usr/bin/env bash
	//   YEAR=$(date +%Y)
	//   echo "-ldflags"
	//   echo "-X"
	//   echo "main.year=$YEAR"
	BuildArgsScript *string `yaml:"build-args-script,omitempty"`

	// VersionVar is the path to a variable that is set with the version information for the build. For example,
	// "github.com/palantir/godel/v2/cmd/godel.Version". If specified, it is provided to the "build" command as an
	// ldflag.
	VersionVar *string `yaml:"version-var,omitempty"`

	// Environment specifies values for the environment variables that should be set for the build. For example,
	// the following sets CGO to false:
	//
	//   environment:
	//     CGO_ENABLED: "0"
	Environment *map[string]string `yaml:"environment,omitempty"`

	// Script is the content of a script that is written to a file and run before the build processes start. The script
	// process inherits the environment variables of the Go process and also has project-related environment variables.
	// Refer to the documentation for the distgo.BuildScriptEnvVariables function for the extra environment variables.
	Script *string `yaml:"script,omitempty"`

	// OSArchs specifies the GOOS and GOARCH pairs for which the product is built. If blank, defaults to the GOOS
	// and GOARCH of the host system at runtime.
	OSArchs *[]osarch.OSArch `yaml:"os-archs,omitempty"`
}

type DistConfig

type DistConfig struct {
	// OutputDir specifies the default distribution output directory for product distributions created by the "dist"
	// task. The distribution output directory is written to
	// "{{OutputDir}}/{{ID}}/{{Version}}/{{NameTemplate}}", and the distribution artifacts are written to
	// "{{OutputDir}}/{{ID}}/{{Version}}".
	//
	// If a value is not specified, "out/dist" is used as the default value.
	OutputDir *string `yaml:"output-dir,omitempty"`

	// Disters is the configuration for the disters for this product. The YAML representation can be a single DisterConfig
	// or a map[DistID]DisterConfig.
	Disters *DistersConfig `yaml:"disters,omitempty"`
}

type DisterConfig

type DisterConfig struct {
	// Type is the type of the dister. This field must be non-nil and non-empty and resolve to a valid Dister.
	Type *string `yaml:"type,omitempty"`

	// Config is the YAML configuration content for the dister.
	Config *yaml.MapSlice `yaml:"config,omitempty"`

	// NameTemplate is the template used for the executable output. The following template parameters can be used in the
	// template:
	//   * {{Product}}: the name of the product.
	//   * {{Version}}: the version of the project.
	//
	// If a value is not specified, "{{Product}}-{{Version}}" is used as the default value.
	NameTemplate *string `yaml:"name-template,omitempty"`

	// InputDir specifies an input directory whose contents will be copied to the dist work directory before the
	// distribution operation is run. Symlinks are not followed. Also supports specifying names or paths that should be
	// skipped.
	InputDir *InputDirConfig `yaml:"input-dir,omitempty"`

	// Script is the content of a script that is written to a file and run after the initial distribution process but
	// before the artifact generation process. The content of this value is written to a file and executed with the
	// project directory as the working directory. The script process inherits the environment variables of the Go
	// process and also has dist-related environment variables. Refer to the documentation for the
	// distgo.DistScriptEnvVariables function for the extra environment variables.
	Script *string `yaml:"script,omitempty"`
}

type DistersConfig

type DistersConfig map[distgo.DistID]DisterConfig

func (*DistersConfig) UnmarshalYAML

func (cfgs *DistersConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type DockerBuilderConfig

type DockerBuilderConfig struct {
	// Type is the type of the DockerBuilder. This field must be non-nil and non-empty and resolve to a valid DockerBuilder.
	Type *string `yaml:"type,omitempty"`
	// Script is the content of a script that is written to a file and run before the build task. This script is run
	// before the Dockerfile is read and rendered. The content of this value is written to a file and executed with the
	// project directory as the working directory. The script process inherits the environment variables of the Go
	// process and also has Docker-related environment variables. Refer to the documentation for the
	// distgo.DockerScriptEnvVariables function for the extra environment variables.
	Script *string `yaml:"script,omitempty"`
	// Config is the YAML configuration content for the DockerBuilder.
	Config *yaml.MapSlice `yaml:"config,omitempty"`
	// DockerfilePath is the path to the Dockerfile that is used to build the Docker image. The path is interpreted
	// relative to ContextDir. The content of the Dockerfile supports using Go templates. The following template
	// parameters can be used in the template:
	//   * {{Product}}: the name of the product
	//   * {{Version}}: the version of the project
	//   * {{Repository}}: the Docker repository for the operation
	//   * {{InputBuildArtifact(productID, osArch string) (string, error)}}: the path to the build artifact for the specified input product
	//   * {{InputDistArtifacts(productID, distID string) ([]string, error)}}: the paths to the dist artifacts for the specified input product
	//   * {{Tag(productID, dockerID, tagKey string) (string, error)}}: the rendered tag for the specified Docker image tag
	//   * {{Tags(productID, dockerID string) ([]string, error)}}: the rendered tags for the specified Docker image. Returned in the same order as defined in configuration.
	DockerfilePath *string `yaml:"dockerfile-path,omitempty"`
	// DisableTemplateRendering disables rendering the Go templates in the Dockerfile when set to true. This should only
	// be set to true if the Dockerfile does not use the Docker task templating and contains other Go templating -- in
	// this case, disabling rendering removes the need for the extra level of indirection usually necessary to render Go
	// templates using Go templates.
	DisableTemplateRendering *bool `yaml:"disable-template-rendering,omitempty"`
	// ContextDir is the Docker context directory for building the Docker image.
	ContextDir *string `yaml:"context-dir,omitempty"`
	// InputProductsDir is the directory in the context dir in which input products are written.
	InputProductsDir *string `yaml:"input-products-dir,omitempty"`
	// InputBuilds specifies the products whose build outputs should be made available to the Docker build task. The
	// specified products will be hard-linked into the context directory. The referenced products must be this product
	// or one of its declared dependencies.
	InputBuilds *[]distgo.ProductBuildID `yaml:"input-builds,omitempty"`
	// InputDists specifies the products whose dist outputs should be made available to the Docker build task. The
	// specified dists will be hard-linked into the context directory. The referenced products must be this product
	// or one of its declared dependencies.
	InputDists *[]distgo.ProductDistID `yaml:"input-dists,omitempty"`
	// InputDistsOutputPaths is an optional parameter that allows the paths of the input dists to be a specific
	// hard-coded location. The default behavior of InputDists places the dist outputs in a subdirectory of
	// InputProductsDir and relies on using the {{InputDistArtifacts}} template function to render their locations.
	// The InputDistsOutputPaths can be used to specify hard-coded paths for the dist outputs relative to the context
	// directory instead. Every key in InputDistsOutputPaths must identify a specific dist that is specified in
	// InputDists, even if the specification in InputDists is done at a product level. For example, if InputDists
	// specifies product "foo" and "foo" has "bar" and "baz" defined as dist types, then the only valid keys for
	// InputDistsOutputPaths are "foo.bar" and "foo.baz". The values are the locations that the distribution artifacts
	// should be placed, where each slice index must map to a dist artifact output index. If an output path is specified
	// for a distribution artifact, that path becomes the canonical one for that artifact for this Docker task -- the
	// artifact is placed only in that location, and that location is returned by the {{InputDistArtifacts}} template
	// function.
	InputDistsOutputPaths *map[distgo.ProductDistID][]string `yaml:"input-dist-output-paths,omitempty"`
	// TagTemplates specifies the templates that should be used to render the tag(s) for the Docker image. If multiple
	// values are specified, the image will be tagged with all of them.
	TagTemplates *TagTemplatesMap `yaml:"tag-templates,omitempty"`
}

type DockerBuildersConfig

type DockerBuildersConfig map[distgo.DockerID]DockerBuilderConfig

type DockerConfig

type DockerConfig struct {
	// Repository is the repository that is made available to the tag and Dockerfile templates.
	Repository *string `yaml:"repository,omitempty"`

	// DockerBuilderParams contains the Docker params for this distribution.
	DockerBuildersConfig *DockerBuildersConfig `yaml:"docker-builders,omitempty"`
}

type InputDirConfig added in v1.6.0

type InputDirConfig struct {
	Path    string                `yaml:"path,omitempty"`
	Exclude matcher.NamesPathsCfg `yaml:"exclude,omitempty"`
}

func (InputDirConfig) MarshalYAML added in v1.6.0

func (cfg InputDirConfig) MarshalYAML() (interface{}, error)

func (*InputDirConfig) UnmarshalYAML added in v1.6.0

func (cfg *InputDirConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type ProductConfig

type ProductConfig struct {
	// Build specifies the build configuration for the product.
	Build *BuildConfig `yaml:"build,omitempty"`

	// Run specifies the run configuration for the product.
	Run *RunConfig `yaml:"run,omitempty"`

	// Dist specifies the dist configuration for the product.
	Dist *DistConfig `yaml:"dist,omitempty"`

	// Publish specifies the publish configuration for the product.
	Publish *PublishConfig `yaml:"publish,omitempty"`

	// Docker specifies the Docker configuration for the product.
	Docker *DockerConfig `yaml:"docker,omitempty"`

	// Dependencies specifies the first-level dependencies of this product. Stores the IDs of the products.
	Dependencies *[]distgo.ProductID `yaml:"dependencies,omitempty"`
}

ProductConfig represents user-specified configuration on how to build a specific product.

type ProjectConfig

type ProjectConfig struct {
	// Products maps product names to configurations.
	Products map[distgo.ProductID]ProductConfig `yaml:"products,omitempty"`

	// ProductDefaults specifies the default values that should be used for unspecified values in the products map. If a
	// field in a top-level key in a "ProductConfig" value in the "Products" map is nil and the corresponding value in
	// ProductDefaults is non-nil, the value in ProductDefaults is used.
	ProductDefaults ProductConfig `yaml:"product-defaults,omitempty"`

	// ScriptIncludes specifies a string that is appended to every script that is written out. Can be used to define
	// functions or constants for all scripts.
	ScriptIncludes string `yaml:"script-includes,omitempty"`

	// ProjectVersioner specifies the operation that is used to compute the version for the project. If unspecified,
	// defaults to using the git project versioner (refer to the "projectversioner/git" package for details on the
	// implementation of this operation).
	ProjectVersioner *ProjectVersionConfig `yaml:"project-versioner,omitempty"`

	// Exclude matches the paths to exclude when determining the projects to build.
	Exclude matcher.NamesPathsCfg `yaml:"exclude,omitempty"`
}

type ProjectVersionConfig

type ProjectVersionConfig struct {
	// Type is the type of the project versioner. This field must be non-empty and resolve to a valid ProjectVersioner.
	Type string `yaml:"type,omitempty"`

	// Config is the YAML configuration content for the project versioner.
	Config yaml.MapSlice `yaml:"config,omitempty"`
}

type PublishConfig

type PublishConfig struct {
	// GroupID is the product-specific configuration equivalent to the global GroupID configuration.
	GroupID *string `yaml:"group-id,omitempty"`

	// PublishInfo contains extra configuration for the publish operation. The key is the type of publish and the value
	// is the configuration for that publish operation type.
	PublishInfo *map[distgo.PublisherTypeID]PublisherConfig `yaml:"info,omitempty"`
}

type PublisherConfig

type PublisherConfig struct {
	Config *yaml.MapSlice `yaml:"config,omitempty"`
}

type RunConfig

type RunConfig struct {
	// Args contain the arguments provided to the product when invoked using the "run" task.
	Args *[]string `yaml:"args,omitempty"`
}

type TagTemplatesMap added in v1.7.0

type TagTemplatesMap struct {
	Templates   map[distgo.DockerTagID]string
	OrderedKeys []distgo.DockerTagID
}

func (*TagTemplatesMap) MarshalYAML added in v1.11.0

func (t *TagTemplatesMap) MarshalYAML() (interface{}, error)

func (*TagTemplatesMap) UnmarshalYAML added in v1.7.0

func (t *TagTemplatesMap) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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