gcp

package
v0.0.0-...-bcce8f3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const KeysCacheBucketName = "moneycol-keys"

Variables

This section is empty.

Functions

func ConfigureDocker

func ConfigureDocker()

func CreateGCSBucket

func CreateGCSBucket(projectID string, e string) error

func DeleteGCSBucket

func DeleteGCSBucket(projectID string, e string) error

func ListClusterNodePools

func ListClusterNodePools(project string, zone string, environment string) nodePoolList

ListClusterNodePools list the node pools in the GKE cluster

func NewKmsEncrypter

func NewKmsEncrypter(projectId string, locationId string, defaultKeyRingName string,
	defaultKeyName string) encryption.Encrypter

Creates a new encrypter using GCP KMS service

See: https://cloud.google.com/kms/docs/creating-keys

func ResizeCluster

func ResizeCluster(project string, zone string, environment string, targetSize int)

ResizeCluster change the size of GKE cluster node pools to the provided values

The resize command needs to be executed once per node pool:

gcloud container clusters resize NAME (--num-nodes=NUM_NODES | --size=NUM_NODES) [--async] [--node-pool=NODE_POOL] [--region=REGION | --zone=ZONE, -z ZONE]

func ResizePool

func ResizePool(project string, env string, poolName string, poolSize string, zone string)

ResizePool change node-pool size

func SetKeyEnvVar

func SetKeyEnvVar(k string)

Set OS Environment Variable so the key file is available gor gcloud cli

func SetupEnvironment

func SetupEnvironment(projectId string)

Deprecated see provider.go / setup_environment.go

func SetupKubernetes

func SetupKubernetes(project string, zone string, environment string)

Deprecated

Types

type Auth

type Auth interface {
	Authenticate()
	IsAuthenticated() bool
	Key() *ServiceAccountKey
}

func NewServiceAccountAuth

func NewServiceAccountAuth(keyLocation string) (Auth, error)

type DNSChangeRequest

type DNSChangeRequest interface {
	DNSProvider() string
	DomainName() string
}

func NewDNSChangeRequest

func NewDNSChangeRequest(dnsProvider string, domainName string, serviceName string) (DNSChangeRequest, error)

type DNSService

type DNSService interface {
	UpsertDNSEntry(dnsName string, ipAddress string) error
	UpsertDNSEntries(dnsEntries []string, ipAddress string) error
}

func NewDNSService

func NewDNSService(dnsProvider string, serviceName string) (DNSService, error)

type GoogleCloudDNSService

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

GoogleCloudDNSService is the service that allows to create or update dns records

func NewGoogleCloudDNSService

func NewGoogleCloudDNSService(project, zone string) *GoogleCloudDNSService

NewGoogleCloudDNSService Creates a GCP cloud dns service zone is the managedZone name (should've been created beforehand)

func (*GoogleCloudDNSService) GetDNSRecordByName

func (dnsService *GoogleCloudDNSService) GetDNSRecordByName(dnsRecordType, dnsRecordName string) (records []*dns.ResourceRecordSet)

GetDNSRecordByName returns the record sets matching name and type dnsRecordType is A, CNAME... dnsRecordName is the DNS itself (dev.moneycol.ml, ...)

func (*GoogleCloudDNSService) UpsertDNSEntries

func (dnsService *GoogleCloudDNSService) UpsertDNSEntries(dnsEntries []string, ipAddress string) error

func (*GoogleCloudDNSService) UpsertDNSEntry

func (dnsService *GoogleCloudDNSService) UpsertDNSEntry(dnsName string, ipAddress string) error

func (*GoogleCloudDNSService) UpsertDNSRecord

func (dnsService *GoogleCloudDNSService) UpsertDNSRecord(dnsRecordType, dnsRecordName, dnsRecordContent string) (err error)

UpsertDNSRecord either updates or creates a dns record. dnsRecordContent is usually and IP address or an alias to another service (A and CNAME records)

type IamGcpClient

type IamGcpClient interface {
	CreateKey(request *iam.CreateServiceAccountKeyRequest, resource string) (*iam.ServiceAccountKey, error)
	ListKeys(resource string) (*iam.ListServiceAccountKeysResponse, error)
}

IamClient wrapper interface around GCP Service Account Client that allows creation and listing of Service Account keys. Instead of extracting the exact methods from GCP *iam.Service, they are wrapped on these 2 operations (CreateKey, ListKeys). This is due to the complicated call chains inside *iam.Service (i.e. 'Projects.ServiceAccounts.Keys.Create(...)')

func NewDefaultIamClient

func NewDefaultIamClient() IamGcpClient

NewGcpIamClient Creates a new IamClient with default context. Authentication against GCP must have already been performed when invoking this operation

func NewGcpIamClient

func NewGcpIamClient(ctx context.Context, iamService *iam.Service) IamGcpClient

NewGcpIamClient Creates a new IamClient with external provided context and *iam.Service

type ObjectStorageCache

type ObjectStorageCache interface {
	Write(ctx context.Context, bucketName string, key string, content interface{}) error
	Read(ctx context.Context, bucketName string, objectKey string) (interface{}, error)
}

ObjectStorageCache allows management of basic object storage operations in GCP (write, read). Abstracts the operations needed from the GCP SDK

func NewDefaultObjectStorageCache

func NewDefaultObjectStorageCache() ObjectStorageCache

NewDefaultObjectStorageCache creates a GCP-based Object Storage cache using a inner context

func NewGcpObjectStorageCache

func NewGcpObjectStorageCache(ctx context.Context, client ObjectStorageGcpClient) ObjectStorageCache

NewGcpObjectStorageCache creates a GCP-based Object Storage cache, optionally receiving a Context. It injects a ObjectStorageClient providing the base operations

type ObjectStorageGcpClient

type ObjectStorageGcpClient interface {
	Bucket(bucketName string) *storage.BucketHandle
}

ObjectStorageClient is the interface for the client.Storage GCP SDK operations so they can be mocked in tests or injected

type ServiceAccountAuth

type ServiceAccountAuth struct {
	ServiceAccountKey *ServiceAccountKey
	// contains filtered or unexported fields
}

func (*ServiceAccountAuth) Authenticate

func (saa *ServiceAccountAuth) Authenticate()

func (ServiceAccountAuth) IsAuthenticated

func (saa ServiceAccountAuth) IsAuthenticated() bool

func (ServiceAccountAuth) Key

type ServiceAccountClient

type ServiceAccountClient interface {
	KeyForServiceAccount(saEmail string, recreateKey bool) (string, error)
	KeyFileForServiceAccount(saEmail string, recreateKey bool, filePath string) error
	CreateKey(serviceAccountEmail string) (string, string, error)
	ListKeys(serviceAccountEmail string) ([]string, error)
}

ServiceAccountClient allows management of service account keys (create, list) for given service account emails

func NewDefaultServiceAccountClient

func NewDefaultServiceAccountClient() ServiceAccountClient

NewDefaultServiceAccountClient creates a new GCP client for service account key management based on defaults Authentication against GCP must have already been performed before invoking this operation

func NewServiceAccountClient

func NewServiceAccountClient(iamClient IamGcpClient, objectStorageCache ObjectStorageCache) ServiceAccountClient

NewServiceAccountClient creates a new GCP client for service account key management

type ServiceAccountKey

type ServiceAccountKey struct {
	KeyFileLocation string
	Email           string
}

func NewServiceAccountKey

func NewServiceAccountKey(keyLocation string) (*ServiceAccountKey, error)

Jump to

Keyboard shortcuts

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