1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- package commonlogk8sauditv2_impl
15+ package commonlogk8saudit_impl
1616
1717import (
1818 "context"
@@ -27,12 +27,12 @@ import (
2727 "github.com/GoogleCloudPlatform/khi/pkg/model/history"
2828 "github.com/GoogleCloudPlatform/khi/pkg/model/history/resourcepath"
2929 "github.com/GoogleCloudPlatform/khi/pkg/model/log"
30- commonlogk8sauditv2_contract "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/commonlogk8sauditv2 /contract"
30+ commonlogk8saudit_contract "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/commonlogk8saudit /contract"
3131)
3232
3333// ConditionLogToTimelineMapperTask is a ManifestLogToTimelineMapper task that tracks and records the history of Kubernetes resource conditions.
3434// It analyzes status.conditions fields in audit logs to generate revisions for each condition type (e.g., Ready, Scheduled).
35- var ConditionLogToTimelineMapperTask = commonlogk8sauditv2_contract .NewManifestLogToTimelineMapper [* conditionLogToTimelineMapperTaskState ](& conditionLogToTimelineMapperTaskSetting {
35+ var ConditionLogToTimelineMapperTask = commonlogk8saudit_contract .NewManifestLogToTimelineMapper [* conditionLogToTimelineMapperTaskState ](& conditionLogToTimelineMapperTaskSetting {
3636 minimumDeltaTimeToCreateInferredCreationRevision : 10 * time .Second ,
3737})
3838
@@ -48,8 +48,8 @@ type conditionLogToTimelineMapperTaskSetting struct {
4848 minimumDeltaTimeToCreateInferredCreationRevision time.Duration
4949}
5050
51- // Process implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
52- func (c * conditionLogToTimelineMapperTaskSetting ) Process (ctx context.Context , passIndex int , event commonlogk8sauditv2_contract .ResourceChangeEvent , cs * history.ChangeSet , builder * history.Builder , prevResource * conditionLogToTimelineMapperTaskState ) (* conditionLogToTimelineMapperTaskState , error ) {
51+ // Process implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
52+ func (c * conditionLogToTimelineMapperTaskSetting ) Process (ctx context.Context , passIndex int , event commonlogk8saudit_contract .ResourceChangeEvent , cs * history.ChangeSet , builder * history.Builder , prevResource * conditionLogToTimelineMapperTaskState ) (* conditionLogToTimelineMapperTaskState , error ) {
5353 if event .EventTargetBodyReader == nil {
5454 return prevResource , nil
5555 }
@@ -63,17 +63,17 @@ func (c *conditionLogToTimelineMapperTaskSetting) Process(ctx context.Context, p
6363 }
6464}
6565
66- // TaskID implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
66+ // TaskID implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
6767func (c * conditionLogToTimelineMapperTaskSetting ) TaskID () taskid.TaskImplementationID [struct {}] {
68- return commonlogk8sauditv2_contract .ConditionLogToTimelineMapperTaskID
68+ return commonlogk8saudit_contract .ConditionLogToTimelineMapperTaskID
6969}
7070
71- // ResourcePairs implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
72- func (c * conditionLogToTimelineMapperTaskSetting ) ResourcePairs (ctx context.Context , groupedLogs commonlogk8sauditv2_contract .ResourceManifestLogGroupMap ) ([]commonlogk8sauditv2_contract .ResourcePair , error ) {
73- result := []commonlogk8sauditv2_contract .ResourcePair {}
71+ // ResourcePairs implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
72+ func (c * conditionLogToTimelineMapperTaskSetting ) ResourcePairs (ctx context.Context , groupedLogs commonlogk8saudit_contract .ResourceManifestLogGroupMap ) ([]commonlogk8saudit_contract .ResourcePair , error ) {
73+ result := []commonlogk8saudit_contract .ResourcePair {}
7474 for _ , group := range groupedLogs {
75- if group .Resource .Type () == commonlogk8sauditv2_contract .Resource {
76- result = append (result , commonlogk8sauditv2_contract .ResourcePair {
75+ if group .Resource .Type () == commonlogk8saudit_contract .Resource {
76+ result = append (result , commonlogk8saudit_contract .ResourcePair {
7777 TargetGroup : group .Resource ,
7878 })
7979 }
@@ -83,15 +83,15 @@ func (c *conditionLogToTimelineMapperTaskSetting) ResourcePairs(ctx context.Cont
8383
8484// processFirstPass collects all available condition types from the log.
8585// This is necessary because some conditions might appear later in the history, and we need to know about them upfront to track their state correctly.
86- func (c * conditionLogToTimelineMapperTaskSetting ) processFirstPass (ctx context.Context , event commonlogk8sauditv2_contract .ResourceChangeEvent , cs * history.ChangeSet , builder * history.Builder , state * conditionLogToTimelineMapperTaskState ) (* conditionLogToTimelineMapperTaskState , error ) {
86+ func (c * conditionLogToTimelineMapperTaskSetting ) processFirstPass (ctx context.Context , event commonlogk8saudit_contract .ResourceChangeEvent , cs * history.ChangeSet , builder * history.Builder , state * conditionLogToTimelineMapperTaskState ) (* conditionLogToTimelineMapperTaskState , error ) {
8787 if state == nil {
8888 state = & conditionLogToTimelineMapperTaskState {
8989 AvailableTypes : map [string ]struct {}{},
9090 ConditionWalkers : map [string ]* conditionWalker {},
9191 }
9292 }
9393 commonFieldSet := log .MustGetFieldSet (event .Log , & log.CommonFieldSet {})
94- k8sFieldSet := log .MustGetFieldSet (event .Log , & commonlogk8sauditv2_contract .K8sAuditLogFieldSet {})
94+ k8sFieldSet := log .MustGetFieldSet (event .Log , & commonlogk8saudit_contract .K8sAuditLogFieldSet {})
9595 ownerPath := resourcepath.ResourcePath {
9696 Path : event .EventTargetResource .ResourcePathString (),
9797 ParentRelationship : enum .RelationshipChild ,
@@ -123,9 +123,9 @@ func (c *conditionLogToTimelineMapperTaskSetting) processFirstPass(ctx context.C
123123
124124// processSecondPass generates revisions for each condition type based on the collected available types.
125125// It handles standard updates, inferred creations (when creation time is missing from the log), and deletions.
126- func (c * conditionLogToTimelineMapperTaskSetting ) processSecondPass (ctx context.Context , event commonlogk8sauditv2_contract .ResourceChangeEvent , cs * history.ChangeSet , builder * history.Builder , state * conditionLogToTimelineMapperTaskState ) (* conditionLogToTimelineMapperTaskState , error ) {
126+ func (c * conditionLogToTimelineMapperTaskSetting ) processSecondPass (ctx context.Context , event commonlogk8saudit_contract .ResourceChangeEvent , cs * history.ChangeSet , builder * history.Builder , state * conditionLogToTimelineMapperTaskState ) (* conditionLogToTimelineMapperTaskState , error ) {
127127 commonFieldSet := log .MustGetFieldSet (event .Log , & log.CommonFieldSet {})
128- k8sFieldSet := log .MustGetFieldSet (event .Log , & commonlogk8sauditv2_contract .K8sAuditLogFieldSet {})
128+ k8sFieldSet := log .MustGetFieldSet (event .Log , & commonlogk8saudit_contract .K8sAuditLogFieldSet {})
129129 ownerPath := resourcepath.ResourcePath {
130130 Path : event .EventTargetResource .ResourcePathString (),
131131 ParentRelationship : enum .RelationshipChild ,
@@ -147,7 +147,7 @@ func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.
147147 }
148148 slices .Sort (sortedKeys )
149149
150- if event .EventType == commonlogk8sauditv2_contract .ChangeEventTypeTargetCreation {
150+ if event .EventType == commonlogk8saudit_contract .ChangeEventTypeTargetCreation {
151151 creationTime , found := GetCreationTimestamp (event .EventTargetBodyReader )
152152 if found {
153153 if commonFieldSet .Timestamp .Sub (creationTime ) > c .minimumDeltaTimeToCreateInferredCreationRevision {
@@ -175,7 +175,7 @@ func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.
175175 walker .CheckAndRecord (commonFieldSet , k8sFieldSet , currentConditions [key ], cs )
176176 }
177177
178- if event .EventType == commonlogk8sauditv2_contract .ChangeEventTypeTargetDeletion {
178+ if event .EventType == commonlogk8saudit_contract .ChangeEventTypeTargetDeletion {
179179 for _ , key := range sortedKeys {
180180 walker := state .ConditionWalkers [key ]
181181 if walker == nil {
@@ -198,27 +198,27 @@ func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.
198198 return state , nil
199199}
200200
201- // Dependencies implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
201+ // Dependencies implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
202202func (c * conditionLogToTimelineMapperTaskSetting ) Dependencies () []taskid.UntypedTaskReference {
203203 return []taskid.UntypedTaskReference {}
204204}
205205
206- // PassCount implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
206+ // PassCount implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
207207func (c * conditionLogToTimelineMapperTaskSetting ) PassCount () int {
208208 return 2
209209}
210210
211- // GroupedLogTask implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
212- func (c * conditionLogToTimelineMapperTaskSetting ) GroupedLogTask () taskid.TaskReference [commonlogk8sauditv2_contract .ResourceManifestLogGroupMap ] {
213- return commonlogk8sauditv2_contract .ResourceLifetimeTrackerTaskID .Ref ()
211+ // GroupedLogTask implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
212+ func (c * conditionLogToTimelineMapperTaskSetting ) GroupedLogTask () taskid.TaskReference [commonlogk8saudit_contract .ResourceManifestLogGroupMap ] {
213+ return commonlogk8saudit_contract .ResourceLifetimeTrackerTaskID .Ref ()
214214}
215215
216- // LogIngesterTask implements commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting.
216+ // LogIngesterTask implements commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting.
217217func (c * conditionLogToTimelineMapperTaskSetting ) LogIngesterTask () taskid.TaskReference [[]* log.Log ] {
218- return commonlogk8sauditv2_contract .K8sAuditLogIngesterTaskID .Ref ()
218+ return commonlogk8saudit_contract .K8sAuditLogIngesterTaskID .Ref ()
219219}
220220
221- var _ commonlogk8sauditv2_contract .ManifestLogToTimelineMapperTaskSetting [* conditionLogToTimelineMapperTaskState ] = (* conditionLogToTimelineMapperTaskSetting )(nil )
221+ var _ commonlogk8saudit_contract .ManifestLogToTimelineMapperTaskSetting [* conditionLogToTimelineMapperTaskState ] = (* conditionLogToTimelineMapperTaskSetting )(nil )
222222
223223// conditionStateToRevisionState converts a Kubernetes condition status string ("True", "False", etc.) to a KHI RevisionState enum.
224224func conditionStateToRevisionState (conditionState string ) enum.RevisionState {
@@ -268,15 +268,15 @@ func newConditionWalker(parentResource resourcepath.ResourcePath, stateType stri
268268}
269269
270270// checkLastTransitionTimes memorizes the last transition time of the condition. This value is used for complementing values for logs without the full status information.
271- func (c * conditionWalker ) checkLastTransitionTimes (commonLog * log.CommonFieldSet , k8sAuditLog * commonlogk8sauditv2_contract .K8sAuditLogFieldSet , condition * model.K8sResourceStatusCondition ) {
271+ func (c * conditionWalker ) checkLastTransitionTimes (commonLog * log.CommonFieldSet , k8sAuditLog * commonlogk8saudit_contract .K8sAuditLogFieldSet , condition * model.K8sResourceStatusCondition ) {
272272 if condition != nil && condition .Status != "" && condition .LastTransitionTime != "" {
273273 c .lastTransitionStates [condition .LastTransitionTime ] = condition
274274 }
275275}
276276
277277// CheckAndRecord compares the current condition with the previous state and records a revision if there is a significant change.
278278// It tracks changes in Status, LastTransitionTime, and LastHeartbeatTime (ProbeLikeTime).
279- func (c * conditionWalker ) CheckAndRecord (commonLog * log.CommonFieldSet , k8sAuditLog * commonlogk8sauditv2_contract .K8sAuditLogFieldSet , condition * model.K8sResourceStatusCondition , cs * history.ChangeSet ) {
279+ func (c * conditionWalker ) CheckAndRecord (commonLog * log.CommonFieldSet , k8sAuditLog * commonlogk8saudit_contract .K8sAuditLogFieldSet , condition * model.K8sResourceStatusCondition , cs * history.ChangeSet ) {
280280 if condition == nil {
281281 if c .lastStatus != "n/a" {
282282 cs .AddRevision (c .conditionPath (), & history.StagingResourceRevision {
0 commit comments