Documentation
¶
Overview ¶
Package gcloud provides a code generator for gcloud commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CLIModel ¶ added in v0.12.0
type CLIModel struct {
// ModulePath is the Go module path used to construct the import path
// of each surface package, e.g. "cloud.google.com/go/gcloud" yields
// imports like "cloud.google.com/go/gcloud/internal/generated/parallelstore".
ModulePath string
// Surfaces lists every surface registered under the gcloud root
// command, in the order they should appear in the Commands slice.
Surfaces []SurfaceRef
}
CLIModel is the data passed to the cmd/gcloud/main.go template.
type ClientCall ¶ added in v0.12.1
type ClientCall struct {
// IsDelete reports whether the method is a standard Delete method.
IsDelete bool
// IsLRO reports whether the call returns a long-running operation.
IsLRO bool
// Method is the unqualified client method to call on the constructed
// client, for example "GetInstance". The template invokes it as
// `client.<Method>(ctx, &<RequestType>{...})`.
Method string
// NameField is the field on the request message that takes the
// composed resource path, for example "Name" for AIP-131 Get requests.
// The template assigns it from the local path variable.
NameField string
// Package is the import alias of the Go client package, for example
// "parallelstore". The template invokes the constructor as
// `client, err := <Package>.NewClient(ctx)`.
Package string
// Paged reports whether the method returns a paginated iterator (e.g.,
// AIP-132 List).
Paged bool
// RequestType is the qualified request message type, for example
// "parallelstorepb.GetInstanceRequest". The template composites a
// literal of this type and passes its address to the method.
RequestType string
}
ClientCall describes a Go client method invocation that should replace the default print-only action for a generated command.
type Command ¶
type Command struct {
Args []string
ClientCall *ClientCall
Flags []Flag
Name string
PathFormat string
PathLabel string
Usage string
}
Command represents a leaf command.
func (Command) HasPath ¶ added in v0.12.1
HasPath reports whether the command composes a resource path.
func (Command) PathFormatArgs ¶ added in v0.12.1
PathFormatArgs returns the comma-separated cmd.String("X") arguments passed to the generated fmt.Sprintf call.
func (Command) RequiresProject ¶ added in v0.13.0
RequiresProject reports whether the command's path references the "project" variable, in which case the generated Action must validate that the global --project flag is set.
type Flag ¶ added in v0.12.1
type Flag struct {
// Name is the long flag name without leading dashes (e.g. "project").
Name string
// Kind is the urfave/cli flag type (e.g. "String", "Bool").
Kind string
// Required reports whether the flag must be set on the command line.
Required bool
// Usage is the help text shown next to the flag.
//
// TODO(https://github.com/googleapis/librarian/issues/5769):
// Usage is currently a generic "The <name>." string. Source it from
// the proto field's documentation when we wire that through.
Usage string
}
Flag represents a single CLI flag.
type Import ¶ added in v0.12.1
type Import struct {
// Alias is the optional package alias; empty when the import has no
// alias. For example, "parallelstore" in:
//
// parallelstore "cloud.google.com/go/parallelstore/apiv1"
Alias string
// Path is the import path of the package, for example
// "cloud.google.com/go/parallelstore/apiv1".
Path string
}
Import represents a Go import line in a generated file.
type SurfaceModel ¶ added in v0.13.0
type SurfaceModel struct {
// PackageName is the Go package name and the directory under
// internal/generated/.
PackageName string
// Imports holds the Go imports rendered into the surface's
// commands.go, typically the GAPIC client and proto-Go packages used
// by ClientCall actions. It is empty when no command in the surface
// has a ClientCall.
Imports []Import
// Group is the surface's command tree: the root command for the
// surface, with its subgroups and commands beneath.
Group Group
}
SurfaceModel is the data passed to the surface_commands.go template. One surface model is rendered per generated package under internal/generated/.
type SurfaceRef ¶ added in v0.13.0
type SurfaceRef struct {
// PackageName is both the Go package name and the directory under
// internal/generated/, e.g. "parallelstore".
PackageName string
}
SurfaceRef references a generated surface package from the top-level main.go.