gcp

package
v0.0.0-...-c60b83b Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FindGoogleDefaultCredentials func(ctx context.Context, scopes ...string) (*google.Credentials, error) = google.FindDefaultCredentials

Functions

func FixupGcpConfig

func FixupGcpConfig(vCpu float32, memoryMiB uint64) (cpu float64, memory uint)

FIXME: Add tests

func IsNotFound

func IsNotFound(err error) bool

Types

type Gcp

type Gcp struct {
	Region        string
	ProjectId     string
	ProjectNumber int64
}

func (Gcp) CreateUploadURL

func (gcp Gcp) CreateUploadURL(ctx context.Context, bucketName, objectName, serviceAccount string) (string, error)

func (Gcp) EnsureAPIsEnabled

func (gcp Gcp) EnsureAPIsEnabled(ctx context.Context, apis ...string) error

func (Gcp) EnsureArtifactRegistryExists

func (gcp Gcp) EnsureArtifactRegistryExists(ctx context.Context, repoName string) (string, error)

func (Gcp) EnsureBucketExists

func (gcp Gcp) EnsureBucketExists(ctx context.Context, prefix string) (string, error)

func (Gcp) EnsureDNSZoneExists

func (gcp Gcp) EnsureDNSZoneExists(ctx context.Context, name, domain, description string) (*dns.ManagedZone, error)

func (Gcp) EnsureProjectExists

func (gcp Gcp) EnsureProjectExists(ctx context.Context, projectName string) (*resourcepb.Project, error)

func (Gcp) EnsureRoleExists

func (gcp Gcp) EnsureRoleExists(ctx context.Context, roleId, title, description string, permissions []string) (string, error)

func (Gcp) EnsureServiceAccountExists

func (gcp Gcp) EnsureServiceAccountExists(ctx context.Context, serviceAccountId, displayName, description string) (string, error)

func (Gcp) EnsureServiceAccountHasArtifactRegistryRoles

func (gcp Gcp) EnsureServiceAccountHasArtifactRegistryRoles(ctx context.Context, repo, serviceAccount string, roles []string) error

func (Gcp) EnsureServiceAccountHasBucketRoles

func (gcp Gcp) EnsureServiceAccountHasBucketRoles(ctx context.Context, bucketName, serviceAccount string, roles []string) error

func (Gcp) EnsureServiceAccountHasRoles

func (gcp Gcp) EnsureServiceAccountHasRoles(ctx context.Context, serviceAccount string, roles []string) error

func (Gcp) EnsureUserHasServiceAccountRoles

func (gcp Gcp) EnsureUserHasServiceAccountRoles(ctx context.Context, user, serviceAccount string, roles []string) error

TODO: Investigate if this can be merged with EnsureServiceAccountHasRoles

func (Gcp) GetBucketObject

func (gcp Gcp) GetBucketObject(ctx context.Context, bucketName, objectName string) ([]byte, error)

func (Gcp) GetBucketWithPrefix

func (gcp Gcp) GetBucketWithPrefix(ctx context.Context, prefix string) (string, error)

func (Gcp) GetCurrentAccountEmail

func (gcp Gcp) GetCurrentAccountEmail(ctx context.Context) (string, error)

func (Gcp) GetDNSZone

func (gcp Gcp) GetDNSZone(ctx context.Context, name string) (*dns.ManagedZone, error)

func (Gcp) GetExecutionEnv

func (gcp Gcp) GetExecutionEnv(ctx context.Context, executionName string) (map[string]string, error)

func (Gcp) GetProjectNumber

func (gcp Gcp) GetProjectNumber(ctx context.Context) (int64, error)

func (Gcp) IterateBucketObjects

func (gcp Gcp) IterateBucketObjects(ctx context.Context, bucketName, prefix string, f func(*storage.ObjectAttrs) error) error

func (Gcp) NewTailer

func (gcp Gcp) NewTailer(ctx context.Context) (*Tailer, error)

func (Gcp) Run

func (gcp Gcp) Run(ctx context.Context, jobId string, env map[string]string, cmd ...string) (string, error)

func (Gcp) SetupJob

func (gcp Gcp) SetupJob(ctx context.Context, jobId, serviceAccount string, containers []types.Container) error

func (Gcp) SignBytes

func (gcp Gcp) SignBytes(ctx context.Context, b []byte, name string) ([]byte, error)

type ProjectId

type ProjectId string

func ProjectIDFromName

func ProjectIDFromName(name string) ProjectId

A project ID has the following requirements:

  • Must be 6 to 30 characters in length.
  • Can only contain lowercase letters, numbers, and hyphens.
  • Must start with a letter.
  • Cannot end with a hyphen.
  • Cannot be in use or previously used; this includes deleted projects.
  • Cannot contain restricted strings, such as google, null, undefined, and ssl.

Compose Project Name:

  • must contain only lowercase letters, decimal digits, dashes, and underscores,
  • and must begin with a lowercase letter or decimal digit

Differences:

  • Project ID cannot contain underscores
  • Project ID cannot start with a digit
  • Project ID cannot end with a hyphen
  • Project ID cannot contain restricted strings: google, null, undefined, ssl
  • Note: console test shows only google is restricted
  • Project ID must be 6 ~ 30 characters
  • Project ID must be unique including deleted projects

func (ProjectId) IsValid

func (id ProjectId) IsValid() bool

func (ProjectId) Prefix

func (id ProjectId) Prefix() string

func (ProjectId) String

func (id ProjectId) String() string

func (ProjectId) Suffix

func (id ProjectId) Suffix() string

type Tailer

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

func (*Tailer) AddQuerySet

func (t *Tailer) AddQuerySet(query string)

func (Tailer) Close

func (t Tailer) Close() error

func (*Tailer) Next

func (t *Tailer) Next(ctx context.Context) (*loggingpb.LogEntry, error)

func (*Tailer) SetBaseQuery

func (t *Tailer) SetBaseQuery(query string)

func (*Tailer) Start

func (t *Tailer) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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