Documentation
¶
Overview ¶
Package flatjson contains facilities to extract credentials that are expressed as a single (flat) JSON object whose values are all strings.
This can be use to extract GCP service account keys, GCP API keys, etc.
Index ¶
Constants ¶
const ( // DefaultMaxMatches is the default value for an Extractor's MaxMatches. It is // used to limit the number of matches to constrain runtime. DefaultMaxMatches = 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor struct {
// MaxMatches limits the number of matches to constrain runtime. The default
// is 20 but it can be set arbitrarily, even to -1 in which case no limit is
// applied.
//
// For example Although we're expecting only about 10 fields for GCP service
// account keys, it makes sense to have a slightly larger limit, because
// fields like "universe" get added to the key or people might add their own
// metadata to the JSON structure.
MaxMatches int
// contains filtered or unexported fields
}
Extractor extracts key-value pairs with required or optional keys from an input. It assumes that the key-value pairs are contained in a flat JSON object as it is the case for e.g. GCP service account keys.
func NewExtractor ¶
NewExtractor creates an Extractor that can be used to extract flat-JSON key-value pairs from an input. The requiredKeys take precedence; if a key is present in both requiredKeys and optionalKeys (although it really shouldn't be), it's considered required.