Skip to content

Commit 3735fdf

Browse files
committed
unexport checkpointKey
1 parent 211ba56 commit 3735fdf

3 files changed

Lines changed: 7 additions & 18 deletions

File tree

internal/k8sinventory/checkpoint/checkpointer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (c *Checkpointer) GetCheckpoint(ctx context.Context, namespace, objectType
4444
return "", errors.New("storage client is nil")
4545
}
4646

47-
checkPointKey := c.CheckpointKey(namespace, objectType)
47+
checkPointKey := c.checkpointKey(namespace, objectType)
4848
c.logger.Debug("Retrieving checkpoint, key: "+checkPointKey,
4949
zap.String("namespace", namespace),
5050
zap.String("objectType", objectType))
@@ -76,7 +76,7 @@ func (c *Checkpointer) SetCheckpoint(
7676
_ context.Context,
7777
namespace, objectType, resourceVersion string,
7878
) error {
79-
key := c.CheckpointKey(namespace, objectType)
79+
key := c.checkpointKey(namespace, objectType)
8080
if key == "" {
8181
return fmt.Errorf("checkpoint key is empty: %s, %s", namespace, objectType)
8282
}
@@ -182,7 +182,7 @@ func (c *Checkpointer) DeleteCheckpoint(
182182
return errors.New("storage client is nil")
183183
}
184184

185-
key := c.CheckpointKey(namespace, objectType)
185+
key := c.checkpointKey(namespace, objectType)
186186
if key == "" {
187187
return fmt.Errorf("checkpoint key is empty: %s, %s", namespace, objectType)
188188
}
@@ -198,10 +198,10 @@ func (c *Checkpointer) DeleteCheckpoint(
198198
return nil
199199
}
200200

201-
// CheckpointKey generates a unique storage key
201+
// checkpointKey generates a unique storage key
202202
// returns resourceVersion key for global watch stream (without namespace) or
203203
// per namespace watch stream.
204-
func (*Checkpointer) CheckpointKey(namespace, objectType string) string {
204+
func (*Checkpointer) checkpointKey(namespace, objectType string) string {
205205
// when watch stream is cluster-wide or cluster-scoped resource (no namespace),
206206
// the resource version is persisted per object type only.
207207
if namespace == "" {

internal/k8sinventory/checkpoint/checkpointer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestCheckpointerKeyFormat(t *testing.T) {
9191
require.NoError(t, err)
9292
assert.Equal(t, tt.resourceVersion, rv)
9393

94-
key := checkpointer.CheckpointKey(tt.namespace, tt.objectType)
94+
key := checkpointer.checkpointKey(tt.namespace, tt.objectType)
9595
assert.Equal(t, tt.expectedKey, key)
9696
})
9797
}
@@ -357,7 +357,7 @@ func TestCheckpointerLoadSkipsMissingAndUnparseable(t *testing.T) {
357357
// going around SetCheckpoint's validation — write the raw bytes directly.
358358
require.NoError(t, cp.SetCheckpoint(ctx, "default", "pods", "100"))
359359
require.NoError(t, cp.Flush(ctx))
360-
require.NoError(t, client.Set(ctx, cp.CheckpointKey("weird", "pods"), []byte("not-a-number")))
360+
require.NoError(t, client.Set(ctx, cp.checkpointKey("weird", "pods"), []byte("not-a-number")))
361361

362362
cp.Load(ctx, []string{"default", "missing", "weird"}, "pods")
363363

internal/k8sinventory/watch/observer_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,6 @@ func TestObserverPersistenceClusterWideWatch(t *testing.T) {
841841
rv, err := checkpointer.GetCheckpoint(t.Context(), "", "pods")
842842
require.NoError(t, err)
843843
assert.NotEmpty(t, rv) // Should have a value
844-
845-
// Verify key format
846-
key := checkpointer.CheckpointKey("", "pods")
847-
assert.Equal(t, "latestResourceVersion/pods", key)
848844
}
849845

850846
func TestObserverPersistenceMultipleNamespaces(t *testing.T) {
@@ -907,13 +903,6 @@ func TestObserverPersistenceMultipleNamespaces(t *testing.T) {
907903
rv2, err := checkpointer.GetCheckpoint(t.Context(), "other", "pods")
908904
require.NoError(t, err)
909905
assert.Equal(t, "200", rv2)
910-
911-
// Verify key formats
912-
key1 := checkpointer.CheckpointKey("default", "pods")
913-
assert.Equal(t, "latestResourceVersion/pods.default", key1)
914-
915-
key2 := checkpointer.CheckpointKey("other", "pods")
916-
assert.Equal(t, "latestResourceVersion/pods.other", key2)
917906
}
918907

919908
func TestGetResourceVersion(t *testing.T) {

0 commit comments

Comments
 (0)