client

package
v1.34.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreErrorCodes added in v1.24.0

func IgnoreErrorCodes(err error, codes ...int) error

IgnoreErrorCodes returns nil if the error matches one of the provided HTTP status codes.

func IgnoreNotFoundError added in v1.27.0

func IgnoreNotFoundError(err error) error

IgnoreNotFoundError returns nil if the error is a NotFound error. Otherwise, it returns the original error.

func IsErrorCode added in v1.24.0

func IsErrorCode(err error, codes ...int) bool

IsErrorCode checks if the error is of type googleapi.Error and the HTTP status matches one of the provided list of codes.

func IsNotFoundError added in v1.30.0

func IsNotFoundError(err error) bool

IsNotFoundError returns true if the error has a HTTP 404 status code.

Types

type Address added in v1.30.0

type Address = compute.Address

Address is a type alias for the GCP client type.

type ComputeClient added in v1.19.0

type ComputeClient interface {
	// GetExternalAddresses returns a list of all external IP addresses mapped to the names of their users.
	GetExternalAddresses(ctx context.Context, region string) (map[string][]string, error)
	// GetAddress returns a Address.
	GetAddress(ctx context.Context, region, name string) (*Address, error)

	// InsertNetwork creates a Network with the given specification.
	InsertNetwork(ctx context.Context, nw *Network) (*Network, error)
	// GetNetwork reads provider information for the specified Network.
	GetNetwork(ctx context.Context, id string) (*Network, error)
	// DeleteNetwork deletes the Network. Return no error if the network is not found
	DeleteNetwork(ctx context.Context, id string) error
	// PatchNetwork patches the network identified by id with the given specification.
	PatchNetwork(ctx context.Context, id string, nw *Network) (*Network, error)

	// InsertSubnet creates a Subnetwork with the given specification.
	InsertSubnet(ctx context.Context, region string, subnet *Subnetwork) (*Subnetwork, error)
	// GetSubnet returns the Subnetwork specified by id.
	GetSubnet(ctx context.Context, region, id string) (*Subnetwork, error)
	// PatchSubnet updates the Subnetwork specified by id with the given specification.
	PatchSubnet(ctx context.Context, region, id string, subnet *Subnetwork) (*Subnetwork, error)
	// DeleteSubnet deletes the Subnetwork specified by id.
	DeleteSubnet(ctx context.Context, region, id string) error
	// ExpandSubnet expands the subnet to the target CIDR.
	ExpandSubnet(ctx context.Context, region, id, cidr string) (*Subnetwork, error)

	// InsertRouter creates a router with the given specification.
	InsertRouter(ctx context.Context, region string, router *Router) (*Router, error)
	// GetRouter returns the Router specified by id.
	GetRouter(ctx context.Context, region, id string) (*Router, error)
	// PatchRouter updates the Router specified by id with the given specification.
	PatchRouter(ctx context.Context, region, id string, router *Router) (*Router, error)
	// DeleteRouter deletes the router specified by id.
	DeleteRouter(ctx context.Context, region, id string) error
	// ListRoutes lists all routes.
	ListRoutes(ctx context.Context) ([]*Route, error)
	// DeleteRoute deletes the specified route.
	DeleteRoute(ctx context.Context, id string) error

	// InsertFirewallRule creates a firewall rule with the given specification.
	InsertFirewallRule(ctx context.Context, firewall *Firewall) (*Firewall, error)
	// GetFirewallRule returns the firewall rule specified by id.
	GetFirewallRule(ctx context.Context, firewall string) (*Firewall, error)
	// PatchFirewallRule updates the firewall rule specified by id with the given specification.
	PatchFirewallRule(ctx context.Context, name string, firewall *Firewall) (*Firewall, error)
	// DeleteFirewallRule deletes  the firewall rule specified by id.
	DeleteFirewallRule(ctx context.Context, firewall string) error
	// ListFirewallRules lists all firewall rules.
	ListFirewallRules(ctx context.Context) ([]*Firewall, error)
}

ComputeClient is the interface for a GCP Compute API client that can perform all operations needed for the provider-extension.

func NewComputeClient added in v1.30.0

func NewComputeClient(ctx context.Context, serviceAccount *gcp.ServiceAccount) (ComputeClient, error)

NewComputeClient returns a client for Compute API. The client follows the following conventions: Unless stated otherwise all operations are synchronous: even on operations that are asynchronous on GCP API e.g. Insert operations returning compute.Operation. The client should wait until the completion of the respective operations before returning. Delete operations will ignore errors when the respective resource can not be found, meaning that the Delete operations will never return HTTP 404 errors. Update operations will ignore errors when the update operation is a no-op, meaning that Update operations will ignore HTTP 304 errors.

type DNSClient added in v1.18.0

type DNSClient interface {
	GetManagedZones(ctx context.Context) (map[string]string, error)
	CreateOrUpdateRecordSet(ctx context.Context, managedZone, name, recordType string, rrdatas []string, ttl int64) error
	DeleteRecordSet(ctx context.Context, managedZone, name, recordType string) error
}

DNSClient is an interface which must be implemented by GCP DNS clients.

func NewDNSClient added in v1.30.0

func NewDNSClient(ctx context.Context, serviceAccount *gcp.ServiceAccount) (DNSClient, error)

NewDNSClient returns a client for GCP's CloudDNS service.

type Factory added in v1.18.0

type Factory interface {
	// DNS returns a GCP cloud DNS service client.
	DNS(context.Context, client.Client, corev1.SecretReference) (DNSClient, error)
	// Storage returns a GCP (blob) storage client.
	Storage(context.Context, client.Client, corev1.SecretReference) (StorageClient, error)
	// Compute returns a GCP compute client.
	Compute(context.Context, client.Client, corev1.SecretReference) (ComputeClient, error)
	// IAM returns a GCP compute client.
	IAM(context.Context, client.Client, corev1.SecretReference) (IAMClient, error)
}

Factory is a factory that can produce clients for various GCP Services.

func New added in v1.30.0

func New() Factory

New returns a new instance of Factory.

type Firewall added in v1.30.0

type Firewall = compute.Firewall

Firewall is a type alias for the GCP client type.

type IAMClient added in v1.24.0

type IAMClient interface {
	GetServiceAccount(ctx context.Context, name string) (*ServiceAccount, error)
	CreateServiceAccount(ctx context.Context, accountID string) (*ServiceAccount, error)
	DeleteServiceAccount(context.Context, string) error
}

IAMClient is the client interface for the IAM API.

func NewIAMClient added in v1.24.0

func NewIAMClient(ctx context.Context, serviceAccount *gcp.ServiceAccount) (IAMClient, error)

NewIAMClient returns a new IAM client.

type InvalidUpdateError added in v1.30.0

type InvalidUpdateError struct {
	// contains filtered or unexported fields
}

InvalidUpdateError indicates an impossible update. When InvalidUpdateError is returned it means that an update was attempted on an immutable or unsupported field.

func NewInvalidUpdateError added in v1.30.0

func NewInvalidUpdateError(fields ...string) *InvalidUpdateError

NewInvalidUpdateError returns a new InvalidUpdateError.

func (InvalidUpdateError) Error added in v1.30.0

func (i InvalidUpdateError) Error() string

type Network added in v1.30.0

type Network = compute.Network

Network is a type alias for the GCP client type.

type Route added in v1.30.0

type Route = compute.Route

Route is a type alias for the GCP client type.

type Router added in v1.30.0

type Router = compute.Router

Router is a type alias for the GCP client type.

type RouterNat added in v1.30.0

type RouterNat = compute.RouterNat

RouterNat is a type alias for the GCP client type.

type ServiceAccount added in v1.30.0

type ServiceAccount = iam.ServiceAccount

ServiceAccount is a type alias for the GCP client type.

type StorageClient

type StorageClient interface {
	// GCS wrappers
	CreateBucketIfNotExists(ctx context.Context, bucketName, region string) error
	DeleteBucketIfExists(ctx context.Context, bucketName string) error
	DeleteObjectsWithPrefix(ctx context.Context, bucketName, prefix string) error
}

StorageClient is an interface which must be implemented by GCS clients.

func NewStorageClient

func NewStorageClient(ctx context.Context, serviceAccount *gcp.ServiceAccount) (StorageClient, error)

NewStorageClient creates a new storage client from the given serviceAccount.

func NewStorageClientFromSecretRef

func NewStorageClientFromSecretRef(ctx context.Context, c client.Client, secretRef corev1.SecretReference) (StorageClient, error)

NewStorageClientFromSecretRef creates a new storage client from the given <secretRef>.

type Subnetwork added in v1.30.0

type Subnetwork = compute.Subnetwork

Subnetwork is a type alias for the GCP client type.

type Updater added in v1.30.0

type Updater interface {
	// VPC updates the respective infrastructure object according to desired state.
	VPC(ctx context.Context, client ComputeClient, desired, current *compute.Network) (*compute.Network, error)
	// Subnet updates the respective infrastructure object according to desired state.
	Subnet(ctx context.Context, client ComputeClient, region string, desired, current *compute.Subnetwork) (*compute.Subnetwork, error)
	// Router updates the respective infrastructure object according to desired state.
	Router(ctx context.Context, client ComputeClient, region string, desired, current *compute.Router) (*compute.Router, error)
	// NAT updates the respective infrastructure object according to desired state.
	NAT(ctx context.Context, client ComputeClient, region string, router *compute.Router, desired *compute.RouterNat) (*compute.Router, *compute.RouterNat, error)
	// DeleteNAT deletes the NAT gateway from the respective router.
	// Since NAT Gateways are a property of Cloud Routers, DeleteNAT is a special update function for the CloudRouter that
	// will remove the NAT with specified name.
	DeleteNAT(ctx context.Context, client ComputeClient, region, router, nat string) (*compute.Router, error)
	// Firewall updates the respective infrastructure object according to desired state.
	Firewall(ctx context.Context, client ComputeClient, firewall *compute.Firewall) (*compute.Firewall, error)
}

Updater can perform operations to update infrastructure resources.

func NewUpdater added in v1.30.0

func NewUpdater(f Factory, sa *gcp.ServiceAccount, log logr.Logger) Updater

NewUpdater returns a new instance of Updater.

Directories

Path Synopsis
Package client is a generated GoMock package.
Package client is a generated GoMock package.

Jump to

Keyboard shortcuts

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