{"modulePath":"github.com/jetstack/preflight","version":"v1.13.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\nPackage api provides types for Preflight reports and some common helpers.\n\n## Constants\n\n```go\nconst TimeFormat = time.RFC3339\n```\nTimeFormat defines the format used for timestamps across all this API.\n\n## Types\n\n```go\ntype AgentMetadata struct {\n\tVersion string `json:\"version\"`\n\t// ClusterID is the name of the cluster or host where the agent is running.\n\t// It may send data for other clusters in its datareadings.\n\tClusterID string `json:\"cluster_id\"`\n}\n```\nAgentMetadata is metadata about the agent.\n\n```go\ntype DataReading struct {\n\t// ClusterID is optional as it can be inferred from the agent\n\t// token when using basic authentication.\n\tClusterID     string `json:\"cluster_id,omitempty\"`\n\tDataGatherer  string `json:\"data-gatherer\"`\n\tTimestamp     Time   `json:\"timestamp\"`\n\tData          any    `json:\"data\"`\n\tSchemaVersion string `json:\"schema_version\"`\n}\n```\nDataReading is the output of a DataGatherer.\n\n```go\nfunc (o *DataReading) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements the json.Unmarshaler interface for DataReading. The function attempts to decode the Data field into known types in a prioritized order. Empty data is considered an error, because there is no way to discriminate between data types. TODO(wallrj): Add a discriminator field to DataReading to avoid this complex logic. E.g. \"data\\_type\": \"discovery\"|\"dynamic\"\n\n```go\ntype DataReadingsPost struct {\n\tAgentMetadata *AgentMetadata `json:\"agent_metadata\"`\n\t// DataGatherTime represents the time that the data readings were gathered\n\tDataGatherTime time.Time      `json:\"data_gather_time\"`\n\tDataReadings   []*DataReading `json:\"data_readings\"`\n}\n```\nDataReadingsPost is the payload in the upload request.\n\n```go\ntype DiscoveryData struct {\n\t// ClusterID is the unique ID of the Kubernetes cluster which this snapshot was taken from.\n\t// This is sourced from the kube-system namespace UID,\n\t// which is assumed to be stable for the lifetime of the cluster.\n\t// - https://github.com/kubernetes/kubernetes/issues/77487#issuecomment-489786023\n\tClusterID string `json:\"cluster_id\"`\n\t// ServerVersion is the version information of the k8s apiserver\n\t// See https://godoc.org/k8s.io/apimachinery/pkg/version#Info\n\tServerVersion *version.Info `json:\"server_version\"`\n}\n```\nDiscoveryData is the DataReading.Data returned by the k8sdiscovery.DataGathererDiscovery gatherer\n\n```go\ntype DynamicData struct {\n\t// Items is a list of GatheredResource\n\tItems []*GatheredResource `json:\"items\"`\n}\n```\nDynamicData is the DataReading.Data returned by the k8sdynamic.DataGathererDynamic gatherer\n\n```go\ntype GatheredResource struct {\n\t// Resource is a reference to a k8s object that was found by the informer\n\t// should be of type unstructured.Unstructured, raw Object\n\tResource  any\n\tDeletedAt Time\n}\n```\nGatheredResource wraps the raw k8s resource that is sent to the jetstack secure backend\n\n```go\nfunc (v GatheredResource) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (v *GatheredResource) UnmarshalJSON(data []byte) error\n```\n\n```go\ntype OIDCDiscoveryData struct {\n\t// OIDCConfig contains OIDC configuration data from the API server's\n\t// `/.well-known/openid-configuration` endpoint\n\tOIDCConfig map[string]any `json:\"openid_configuration,omitempty\"`\n\t// OIDCConfigError contains any error encountered while fetching the OIDC configuration\n\tOIDCConfigError string `json:\"openid_configuration_error,omitempty\"`\n\n\t// JWKS contains JWKS data from the API server's `/openid/v1/jwks` endpoint\n\tJWKS map[string]any `json:\"jwks,omitempty\"`\n\t// JWKSError contains any error encountered while fetching the JWKS\n\tJWKSError string `json:\"jwks_error,omitempty\"`\n}\n```\nOIDCDiscoveryData is the DataReading.Data returned by the oidc.OIDCDiscovery gatherer\n\n```go\ntype Time struct {\n\ttime.Time\n}\n```\nTime is a wrapper around time.Time that overrides how it is marshaled into JSON\n\n```go\nfunc (t Time) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals the timestamp with RFC3339 format\n\n```go\nfunc (t Time) String() string\n```\nString returns a string representation of the timestamp\n\n","path":"github.com/jetstack/preflight/api","name":"api","synopsis":"Package api provides types for Preflight reports and some common helpers.","isRedistributable":true}
