gcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultScope = cloudresourcemanager.CloudPlatformScope

DefaultScope is the default scope to use for a GCP client

Variables

This section is empty.

Functions

func CloudSQLConditionType

func CloudSQLConditionType(state string) corev1alpha1.ConditionType

CloudSQLConditionType converts the given CloudSQL state string into a corresponding condition type

func CloudSQLStatusMessage

func CloudSQLStatusMessage(instanceName string, cloudSQLInstance *sqladmin.DatabaseInstance) string

CloudSQLStatusMessage returns a status message based on the state of the given instance

func GetGoogleClient

func GetGoogleClient(clientset kubernetes.Interface, namespace string, secretKey v1.SecretKeySelector,
	scopes ...string) (*http.Client, error)

GetGoogleClient returns a client object that can be used to interact with the Google API

func IsErrorAlreadyExists

func IsErrorAlreadyExists(err error) bool

IsErrorAlreadyExists gets a value indicating whether the given error represents a "conflict" response from the Google API

func IsErrorBadRequest

func IsErrorBadRequest(err error) bool

IsErrorBadRequest gets a value indicating whether the given error represents a "bad request" response from the Google API

func IsErrorNotFound

func IsErrorNotFound(err error) bool

IsErrorNotFound gets a value indicating whether the given error represents a "not found" response from the Google API

func IsOperationComplete

func IsOperationComplete(op *sqladmin.Operation) bool

IsOperationComplete returns true if the supplied operation is complete.

func IsOperationSuccessful

func IsOperationSuccessful(op *sqladmin.Operation) bool

IsOperationSuccessful returns true if the supplied operation was successful.

func ProviderCredentials

func ProviderCredentials(client kubernetes.Interface, p *gcpv1alpha1.Provider, scopes ...string) (*google.Credentials, error)

ProviderCredentials return google credentials based on the provider's credentials secret data

func TestPermissions

func TestPermissions(creds *google.Credentials, permissions []string) error

TestPermissions tests service account permission using provided credentials and assert that it has all the provided permissions. - return nil - if all permissions are found - return an error - if one or more expected permissions are not found

func WaitUntilOperationCompletes

func WaitUntilOperationCompletes(operationID string, provider *gcpv1alpha1.Provider,
	cloudSQLClient CloudSQLAPI, waitTime time.Duration) (*sqladmin.Operation, error)

WaitUntilOperationCompletes waits until the supplied operation is complete, returning an error if it does not complete within the supplied duration.

Types

type CloudSQLAPI

type CloudSQLAPI interface {
	GetInstance(project string, instance string) (*sqladmin.DatabaseInstance, error)
	CreateInstance(project string, databaseinstance *sqladmin.DatabaseInstance) (*sqladmin.Operation, error)
	DeleteInstance(project string, instance string) (*sqladmin.Operation, error)
	ListUsers(project string, instance string) (*sqladmin.UsersListResponse, error)
	UpdateUser(project string, instance string, name string, user *sqladmin.User) (*sqladmin.Operation, error)
	GetOperation(project string, operationID string) (*sqladmin.Operation, error)
}

CloudSQLAPI provides an interface for operations on CloudSQL instances

type CloudSQLAPIFactory

type CloudSQLAPIFactory interface {
	CreateAPIInstance(kubernetes.Interface, string, v1.SecretKeySelector) (CloudSQLAPI, error)
}

CloudSQLAPIFactory defines an interface for creating instances of the CloudSQLAPI interface.

type CloudSQLClient

type CloudSQLClient struct {
	*sqladmin.Service
}

CloudSQLClient implements the CloudSQLAPI interface for real CloudSQL instances

func NewCloudSQLClient

func NewCloudSQLClient(clientset kubernetes.Interface, namespace string, secretKey v1.SecretKeySelector) (*CloudSQLClient, error)

NewCloudSQLClient creates a new instance of a CloudSQLClient

func (*CloudSQLClient) CreateInstance

func (c *CloudSQLClient) CreateInstance(project string, databaseinstance *sqladmin.DatabaseInstance) (*sqladmin.Operation, error)

CreateInstance creates the given CloudSQL instance

func (*CloudSQLClient) DeleteInstance

func (c *CloudSQLClient) DeleteInstance(project string, instance string) (*sqladmin.Operation, error)

DeleteInstance deletes the given CloudSQL instance

func (*CloudSQLClient) GetInstance

func (c *CloudSQLClient) GetInstance(project string, instance string) (*sqladmin.DatabaseInstance, error)

GetInstance retrieves details for the requested CloudSQL instance

func (*CloudSQLClient) GetOperation

func (c *CloudSQLClient) GetOperation(project string, operationID string) (*sqladmin.Operation, error)

GetOperation retrieves the latest status for the given operation

func (*CloudSQLClient) ListUsers

func (c *CloudSQLClient) ListUsers(project string, instance string) (*sqladmin.UsersListResponse, error)

ListUsers lists all the users for the given CloudSQL instance

func (*CloudSQLClient) UpdateUser

func (c *CloudSQLClient) UpdateUser(project string, instance string, name string, user *sqladmin.User) (*sqladmin.Operation, error)

UpdateUser updates the given user for the given CloudSQL instance

type CloudSQLClientFactory

type CloudSQLClientFactory struct {
}

CloudSQLClientFactory will create a real CloudSQL client that talks to GCP

func (*CloudSQLClientFactory) CreateAPIInstance

func (c *CloudSQLClientFactory) CreateAPIInstance(clientset kubernetes.Interface, namespace string,
	secretKey v1.SecretKeySelector) (CloudSQLAPI, error)

CreateAPIInstance instantiates a real CloudSQL client that talks to GCP

type ProjectInfo

type ProjectInfo struct {
	// Name: The user-assigned display name of the Project.
	Name string
	// ID: The unique, user-assigned ID of the Project.
	ID string
	// Number: The number uniquely identifying the project.
	Number int64
	// CreateTime: Project Creation time.
	CreateTime string
	// Labels: The labels associated with this Project.
	Labels map[string]string
}

ProjectInfo represent GCP Project information

func Project

func Project(creds *google.Credentials) (*ProjectInfo, error)

Project returns project information

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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