Documentation ¶
Index ¶
- func CreateComputeClient(ctx *context.Context, oauth string, ce string) (daisyCompute.Client, error)
- func GetGlobalResourcePath(resourceType string, resourceName string) string
- func GetImageResourcePath(projectID, imageName string) string
- func GetProjectID(mgce domain.MetadataGCEInterface, projectFlag string) (string, error)
- func GetRegionalResourcePath(region string, resourceType string, resourceName string) string
- func GetZonalResourcePath(zone string, resourceType string, resourceName string) string
- func ParseKeyValues(keyValues string) (map[string]string, error)
- func PopulateProjectIfMissing(mgce domain.MetadataGCEInterface, projectFlag *string) error
- func PopulateRegion(region *string, zone string) error
- type NetworkResolver
- type Populator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateComputeClient ¶
func CreateComputeClient(ctx *context.Context, oauth string, ce string) (daisyCompute.Client, error)
CreateComputeClient creates a new compute client
func GetGlobalResourcePath ¶
GetGlobalResourcePath gets global resource path based on either a local resource name or a path
func GetImageResourcePath ¶
GetImageResourcePath gets the resource path for an image. It will panic if either projectID or imageName is invalid. To avoid panic, pre-validate using the functions in the `validation` package.
func GetProjectID ¶
func GetProjectID(mgce domain.MetadataGCEInterface, projectFlag string) (string, error)
GetProjectID gets project id from flag if exists; otherwise, try to retrieve from GCE metadata.
func GetRegionalResourcePath ¶
GetRegionalResourcePath gets regional resource path based on either a local resource name or a path
func GetZonalResourcePath ¶
GetZonalResourcePath gets zonal resource path based on either a local resource name or a path
func ParseKeyValues ¶
ParseKeyValues parses a comma-separated list of [key=value] pairs.
func PopulateProjectIfMissing ¶
func PopulateProjectIfMissing(mgce domain.MetadataGCEInterface, projectFlag *string) error
PopulateProjectIfMissing populates project id for cli tools
func PopulateRegion ¶
PopulateRegion populates region based on the value extracted from zone param
Types ¶
type NetworkResolver ¶
type NetworkResolver interface { // Resolve returns the URI representation of network and subnet // within a given region. // // There are two goals: // // a. Explicitly use the 'default' network only when // network is omitted and subnet is empty. // b. Convert bare identifiers to URIs. Resolve(originalNetwork, originalSubnet, region, project string) (network, subnet string, err error) }
NetworkResolver standardizes and validates network and subnet fields. It follows the rules from the `networkInterfaces[].network` section of instances.insert:
https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert - When both subnet and network are empty, explicitly use the default network. - If the subnet is empty, leave it empty to allow the compute backend to infer it. - Similarly, if only the network is empty, leave it empty to allow inference. - Backfill project and region resource properties if they are omitted in the network and subnet URIs.
func NewNetworkResolver ¶
func NewNetworkResolver(client daisyCompute.Client) NetworkResolver
NewNetworkResolver returns a NetworkResolver implementation that uses the Compute API.
type Populator ¶
type Populator interface { PopulateMissingParameters(project *string, clientID string, zone *string, region *string, scratchBucketGcsPath *string, file string, storageLocation, network, subnet *string) error }
Populator standardizes user input, and determines omitted values.
func NewPopulator ¶
func NewPopulator( NetworkResolver NetworkResolver, metadataClient domain.MetadataGCEInterface, storageClient domain.StorageClientInterface, locationClient domain.ResourceLocationRetrieverInterface, scratchBucketClient domain.ScratchBucketCreatorInterface) Populator
NewPopulator returns an object that implements Populator.