gcpasset

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gcpasset reads a Google Cloud resource's labels through Cloud Asset Inventory.

It exists because the labels patchy needs are not in the notification that brought the finding: a Security Command Center message describes the resource (name, type, project) but carries none of its labels, so ownership has to be looked up separately. That lookup is the only reason context-controller holds a cloud credential, and it is read-only.

The client is deliberately thin — one method, one struct — so the enhancer that uses it can be tested against a hand-written fake and neither the enhancer nor anything in pkg/ ever names a Google Cloud type.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("resource not found in cloud asset inventory")

ErrNotFound reports that Cloud Asset Inventory has no record of the resource. This is a permanent answer, not a transient one: the resource may have been deleted between the finding being raised and this lookup, or it may sit outside the configured scope. Callers use it to decide against retrying.

Functions

func ValidateScope

func ValidateScope(scope string) error

ValidateScope reports whether scope is one Asset Inventory accepts. Checked at construction so a typo fails at startup rather than on the first finding.

Types

type Client

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

Client reads resource labels from Cloud Asset Inventory. There is no interface here on purpose: the consumer declares the one-method seam it needs and this satisfies it.

func New

func New(ctx context.Context, scope string) (*Client, error)

New builds a client searching within scope, which must name an organization, folder, or project ("organizations/123", "folders/456", "projects/foo"). Credentials come from Application Default Credentials — in-cluster that means workload identity, so no key file exists anywhere.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying connection.

func (*Client) LabelsFor

func (c *Client) LabelsFor(ctx context.Context, resourceName string) (*Labels, error)

LabelsFor returns the labels of one resource, named as Security Command Center names it.

Errors are classified for the caller: ErrNotFound is final, everything else is worth retrying. That distinction is what lets the enhancer chain decide between advancing a finding and holding it for another try.

type Labels

type Labels struct {
	// Name is the resource's full name, as Security Command Center and Asset
	// Inventory both spell it.
	Name string
	// Labels are the resource's own labels.
	Labels map[string]string
}

Labels are one resource's labels, plus enough identity to log about it.

Jump to

Keyboard shortcuts

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