docker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package docker provides the interface for running language-specific Docker containers which conform to the Librarian container contract. TODO(https://github.com/googleapis/librarian/issues/330): link to the documentation when it's written.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildRequest added in v0.1.1

type BuildRequest struct {
	// LibraryID specifies the ID of the library to build.
	LibraryID string

	// RepoDir is the local root directory of the language repository.
	RepoDir string

	// State is a pointer to the [config.LibrarianState] struct, representing
	// the overall state of the generation and release pipeline.
	State *config.LibrarianState
}

BuildRequest contains all the information required for a language container to run the build command.

type Command

type Command string

Command is the string representation of a command to be passed to the language-specific container's entry point as the first argument.

const (
	// CommandBuild builds a library.
	CommandBuild Command = "build"
	// CommandConfigure configures a new API as a library.
	CommandConfigure Command = "configure"
	// CommandGenerate performs generation for a configured library.
	CommandGenerate Command = "generate"
	// CommandReleaseStage performs release for a library.
	CommandReleaseStage Command = "release-stage"
)

The set of commands passed to the language container, in a single place to avoid typos.

type ConfigureRequest added in v0.1.1

type ConfigureRequest struct {
	// ApiRoot specifies the root directory of the API specification repo.
	ApiRoot string

	// libraryID specifies the ID of the library to configure.
	LibraryID string

	// Output specifies the empty output directory into which the command should
	// generate code
	Output string

	// RepoDir is the local root directory of the language repository.
	RepoDir string

	// ExistingSourceRoots are existing source roots in the language repository.
	ExistingSourceRoots []string

	// GlobalFiles are global files of the language repository.
	GlobalFiles []string

	// State is a pointer to the [config.LibrarianState] struct, representing
	// the overall state of the generation and release pipeline.
	State *config.LibrarianState
}

ConfigureRequest contains all the information required for a language container to run the configure command.

type Docker

type Docker struct {
	// The Docker image to run.
	Image string

	// HostMount specifies a mount point from the Docker host into the Docker
	// container. The format is "{host-dir}:{local-dir}".
	HostMount string
	// contains filtered or unexported fields
}

Docker contains all the information required to run language-specific Docker containers.

func New

func New(workRoot, image string, options *DockerOptions) (*Docker, error)

New constructs a Docker instance which will invoke the specified Docker image as required to implement language-specific commands, providing the container with required environment variables.

func (*Docker) Build added in v0.1.1

func (c *Docker) Build(ctx context.Context, request *BuildRequest) error

Build builds the library with an ID of libraryID, as configured in the Librarian state file for the repository with a root of repoRoot.

func (*Docker) Configure

func (c *Docker) Configure(ctx context.Context, request *ConfigureRequest) (string, error)

Configure configures an API within a repository, either adding it to an existing library or creating a new library.

Returns the configured library id if the command succeeds.

func (*Docker) Generate added in v0.1.1

func (c *Docker) Generate(ctx context.Context, request *GenerateRequest) error

Generate performs generation for an API which is configured as part of a library.

func (*Docker) ReleaseStage added in v0.6.0

func (c *Docker) ReleaseStage(ctx context.Context, request *ReleaseStageRequest) error

ReleaseStage stages a release for a given language repository.

type DockerOptions added in v0.4.0

type DockerOptions struct {
	// UserUID is the user ID of the current user. It is used to run Docker
	// containers with the same user, so that created files have the correct
	// ownership.
	UserUID string
	// UserGID is the group ID of the current user. It is used to run Docker
	// containers with the same user, so that created files have the correct
	// ownership.
	UserGID string
	// HostMount is used to remap Docker mount paths when running in environments
	// where Docker containers are siblings (e.g., Kokoro).
	// It specifies a mount point from the Docker host into the Docker container.
	// The format is "{host-dir}:{local-dir}".
	HostMount string
}

DockerOptions contains optional configuration parameters for invoking docker commands.

type GenerateRequest added in v0.1.1

type GenerateRequest struct {
	// ApiRoot specifies the root directory of the API specification repo.
	ApiRoot string

	// LibraryID specifies the ID of the library to generate.
	LibraryID string

	// Output specifies the empty output directory into which the command should
	// generate code
	Output string

	// RepoDir is the local root directory of the language repository.
	RepoDir string

	// State is a pointer to the [config.LibrarianState] struct, representing
	// the overall state of the generation and release pipeline.
	State *config.LibrarianState
}

GenerateRequest contains all the information required for a language container to run the generate command.

type ReleaseStageRequest added in v0.6.0

type ReleaseStageRequest struct {
	// Branch is the remote branch of the language repository to use.
	Branch string

	// Commit determines whether to create a commit for the release but not
	// create a pull request. This flag is ignored if Push is set to true.
	Commit bool

	// LibrarianConfig is a pointer to the [config.LibrarianConfig] struct, holding
	// global files configuration in a language repository.
	LibrarianConfig *config.LibrarianConfig

	// LibraryID specifies the ID of the library to release.
	LibraryID string

	// LibraryVersion specifies the version of the library to release.
	LibraryVersion string

	// Output specifies the empty output directory into which the command should
	// generate code.
	Output string

	// RepoDir is the local root directory of language repository contains
	// files that make up libraries and global files.
	// This is the directory that container can access.
	RepoDir string

	// Push determines whether to push changes to GitHub.
	Push bool

	// State is a pointer to the [config.LibrarianState] struct, representing
	// the overall state of the generation and release pipeline.
	State *config.LibrarianState
}

ReleaseStageRequest contains all the information required for a language container to run the stage command.

Jump to

Keyboard shortcuts

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