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 ¶
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 ¶
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 ¶
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) LabelsFor ¶
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.