Documentation
¶
Index ¶
- Variables
- type Builder
- func (builder *Builder) Finalize(ctx context.Context, serializedMetadata map[string]interface{}, ...) (int, error)
- func (builder *Builder) GetChildResources(parentResourcePath string) []*Resource
- func (builder *Builder) GetLog(logId string) (*SerializableLog, error)
- func (builder *Builder) GetTimelineBuilder(resourcePath string) *TimelineBuilder
- func (builder *Builder) ParseLogsByGroups(ctx context.Context, groupedLogs []*log.LogEntity, logWalker BuilderLogWalker) error
- func (builder *Builder) PrepareParseLogs(ctx context.Context, entireLogs []*log.LogEntity, onLogPorcessed func()) error
- type BuilderLogWalker
- type ChangeSet
- func (cs *ChangeSet) FlushToHistory(builder *Builder) ([]string, error)
- func (cs *ChangeSet) GetAllResourcePaths() []string
- func (cs *ChangeSet) GetEvents(resourcePath resourcepath.ResourcePath) []*ResourceEvent
- func (cs *ChangeSet) GetLogSummary() string
- func (cs *ChangeSet) GetRevisions(resourcePath resourcepath.ResourcePath) []*StagingResourceRevision
- func (cs *ChangeSet) RecordEvent(resourcePath resourcepath.ResourcePath)
- func (cs *ChangeSet) RecordLogSeverity(severity enum.Severity)
- func (cs *ChangeSet) RecordLogSummary(summary string)
- func (cs *ChangeSet) RecordResourceAlias(sourceResourcePath resourcepath.ResourcePath, ...)
- func (cs *ChangeSet) RecordRevision(resourcePath resourcepath.ResourcePath, revision *StagingResourceRevision)
- type FirstRevisionTimeSortStrategy
- type History
- type LogAnnotation
- type NameSortStrategy
- type Resource
- type ResourceChunkSortStrategy
- type ResourceEvent
- type ResourceReferenceAnnotation
- type ResourceRevision
- type ResourceSorter
- type ResourceTimeline
- type SerializableLog
- type SerializableResourceReferenceAnnotation
- type StagingResourceRevision
- type TimelineBuilder
- type UnreachableSortStrategy
Constants ¶
This section is empty.
Variables ¶
var ErrorSortSkipped = errors.New("skipping this sorter for the given resource chunk")
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { ClusterResource *resourceinfo.Cluster // contains filtered or unexported fields }
Builder builds History from ChangeSet obtained from parsers.
func NewBuilder ¶
func (*Builder) Finalize ¶
func (builder *Builder) Finalize(ctx context.Context, serializedMetadata map[string]interface{}, writer io.Writer, progress *progress.TaskProgress) (int, error)
Finalize flushes the binary chunk data and serialized metadata to the given io.Writer. Returns the written data size in bytes and error.
func (*Builder) GetChildResources ¶
GetChildResources returns the list of ResourceTimeline filtered with the prefix of resource path.
func (*Builder) GetLog ¶
func (builder *Builder) GetLog(logId string) (*SerializableLog, error)
GetLog returns a copy of SerializableLog. Returns an error when the specified logId wasn't found from the list of consumed logs.
func (*Builder) GetTimelineBuilder ¶
func (builder *Builder) GetTimelineBuilder(resourcePath string) *TimelineBuilder
func (*Builder) ParseLogsByGroups ¶
type ChangeSet ¶
type ChangeSet struct {
// contains filtered or unexported fields
}
history.ChangeSet is set of changes applicable to history. A parser ingest a log.LogEntry and returns a ChangeSet. ChangeSet contains multiple changes against the history. This change is applied atomically, when the parser returns an error, no partial changes would be written.
func NewChangeSet ¶
func (*ChangeSet) FlushToHistory ¶
FlushToHistory writes the recorded changeset to the history and returns resource paths where the resource modified.
func (*ChangeSet) GetAllResourcePaths ¶
GetAllResourcePaths returns the all of resource paths included in this ChangeSet.
func (*ChangeSet) GetEvents ¶
func (cs *ChangeSet) GetEvents(resourcePath resourcepath.ResourcePath) []*ResourceEvent
GetEvents returns every ResourceEvents at the specified resource path.
func (*ChangeSet) GetLogSummary ¶
GetLogSummary returns the summary of log to be written with the log.
func (*ChangeSet) GetRevisions ¶
func (cs *ChangeSet) GetRevisions(resourcePath resourcepath.ResourcePath) []*StagingResourceRevision
GetRevisions returns every StagingResourceRevisions at the specified resource path.
func (*ChangeSet) RecordEvent ¶
func (cs *ChangeSet) RecordEvent(resourcePath resourcepath.ResourcePath)
func (*ChangeSet) RecordLogSeverity ¶
func (*ChangeSet) RecordLogSummary ¶
func (*ChangeSet) RecordResourceAlias ¶
func (cs *ChangeSet) RecordResourceAlias(sourceResourcePath resourcepath.ResourcePath, destResourcePath resourcepath.ResourcePath)
func (*ChangeSet) RecordRevision ¶
func (cs *ChangeSet) RecordRevision(resourcePath resourcepath.ResourcePath, revision *StagingResourceRevision)
type FirstRevisionTimeSortStrategy ¶
type FirstRevisionTimeSortStrategy struct {
TargetRelationship enum.ParentRelationship
}
func (*FirstRevisionTimeSortStrategy) SortChunk ¶
func (b *FirstRevisionTimeSortStrategy) SortChunk(builder *Builder, parents []*Resource, groupedRelationship enum.ParentRelationship, chunk []*Resource) ([]*Resource, error)
SortChunk implements ResourceChunkSortStrategy.
type History ¶
type History struct { Version string `json:"version"` Metadata map[string]interface{} `json:"metadata"` Logs []*SerializableLog `json:"logs"` Timelines []*ResourceTimeline `json:"timelines"` Resources []*Resource `json:"resources"` }
The entire inspection data.
func NewHistory ¶
func NewHistory() *History
type LogAnnotation ¶
type LogAnnotation interface { Priority() int Serialize(builder *binarychunk.Builder) (any, error) }
type NameSortStrategy ¶
func NewNameSortStrategy ¶
func NewNameSortStrategy(layer int, prioritizedKeys []string) *NameSortStrategy
func (*NameSortStrategy) SortChunk ¶
func (n *NameSortStrategy) SortChunk(builder *Builder, parents []*Resource, groupedRelationship enum.ParentRelationship, chunk []*Resource) ([]*Resource, error)
SortChunk implements ResourceChunkSortStrategy.
type ResourceEvent ¶
type ResourceEvent struct {
Log string `json:"log"`
}
type ResourceReferenceAnnotation ¶
type ResourceReferenceAnnotation struct {
Path string
}
func NewResourceReferenceAnnotation ¶
func NewResourceReferenceAnnotation(resourcePath string) *ResourceReferenceAnnotation
func (*ResourceReferenceAnnotation) Priority ¶
func (a *ResourceReferenceAnnotation) Priority() int
func (*ResourceReferenceAnnotation) Serialize ¶
func (a *ResourceReferenceAnnotation) Serialize(builder *binarychunk.Builder) (any, error)
type ResourceRevision ¶
type ResourceRevision struct { Log string `json:"log"` Verb enum.RevisionVerb `json:"verb"` Requestor *binarychunk.BinaryReference `json:"requestor"` Body *binarychunk.BinaryReference `json:"body"` ChangeTime time.Time `json:"changeTime"` State enum.RevisionState `json:"state"` // DEPRECATED: This field is no longer used. Will be removed in near future. Partial bool `json:"partial"` }
type ResourceSorter ¶
type ResourceSorter struct {
Strategies []ResourceChunkSortStrategy
}
func NewResourceSorter ¶
func NewResourceSorter(strategy ...ResourceChunkSortStrategy) *ResourceSorter
type ResourceTimeline ¶
type ResourceTimeline struct { ID string `json:"id"` Revisions []*ResourceRevision `json:"revisions"` Events []*ResourceEvent `json:"events"` }
type SerializableLog ¶
type SerializableLog struct { // Common fields assigned by log entity Timestamp time.Time `json:"ts"` // ID is an actual unique ID of this log. This field must be unique. KHI uses `insertId`-`timestamp` for GCP log. ID string `json:"id"` // Display ID is a log ID directly visible to user. This field no need to be unique. KHI uses `insertId` for GCP log. DisplayId string `json:"displayId"` Body *binarychunk.BinaryReference `json:"body"` // These fields are managed by each parsers Type enum.LogType `json:"type"` Summary *binarychunk.BinaryReference `json:"summary"` Severity enum.Severity `json:"severity"` Annotations []any `json:"annotations"` }
type SerializableResourceReferenceAnnotation ¶
type SerializableResourceReferenceAnnotation struct { Type string `json:"type"` Path *binarychunk.BinaryReference `json:"path"` }
type StagingResourceRevision ¶
type StagingResourceRevision struct { Verb enum.RevisionVerb Body string Requestor string Partial bool // If this resource existence is inferred from another logs later. Inferred bool ChangeTime time.Time State enum.RevisionState }
type TimelineBuilder ¶
type TimelineBuilder struct {
// contains filtered or unexported fields
}
An utility class to modify specific resource timeline obtained from history.
func (*TimelineBuilder) AddEvent ¶
func (b *TimelineBuilder) AddEvent(event *ResourceEvent)
func (*TimelineBuilder) AddRevision ¶
func (b *TimelineBuilder) AddRevision(revision *ResourceRevision)
func (*TimelineBuilder) GetLatestRevision ¶
func (b *TimelineBuilder) GetLatestRevision() *ResourceRevision
Get the latest revision stored in a specific ResourceHistory. Returns nil when specified resource was nil or no any revisions recorded.
func (*TimelineBuilder) GetLatestRevisionBody ¶
func (b *TimelineBuilder) GetLatestRevisionBody() (string, error)
func (*TimelineBuilder) Sort ¶
func (b *TimelineBuilder) Sort()
type UnreachableSortStrategy ¶
type UnreachableSortStrategy struct { }
UnreachableSortStrategy is the default sort strategy catches all. Hitting this sorter is unexpected but implemented not to crush because of bad output from parsers.
func (*UnreachableSortStrategy) SortChunk ¶
func (u *UnreachableSortStrategy) SortChunk(builder *Builder, parents []*Resource, groupedRelationship enum.ParentRelationship, chunk []*Resource) ([]*Resource, error)
SortChunk implements ResourceChunkSortStrategy.