param

package
v0.0.0-...-c23f332 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func GetGlobalResourcePath(resourceType string, resourceName string) string

GetGlobalResourcePath gets global resource path based on either a local resource name or a path

func GetImageResourcePath

func GetImageResourcePath(projectID, imageName string) string

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

func GetRegionalResourcePath(region string, resourceType string, resourceName string) string

GetRegionalResourcePath gets regional resource path based on either a local resource name or a path

func GetZonalResourcePath

func GetZonalResourcePath(zone string, resourceType string, resourceName string) string

GetZonalResourcePath gets zonal resource path based on either a local resource name or a path

func ParseKeyValues

func ParseKeyValues(keyValues string) (map[string]string, error)

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

func PopulateRegion(region *string, zone string) error

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.

Jump to

Keyboard shortcuts

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