Documentation
¶
Overview ¶
Package config provides types and functions for reading and writing librarian.yaml configuration files.
Index ¶
- Constants
- type API
- type Config
- type DartPackage
- type Default
- type GoAPI
- type GoModule
- type Library
- type PythonPackage
- type Release
- type RustCrate
- type RustDefault
- type RustDiscovery
- type RustDocumentationOverride
- type RustModule
- type RustPackageDependency
- type RustPaginationOverride
- type RustPoller
- type Source
- type Sources
- type Tool
Constants ¶
const ( // SpecProtobuf defines the name for service specifications based on // [Protobuf]. // // [Protobuf]: https://protocolbuffers.dev SpecProtobuf = "protobuf" // SpecDiscovery defines the name for service specifications based on // [Discovery docs]. // // [Discovery docs]: https://developers.google.com/discovery/v1/reference/apis SpecDiscovery = "discovery" // SpecOpenAPI defines the name for service specifications based on // [OpenAPI]. // // [OpenAPI]: https://swagger.io/specification/ SpecOpenAPI = "openapi" // SpecNone is used for client library specifications that combine two other // clients. The only case today is Cloud Storage for Rust. SpecNone = "none" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶ added in v0.1.1
type API struct {
// Path specifies which googleapis Path to generate from (for generated
// libraries).
Path string `yaml:"path,omitempty"`
}
API describes an API to include in a library.
type Config ¶
type Config struct {
// Language is the language for this workspace (go, python, rust).
Language string `yaml:"language"`
// Version is the librarian tool version to use.
Version string `yaml:"version,omitempty"`
// Repo is the repository name, such as "googleapis/google-cloud-python".
//
// TODO(https://github.com/googleapis/librarian/issues/3003): Remove this
// field when .repo-metadata.json generation is removed.
Repo string `yaml:"repo,omitempty"`
// Sources references external source repositories.
Sources *Sources `yaml:"sources,omitempty"`
// Release holds the configuration parameter for publishing and release subcommands.
Release *Release `yaml:"release,omitempty"`
// Default contains default settings for all libraries. They apply to all libraries unless overridden.
Default *Default `yaml:"default,omitempty"`
// Libraries contains configuration overrides for libraries that need
// special handling, and differ from default settings.
Libraries []*Library `yaml:"libraries,omitempty"`
}
Config represents a librarian.yaml configuration file.
type DartPackage ¶ added in v0.8.0
type DartPackage struct {
// APIKeysEnvironmentVariables is a comma-separated list of environment variable names
// that can contain API keys (e.g., "GOOGLE_API_KEY,GEMINI_API_KEY").
APIKeysEnvironmentVariables string `yaml:"api_keys_environment_variables,omitempty"`
// Dependencies is a comma-separated list of dependencies.
Dependencies string `yaml:"dependencies,omitempty"`
// DevDependencies is a comma-separated list of development dependencies.
DevDependencies string `yaml:"dev_dependencies,omitempty"`
// ExtraImports is additional imports to include in the generated library.
ExtraImports string `yaml:"extra_imports,omitempty"`
// IncludeList is a list of proto files to include (e.g., "date.proto", "expr.proto").
IncludeList []string `yaml:"include_list,omitempty"`
// IssueTrackerURL is the URL for the issue tracker.
IssueTrackerURL string `yaml:"issue_tracker_url,omitempty"`
// LibraryPathOverride overrides the library path.
LibraryPathOverride string `yaml:"library_path_override,omitempty"`
// NameOverride overrides the package name
NameOverride string `yaml:"name_override,omitempty"`
// Packages maps Dart package names to version constraints.
// Keys are in the format "package:googleapis_auth" and values are version strings like "^2.0.0".
// These are merged with default settings, with library settings taking precedence.
Packages map[string]string `yaml:"packages,omitempty"`
// PartFile is the path to a part file to include in the generated library.
PartFile string `yaml:"part_file,omitempty"`
// Prefixes maps protobuf package names to Dart import prefixes.
// Keys are in the format "prefix:google.protobuf" and values are the prefix names.
// These are merged with default settings, with library settings taking precedence.
Prefixes map[string]string `yaml:"prefixes,omitempty"`
// Protos maps protobuf package names to Dart import paths.
// Keys are in the format "proto:google.api" and values are import paths like "package:google_cloud_api/api.dart".
// These are merged with default settings, with library settings taking precedence.
Protos map[string]string `yaml:"protos,omitempty"`
// ReadmeAfterTitleText is text to insert in the README after the title.
ReadmeAfterTitleText string `yaml:"readme_after_title_text,omitempty"`
// ReadmeQuickstartText is text to use for the quickstart section in the README.
ReadmeQuickstartText string `yaml:"readme_quickstart_text,omitempty"`
// RepositoryURL is the URL to the repository for this package.
RepositoryURL string `yaml:"repository_url,omitempty"`
// TitleOverride overrides the API title.
TitleOverride string `yaml:"title_override,omitempty"`
// Version is the version of the dart package.
Version string `yaml:"version,omitempty"`
}
DartPackage contains Dart-specific library configuration.
type Default ¶ added in v0.8.0
type Default struct {
// Keep lists files and directories to preserve during regeneration.
Keep []string `yaml:"keep,omitempty"`
// Output is the directory where code is written. For example, for Rust
// this is src/generated.
Output string `yaml:"output,omitempty"`
// ReleaseLevel is either "stable" or "preview".
ReleaseLevel string `yaml:"release_level,omitempty"`
// TagFormat is the template for git tags, such as "{name}/v{version}".
TagFormat string `yaml:"tag_format,omitempty"`
// Transport is the transport protocol, such as "grpc+rest" or "grpc".
Transport string `yaml:"transport,omitempty"`
// Dart contains Dart-specific default configuration.
Dart *DartPackage `yaml:"dart,omitempty"`
// Rust contains Rust-specific default configuration.
Rust *RustDefault `yaml:"rust,omitempty"`
}
Default contains default settings for all libraries.
type GoAPI ¶ added in v0.8.0
type GoAPI struct {
Path string `yaml:"path,omitempty"`
ClientDirectory string `yaml:"client_directory,omitempty"`
DisableGAPIC bool `yaml:"disable_gapic,omitempty"`
ImportPath string `yaml:"import_path,omitempty"`
NestedProtos []string `yaml:"nested_protos,omitempty"`
ProtoPackage string `yaml:"proto_package,omitempty"`
}
GoAPI represents configuration for a single API within a Go module.
type GoModule ¶ added in v0.8.0
type GoModule struct {
DeleteGenerationOutputPaths []string `yaml:"delete_generation_output_paths,omitempty"`
GoAPIs []*GoAPI `yaml:"go_apis,omitempty"`
ModulePathVersion string `yaml:"module_path_version,omitempty"`
}
GoModule represents the Go-specific configuration for a library.
type Library ¶ added in v0.8.0
type Library struct {
// Name is the library name, such as "secretmanager" or "storage".
Name string `yaml:"name"`
// Version is the library version.
Version string `yaml:"version,omitempty"`
// API specifies which googleapis API to generate from (for generated
// libraries).
APIs []*API `yaml:"apis,omitempty"`
// CopyrightYear is the copyright year for the library.
CopyrightYear string `yaml:"copyright_year,omitempty"`
// DescriptionOverride overrides the library description.
DescriptionOverride string `yaml:"description_override,omitempty"`
// Keep lists files and directories to preserve during regeneration.
Keep []string `yaml:"keep,omitempty"`
// Output is the directory where code is written. This overrides
// Default.Output.
Output string `yaml:"output,omitempty"`
// ReleaseLevel is the release level, such as "stable" or "preview". This
// overrides Default.ReleaseLevel.
ReleaseLevel string `yaml:"release_level,omitempty"`
// Roots specifies the source roots to use for generation. Defaults to googleapis.
Roots []string `yaml:"roots,omitempty"`
// SkipGenerate disables code generation for this library.
SkipGenerate bool `yaml:"skip_generate,omitempty"`
// SkipPublish disables publishing for this library.
SkipPublish bool `yaml:"skip_publish,omitempty"`
// SkipRelease disables releasing for this library.
SkipRelease bool `yaml:"skip_release,omitempty"`
// SpecificationFormat specifies the API specification format. Valid values
// are "protobuf" (default) or "discovery".
SpecificationFormat string `yaml:"specification_format,omitempty"`
// Transport is the transport protocol, such as "grpc+rest" or "grpc". This
// overrides Default.Transport.
Transport string `yaml:"transport,omitempty"`
// Veneer indicates this library has handwritten code. A veneer may
// contain generated libraries.
Veneer bool `yaml:"veneer,omitempty"`
// Dart contains Dart-specific library configuration.
Dart *DartPackage `yaml:"dart,omitempty"`
// Go contains Go-specific library configuration.
Go *GoModule `yaml:"go,omitempty"`
// Python contains Python-specific library configuration.
Python *PythonPackage `yaml:"python,omitempty"`
// Rust contains Rust-specific library configuration.
Rust *RustCrate `yaml:"rust,omitempty"`
}
Library represents a library configuration.
type PythonPackage ¶ added in v0.8.0
type PythonPackage struct {
// OptArgs contains additional options passed to the generator, where
// the options are common to all apis.
// Example: ["warehouse-package-name=google-cloud-batch"]
OptArgs []string `yaml:"opt_args,omitempty"`
// OptArgsByAPI contains additional options passed to the generator,
// where the options vary by api. In each entry, the key is the api
// (API path) and the value is the list of options to pass when generating
// that API.
// Example: {"google/cloud/secrets/v1beta": ["python-gapic-name=secretmanager"]}
OptArgsByAPI map[string][]string `yaml:"opt_args_by_api,omitempty"`
}
PythonPackage contains Python-specific library configuration.
type Release ¶ added in v0.8.0
type Release struct {
// Branch sets the name of the release branch, typically `main`
Branch string `yaml:"branch,omitempty"`
// IgnoredChanges defines globs that are ignored in change analysis.
IgnoredChanges []string `yaml:"ignored_changes,omitempty"`
// Preinstalled tools defines the list of tools that must be preinstalled.
//
// This is indexed by the well-known name of the tool vs. its path, e.g.
// [preinstalled]
// cargo = /usr/bin/cargo
Preinstalled map[string]string `yaml:"preinstalled,omitempty"`
// Remote sets the name of the source-of-truth remote for releases, typically `upstream`.
Remote string `yaml:"remote,omitempty"`
// An alternative location for the `roots.pem` file. If empty it has no
// effect.
RootsPem string `yaml:"roots_pem,omitempty"`
// Tools defines the list of tools to install, indexed by installer.
Tools map[string][]Tool `yaml:"tools,omitempty"`
}
Release holds the configuration parameter for publish command.
type RustCrate ¶ added in v0.8.0
type RustCrate struct {
RustDefault `yaml:",inline"`
// Modules specifies generation targets for veneer crates. Each module
// defines a source proto path, output location, and template to use.
// This is only used when the library has veneer: true.
Modules []*RustModule `yaml:"modules,omitempty"`
// PerServiceFeatures enables per-service feature flags.
PerServiceFeatures bool `yaml:"per_service_features,omitempty"`
// ModulePath is the module path for the crate.
ModulePath string `yaml:"module_path,omitempty"`
// TemplateOverride overrides the default template.
TemplateOverride string `yaml:"template_override,omitempty"`
// PackageNameOverride overrides the package name.
PackageNameOverride string `yaml:"package_name_override,omitempty"`
// RootName is the root name for the crate.
RootName string `yaml:"root_name,omitempty"`
// DefaultFeatures is a list of default features to enable.
DefaultFeatures []string `yaml:"default_features,omitempty"`
// IncludeList is a list of proto files to include (e.g., "date.proto", "expr.proto").
IncludeList []string `yaml:"include_list,omitempty"`
// IncludedIds is a list of IDs to include.
IncludedIds []string `yaml:"included_ids,omitempty"`
// SkippedIds is a list of IDs to skip.
SkippedIds []string `yaml:"skipped_ids,omitempty"`
// DisabledClippyWarnings is a list of clippy warnings to disable.
DisabledClippyWarnings []string `yaml:"disabled_clippy_warnings,omitempty"`
// HasVeneer indicates whether the crate has a veneer.
HasVeneer bool `yaml:"has_veneer,omitempty"`
// RoutingRequired indicates whether routing is required.
RoutingRequired bool `yaml:"routing_required,omitempty"`
// IncludeGrpcOnlyMethods indicates whether to include gRPC-only methods.
IncludeGrpcOnlyMethods bool `yaml:"include_grpc_only_methods,omitempty"`
// PostProcessProtos indicates whether to post-process protos.
PostProcessProtos string `yaml:"post_process_protos,omitempty"`
// DetailedTracingAttributes indicates whether to include detailed tracing attributes.
DetailedTracingAttributes bool `yaml:"detailed_tracing_attributes,omitempty"`
// DocumentationOverrides contains overrides for element documentation.
DocumentationOverrides []RustDocumentationOverride `yaml:"documentation_overrides,omitempty"`
// PaginationOverrides contains overrides for pagination configuration.
PaginationOverrides []RustPaginationOverride `yaml:"pagination_overrides,omitempty"`
// NameOverrides contains codec-level overrides for type and service names.
NameOverrides string `yaml:"name_overrides,omitempty"`
// Discovery contains discovery-specific configuration for LRO polling.
Discovery *RustDiscovery `yaml:"discovery,omitempty"`
}
RustCrate contains Rust-specific library configuration. It inherits from RustDefault, allowing library-specific overrides of global settings.
type RustDefault ¶ added in v0.8.0
type RustDefault struct {
// PackageDependencies is a list of default package dependencies. These
// are inherited by all libraries. If a library defines its own
// package_dependencies, the library-specific ones take precedence over
// these defaults for dependencies with the same name.
PackageDependencies []*RustPackageDependency `yaml:"package_dependencies,omitempty"`
// DisabledRustdocWarnings is a list of rustdoc warnings to disable.
DisabledRustdocWarnings []string `yaml:"disabled_rustdoc_warnings,omitempty"`
// GenerateSetterSamples indicates whether to generate setter samples.
GenerateSetterSamples string `yaml:"generate_setter_samples,omitempty"`
// GenerateRpcSamples indicates whether to generate RPC samples.
GenerateRpcSamples string `yaml:"generate_rpc_samples,omitempty"`
}
RustDefault contains Rust-specific default configuration.
type RustDiscovery ¶ added in v0.8.0
type RustDiscovery struct {
// OperationID is the ID of the LRO operation type (e.g., ".google.cloud.compute.v1.Operation").
OperationID string `yaml:"operation_id"`
// Pollers is a list of LRO polling configurations.
Pollers []RustPoller `yaml:"pollers,omitempty"`
}
RustDiscovery contains discovery-specific configuration for LRO polling.
type RustDocumentationOverride ¶ added in v0.8.0
type RustDocumentationOverride struct {
// ID is the fully qualified element ID (e.g., .google.cloud.dialogflow.v2.Message.field).
ID string `yaml:"id"`
// Match is the text to match in the documentation.
Match string `yaml:"match"`
// Replace is the replacement text.
Replace string `yaml:"replace"`
}
RustDocumentationOverride represents a documentation override for a specific element.
type RustModule ¶ added in v0.8.0
type RustModule struct {
// DisabledRustdocWarnings specifies rustdoc lints to disable. An empty slice explicitly enables all warnings.
DisabledRustdocWarnings yaml.StringSlice `yaml:"disabled_rustdoc_warnings,omitempty"`
// DocumentationOverrides contains overrides for element documentation.
DocumentationOverrides []RustDocumentationOverride `yaml:"documentation_overrides,omitempty"`
// ExtendGrpcTransport indicates whether the transport stub can be
// extended (in order to support streams).
ExtendGrpcTransport bool `yaml:"extend_grpc_transport,omitempty"`
// GenerateSetterSamples indicates whether to generate setter samples.
GenerateSetterSamples string `yaml:"generate_setter_samples,omitempty"`
// GenerateRpcSamples indicates whether to generate RPC samples.
GenerateRpcSamples string `yaml:"generate_rpc_samples,omitempty"`
// HasVeneer indicates whether this module has a handwritten wrapper.
HasVeneer bool `yaml:"has_veneer,omitempty"`
// IncludedIds is a list of proto IDs to include in generation.
IncludedIds []string `yaml:"included_ids,omitempty"`
// IncludeGrpcOnlyMethods indicates whether to include gRPC-only methods.
IncludeGrpcOnlyMethods bool `yaml:"include_grpc_only_methods,omitempty"`
// IncludeList is a list of proto files to include (e.g., "date.proto,expr.proto").
IncludeList string `yaml:"include_list,omitempty"`
// InternalBuilders indicates whether generated builders should be internal to the crate.
InternalBuilders bool `yaml:"internal_builders,omitempty"`
// Language can be used to select a variation of the Rust generator.
// For example, `rust_storage` enables special handling for the storage client.
Language string `yaml:"language,omitempty"`
// ModulePath is the Rust module path for converters
// (e.g., "crate::generated::gapic::model").
ModulePath string `yaml:"module_path,omitempty"`
ModuleRoots map[string]string `yaml:"module_roots,omitempty"`
// NameOverrides contains codec-level overrides for type and service names.
NameOverrides string `yaml:"name_overrides,omitempty"`
// Output is the directory where generated code is written
// (e.g., "src/storage/src/generated/gapic").
Output string `yaml:"output"`
// PostProcessProtos contains code to post-process generated protos.
PostProcessProtos string `yaml:"post_process_protos,omitempty"`
// RootName is the key for the root directory in the source map.
// It overrides the default root, googleapis-root, used by the rust+prost generator.
RootName string `yaml:"root_name,omitempty"`
// RoutingRequired indicates whether routing is required.
RoutingRequired bool `yaml:"routing_required,omitempty"`
// ServiceConfig is the path to the service config file.
ServiceConfig string `yaml:"service_config,omitempty"`
// SkippedIds is a list of proto IDs to skip in generation.
SkippedIds []string `yaml:"skipped_ids,omitempty"`
// SpecificationFormat overrides the library-level specification format.
SpecificationFormat string `yaml:"specification_format,omitempty"`
// Source is the proto path to generate from (e.g., "google/storage/v2").
Source string `yaml:"source"`
// Template specifies which generator template to use.
// Valid values: "grpc-client", "http-client", "prost", "convert-prost", "mod".
Template string `yaml:"template"`
}
RustModule defines a generation target within a veneer crate. Each module specifies what proto source to use, which template to apply, and where to output the generated code.
type RustPackageDependency ¶ added in v0.8.0
type RustPackageDependency struct {
// Name is the dependency name. It is listed first so it appears at the top
// of each dependency entry in YAML.
Name string `yaml:"name"`
// Ignore prevents this package from being mapped to an external crate.
// When true, references to this package stay as `crate::` instead of being
// mapped to the external crate name. This is used for self-referencing
// packages like location and longrunning.
Ignore bool `yaml:"ignore,omitempty"`
// Package is the package name.
Package string `yaml:"package"`
// Source is the dependency source.
Source string `yaml:"source,omitempty"`
// Feature is the feature name for the dependency.
Feature string `yaml:"feature,omitempty"`
// ForceUsed forces the dependency to be used even if not referenced.
ForceUsed bool `yaml:"force_used,omitempty"`
// UsedIf specifies a condition for when the dependency is used.
UsedIf string `yaml:"used_if,omitempty"`
}
RustPackageDependency represents a package dependency configuration.
type RustPaginationOverride ¶ added in v0.8.0
type RustPaginationOverride struct {
// ID is the fully qualified method ID (e.g., .google.cloud.sql.v1.Service.Method).
ID string `yaml:"id"`
// ItemField is the name of the field used for items.
ItemField string `yaml:"item_field"`
}
RustPaginationOverride represents a pagination override for a specific method.
type RustPoller ¶ added in v0.8.0
type RustPoller struct {
// Prefix is an acceptable prefix for the URL path (e.g., "compute/v1/projects/{project}/zones/{zone}").
Prefix string `yaml:"prefix"`
// MethodID is the corresponding method ID (e.g., ".google.cloud.compute.v1.zoneOperations.get").
MethodID string `yaml:"method_id"`
}
RustPoller defines how to find a suitable poller RPC for discovery APIs.
type Source ¶ added in v0.8.0
type Source struct {
// Branch is the source's git branch to pull updates from.
// Unset should be interpreted as the repository default branch.
Branch string `yaml:"branch,omitempty"`
// Commit is the git commit hash or tag to use.
Commit string `yaml:"commit"`
// Dir is a local directory path to use instead of fetching.
// If set, Commit and SHA256 are ignored.
Dir string `yaml:"dir,omitempty"`
// SHA256 is the expected hash of the tarball for this commit.
SHA256 string `yaml:"sha256,omitempty"`
// Subpath is a directory inside the fetched archive that should be treated as
// the root for operations.
Subpath string `yaml:"subpath,omitempty"`
}
Source represents a source repository.
type Sources ¶ added in v0.8.0
type Sources struct {
// Conformance is the path to the `conformance-tests` repository, used as include directory for `protoc`.
Conformance *Source `yaml:"conformance,omitempty"`
// Discovery is the discovery-artifact-manager repository configuration.
Discovery *Source `yaml:"discovery,omitempty"`
// Googleapis is the googleapis repository configuration.
Googleapis *Source `yaml:"googleapis,omitempty"`
// ProtobufSrc is the path to the `protobuf` repository, used as include directory for `protoc`.
ProtobufSrc *Source `yaml:"protobuf,omitempty"`
// Showcase is the showcase repository configuration.
Showcase *Source `yaml:"showcase,omitempty"`
}
Sources references external source repositories.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bazel parses BUILD.bazel files to extract GAPIC configuration.
|
Package bazel parses BUILD.bazel files to extract GAPIC configuration. |
|
Package gapicyaml provides parsing for GAPIC YAML configuration files.
|
Package gapicyaml provides parsing for GAPIC YAML configuration files. |