gcp

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingProject = errors.New("missing project id")

ErrMissingProject is the error used when no project ID is provided when trying to create a provider.

Functions

This section is empty.

Types

type Disk

type Disk struct {
	*compute.Disk
	// contains filtered or unexported fields
}

Disk holds information about a GCP compute disk.

func (*Disk) CreatedAt

func (d *Disk) CreatedAt() time.Time

CreatedAt returns the time when the GCP compute disk was created.

func (*Disk) DiskType added in v0.0.2

func (d *Disk) DiskType() unused.DiskType

DiskType Type returns the type of the GCP compute disk.

func (*Disk) ID

func (d *Disk) ID() string

ID returns the GCP compute disk ID, prefixed by gcp-disk.

func (*Disk) LastUsedAt

func (d *Disk) LastUsedAt() time.Time

LastUsedAt returns the time when the GCP compute disk was last detached.

func (*Disk) Meta

func (d *Disk) Meta() unused.Meta

Meta returns the disk metadata.

func (*Disk) Name

func (d *Disk) Name() string

Name returns the name of the GCP compute disk.

func (*Disk) Provider

func (d *Disk) Provider() unused.Provider

Provider returns a reference to the provider used to instantiate this disk.

func (*Disk) SizeGB added in v0.0.2

func (d *Disk) SizeGB() int

SizeGB returns the size of the GCP compute disk in GB.

type Provider

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

Provider implements unused.Provider for GCP.

func NewProvider

func NewProvider(logger *logfmt.Logger, svc *compute.Service, project string, meta unused.Meta) (*Provider, error)

NewProvider creates a new GCP unused.Provider.

A valid GCP compute service must be supplied in order to listed the unused resources. It also requires a valid project ID which should be the project where the disks were created.

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, disk unused.Disk) error

Delete deletes the given disk from GCP.

func (*Provider) ListUnusedDisks

func (p *Provider) ListUnusedDisks(ctx context.Context) (unused.Disks, error)

ListUnusedDisks returns all the GCP compute disks that aren't associated to any users, meaning that are not being in use.

func (*Provider) Meta

func (p *Provider) Meta() unused.Meta

Meta returns the provider metadata.

func (*Provider) Name

func (p *Provider) Name() string

Name returns GCP.

Jump to

Keyboard shortcuts

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