docker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 14 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 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 (
	// CommandGenerateRaw performs raw (unconfigured) generation.
	CommandGenerateRaw Command = "generate-raw"
	// CommandGenerateLibrary performs generation for a configured library.
	CommandGenerateLibrary Command = "generate-library"
	// CommandClean cleans files generated for a library.
	CommandClean Command = "clean"
	// CommandBuildRaw builds the results of generate-raw.
	CommandBuildRaw Command = "build-raw"
	// CommandBuildLibrary builds a library.
	CommandBuildLibrary Command = "build-library"
	// CommandConfigure configures a new API as a library.
	CommandConfigure Command = "configure"
	// CommandPrepareLibraryRelease prepares a repository for the release of a library.
	CommandPrepareLibraryRelease Command = "prepare-library-release"
	// CommandIntegrationTestLibrary runs integration tests on a library.
	CommandIntegrationTestLibrary Command = "integration-test-library"
	// CommandPackageLibrary packages a library's artifacts for publication.
	CommandPackageLibrary Command = "package-library"
	// CommandPublishLibrary publishes a library's artifacts.
	CommandPublishLibrary Command = "publish-library"
)

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

type Docker

type Docker struct {
	// The Docker image to run.
	Image string
	// contains filtered or unexported fields
}

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

func New

func New(workRoot, image, secretsProject, uid, gid string, pipelineConfig *statepb.PipelineConfig) (*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) BuildLibrary

func (c *Docker) BuildLibrary(ctx context.Context, cfg *config.Config, repoRoot, libraryID string) error

BuildLibrary 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) BuildRaw

func (c *Docker) BuildRaw(ctx context.Context, cfg *config.Config, generatorOutput, apiPath string) error

BuildRaw builds the result of GenerateRaw, which previously generated code for apiPath in generatorOutput.

func (*Docker) Clean

func (c *Docker) Clean(ctx context.Context, cfg *config.Config, repoRoot, libraryID string) error

Clean deletes files within repoRoot which are generated for library libraryID, as configured in the Librarian state file for the repository.

func (*Docker) Configure

func (c *Docker) Configure(ctx context.Context, cfg *config.Config, apiRoot, apiPath, generatorInput string) error

Configure configures an API within a repository, either adding it to an existing library or creating a new library. The API is indicated by the apiPath directory within apiRoot, and the container is provided with the generatorInput directory to record the results of configuration. The library code is not generated.

func (*Docker) GenerateLibrary

func (c *Docker) GenerateLibrary(ctx context.Context, cfg *config.Config, apiRoot, output, generatorInput, libraryID string) error

GenerateLibrary performs generation for an API which is configured as part of a library. apiRoot specifies the root directory of the API specification repo, output specifies the empty output directory into which the command should generate code, and libraryID specifies the ID of the library to generate, as configured in the Librarian state file for the repository.

func (*Docker) GenerateRaw

func (c *Docker) GenerateRaw(ctx context.Context, cfg *config.Config, apiRoot, output, apiPath string) error

GenerateRaw performs generation for an API not configured in a library. This does not have any context from a language repo: it requires generation purely on the basis of the API specification, which is in the subdirectory apiPath of the API specification repo apiRoot, and whatever is in the language-specific Docker container. The code is generated in the output directory, which is initially empty.

func (*Docker) IntegrationTestLibrary

func (c *Docker) IntegrationTestLibrary(ctx context.Context, cfg *config.Config, repoRoot, libraryID string) error

IntegrationTestLibrary runs the integration tests for a library with ID libraryID within repoRoot.

func (*Docker) PackageLibrary

func (c *Docker) PackageLibrary(ctx context.Context, cfg *config.Config, repoRoot, libraryID, output string) error

PackageLibrary packages release artifacts for a library with ID libraryID within repoRoot, creating the artifacts within output.

func (*Docker) PrepareLibraryRelease

func (c *Docker) PrepareLibraryRelease(ctx context.Context, cfg *config.Config, repoRoot, inputsDirectory, libraryID, releaseVersion string) error

PrepareLibraryRelease prepares the repository languageRepo for the release of a library with ID libraryID within repoRoot, with version releaseVersion. Release notes are expected to be present within inputsDirectory, in a file named `{libraryID}-{releaseVersion}-release-notes.txt`.

func (*Docker) PublishLibrary

func (c *Docker) PublishLibrary(ctx context.Context, cfg *config.Config, output, libraryID, releaseVersion string) error

PublishLibrary publishes release artifacts for a library with ID libraryID and version releaseVersion to package managers, documentation sites etc. The artifacts will previously have been created by PackageLibrary.

type EnvironmentProvider

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

EnvironmentProvider represents configuration for environment variables for docker invocations.

Jump to

Keyboard shortcuts

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