Skip to content

Commit d9014fd

Browse files
committed
address comments
1 parent 103437d commit d9014fd

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

internal/controller/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ttlCache interface {
4040
}
4141

4242
type podMetadataAggregator interface {
43-
AggregatePodMetadata(ctx context.Context, obj *metav1.PartialObjectMetadata) *metadata.AggregatePodMetadata
43+
BuildAggregatePodMetadata(ctx context.Context, obj *metav1.PartialObjectMetadata) *metadata.AggregatePodMetadata
4444
}
4545

4646
// PodEvent represents a pod event to be processed.
@@ -352,7 +352,7 @@ func (c *Controller) processEvent(ctx context.Context, event PodEvent) error {
352352
// Gather aggregate metadata for adds/updates
353353
var aggPodMetadata *metadata.AggregatePodMetadata
354354
if status != deploymentrecord.StatusDecommissioned {
355-
aggPodMetadata = c.metadataAggregator.AggregatePodMetadata(ctx, podToPartialMetadata(pod))
355+
aggPodMetadata = c.metadataAggregator.BuildAggregatePodMetadata(ctx, podToPartialMetadata(pod))
356356
}
357357

358358
// Record info for each container in the pod

internal/metadata/metadata.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func NewAggregator(metadataClient k8smetadata.Interface) *Aggregator {
4444
}
4545
}
4646

47-
// AggregatePodMetadata takes a pod's partial object metadata and traverses its ownership hierarchy to return AggregatePodMetadata.
48-
func (m *Aggregator) AggregatePodMetadata(ctx context.Context, obj *metav1.PartialObjectMetadata) *AggregatePodMetadata {
47+
// BuildAggregatePodMetadata takes a pod's partial object metadata and traverses its ownership hierarchy to return AggregatePodMetadata.
48+
func (m *Aggregator) BuildAggregatePodMetadata(ctx context.Context, obj *metav1.PartialObjectMetadata) *AggregatePodMetadata {
4949
aggMetadata := &AggregatePodMetadata{
5050
RuntimeRisks: make(map[deploymentrecord.RuntimeRisk]bool),
5151
Tags: make(map[string]string),
@@ -111,7 +111,7 @@ func (m *Aggregator) getOwnerMetadata(ctx context.Context, namespace string, own
111111
case "Deployment":
112112
gvr.Resource = "deployments"
113113
default:
114-
slog.Debug("Unsupported owner kind for runtime risk collection",
114+
slog.Debug("Unsupported owner kind for metadata collection",
115115
"kind", owner.Kind,
116116
"name", owner.Name,
117117
)

internal/metadata/metadata_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func TestExtractMetadataFromObject(t *testing.T) {
195195
}
196196
}
197197

198-
func TestAggregatePodMetadata(t *testing.T) {
198+
func TestBuildAggregatePodMetadata(t *testing.T) {
199199
tests := []struct {
200200
name string
201201
pod *metav1.PartialObjectMetadata
@@ -331,7 +331,7 @@ func TestAggregatePodMetadata(t *testing.T) {
331331
fakeClient := metadatafake.NewSimpleMetadataClient(scheme, tt.clusterObjects...)
332332
m := NewAggregator(fakeClient)
333333

334-
result := m.AggregatePodMetadata(context.Background(), tt.pod)
334+
result := m.BuildAggregatePodMetadata(context.Background(), tt.pod)
335335

336336
if len(result.RuntimeRisks) != len(tt.expectedRuntimeRisks) {
337337
t.Errorf("RuntimeRisks count = %d, expected %d", len(result.RuntimeRisks), len(tt.expectedRuntimeRisks))
@@ -354,7 +354,7 @@ func TestAggregatePodMetadata(t *testing.T) {
354354
}
355355
}
356356

357-
func TestAggregatePodMetadata_OwnerFetchError(t *testing.T) {
357+
func TestBuildAggregatePodMetadata_OwnerFetchError(t *testing.T) {
358358
scheme := metadatafake.NewTestScheme()
359359
_ = metav1.AddMetaToScheme(scheme)
360360
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ReplicaSet"}, &metav1.PartialObjectMetadata{})
@@ -370,7 +370,7 @@ func TestAggregatePodMetadata_OwnerFetchError(t *testing.T) {
370370
MetadataAnnotationPrefix + "team": "platform",
371371
}, []metav1.OwnerReference{ownerRef("ReplicaSet", "my-rs", "rs-1")})
372372

373-
result := m.AggregatePodMetadata(context.Background(), pod)
373+
result := m.BuildAggregatePodMetadata(context.Background(), pod)
374374

375375
if len(result.RuntimeRisks) != 0 {
376376
t.Errorf("expected no runtime risks, got %v", result.RuntimeRisks)

0 commit comments

Comments
 (0)