Documentation
¶
Overview ¶
Package config defines configuration used by the CLI.
Index ¶
Constants ¶
const ( // BuildRequest is a JSON file that describes which library to build/test. BuildRequest = "build-request.json" // ConfigureRequest is a JSON file that describes which library to configure. ConfigureRequest = "configure-request.json" // ConfigureResponse is a JSON file that describes which library to change // after initial configuration. ConfigureResponse = "configure-response.json" // GeneratorInputDir is the default directory to store files that generator // needs to regenerate libraries from an empty directory. GeneratorInputDir = ".librarian/generator-input" // GenerateRequest is a JSON file that describes which library to generate. GenerateRequest = "generate-request.json" // LibrarianDir is the default directory to store librarian state/config files, // along with any additional configuration. LibrarianDir = ".librarian" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶ added in v0.1.1
type API struct {
// The path to the API, relative to the root of the API definition repository (e.g., "google/storage/v1").
Path string `yaml:"path" json:"path"`
// The name of the service config file, relative to the API `path`.
ServiceConfig string `yaml:"service_config" json:"service_config"`
}
API represents an API that is part of a library.
type Config ¶
type Config struct {
// API is the path to the API to be configured or generated,
// relative to the root of the googleapis repository. It is a directory
// name as far as (and including) the version (v1, v2, v1alpha etc). It
// is expected to contain a service config YAML file.
// Example: "google/cloud/functions/v2"
//
// API is used by generate and configure commands.
//
// API Path is specified with the -api flag.
API string
// APISource is the path to the root of the googleapis repository.
// When this is not specified, the googleapis repository is cloned
// automatically.
//
// APISource is used by generate, update-apis and configure
// commands.
//
// APISource is specified with the -api-source flag.
APISource string
// Build determines whether to build the generated library, and is only
// used in the generate command.
//
// Build is specified with the -build flag.
Build bool
// CI is the type of Continuous Integration (CI) environment in which
// the tool is executing.
CI string
// GitHubToken is the access token to use for all operations involving
// GitHub.
//
// GitHubToken is used by to configure, update-apis and update-image-tag commands,
// when Push is true.
//
// GitHubToken is not specified by a flag, as flags are logged and the
// access token is sensitive information. Instead, it is fetched from the
// LIBRARIAN_GITHUB_TOKEN environment variable.
GitHubToken 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 is specified with the -host-mount flag.
HostMount string
// Image is the language-specific container image to use for language-specific
// operations. It is primarily used for testing Librarian and/or new images.
//
// Image is used by all commands which perform language-specific operations.
// If this is set via the -image flag, it is expected to be used directly
// (potentially including a repository and/or tag). If the -image flag is not
// set, use an image configured in the `config.yaml`.
//
// Image is specified with the -image flag.
Image string
// Library is the library ID to generate (e.g. google-cloud-secretmanager-v1 ).
// This usually corresponds to a releasable language unit -- for Go this would
// be a Go module or for dotnet the name of a NuGet package. If neither this nor
// api is specified all currently managed libraries will be regenerated.
Library string
// Push determines whether to push changes to GitHub. It is used in
// all commands that create commits in a language repository:
// configure and update-apis.
// These commands all create pull requests if they
//
// By default (when Push isn't explicitly specified), commits are created in
// the language repo (whether a fresh clone or one specified with RepoRoot)
// but no pull request is created. In this situation, the description of the
// pull request that would have been created is displayed in the output of
// the command.
//
// When Push is true, GitHubToken must also be specified.
//
// Push is specified with the -push flag. No value is required.
Push bool
// Repo specifies the language repository to use, as either a local root directory
// or a URL to clone from. If a local directory is specified, it can
// be relative to the current working directory. The repository must
// be in a clean state (i.e. git status should report no changes) to avoid mixing
// Librarian-created changes with other changes.
//
// Repo is used by all commands which operate on a language repository:
// configure, generate, update-apis.
//
// When a local directory is specified for the generate command, the repo is checked to
// determine whether the specified API path is configured as a library. See the generate
// command documentation for more details.
// For all commands other than generate, omitting Repo is equivalent to
// specifying Repo as https://github.com/googleapis/google-cloud-{Language}.
//
// Repo is specified with the -repo flag.
Repo 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.
//
// This is populated automatically after flag parsing. No user setup is
// expected.
UserGID string
// 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.
//
// This is populated automatically after flag parsing. No user setup is
// expected.
UserUID string
// WorkRoot is the root directory used for temporary working files, including
// any repositories that are cloned. By default, this is created in /tmp with
// a timestamped directory name (e.g. /tmp/librarian-20250617T083548Z) but
// can be specified with the -output flag.
//
// WorkRoot is used by all librarian commands.
WorkRoot string
}
Config holds all configuration values parsed from flags or environment variables. When adding members to this struct, please keep them in alphabetical order.
type LibrarianState ¶ added in v0.1.1
type LibrarianState struct {
// The name and tag of the generator image to use. tag is required.
Image string `yaml:"image"`
// A list of library configurations.
Libraries []*LibraryState `yaml:"libraries"`
}
LibrarianState defines the contract for the state.yaml file.
func (*LibrarianState) ImageRefAndTag ¶ added in v0.1.1
func (s *LibrarianState) ImageRefAndTag() (ref string, tag string)
ImageRefAndTag extracts the image reference and tag from the full image string. For example, for "gcr.io/my-image:v1.2.3", it returns a reference to "gcr.io/my-image" and the tag "v1.2.3". If no tag is present, the returned tag is an empty string.
func (*LibrarianState) Validate ¶ added in v0.1.1
func (s *LibrarianState) Validate() error
Validate checks that the LibrarianState is valid.
type LibraryState ¶ added in v0.1.1
type LibraryState struct {
// A unique identifier for the library, in a language-specific format.
// A valid ID should not be empty and only contains alphanumeric characters, slashes, periods, underscores, and hyphens.
ID string `yaml:"id" json:"id"`
// The last released version of the library, following SemVer.
Version string `yaml:"version" json:"version"`
// The commit hash from the API definition repository at which the library was last generated.
LastGeneratedCommit string `yaml:"last_generated_commit" json:"last_generated_commit"`
// A list of APIs that are part of this library.
APIs []*API `yaml:"apis" json:"apis"`
// A list of directories in the language repository where Librarian contributes code.
SourceRoots []string `yaml:"source_roots" json:"source_roots"`
// A list of regular expressions for files and directories to preserve during the copy and remove process.
PreserveRegex []string `yaml:"preserve_regex" json:"preserve_regex"`
// A list of regular expressions for files and directories to remove before copying generated code.
// If not set, this defaults to the `source_roots`.
// A more specific `preserve_regex` takes precedence.
RemoveRegex []string `yaml:"remove_regex" json:"remove_regex"`
}
LibraryState represents the state of a single library within state.yaml.
func (*LibraryState) Validate ¶ added in v0.1.1
func (l *LibraryState) Validate() error
Validate checks that the Library is valid.