Skip to content

Commit 92c707f

Browse files
authored
fix: lint errors caused by #479 (#483)
* fix linting errors * gofmt
1 parent cfadfa9 commit 92c707f

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

cmd/acr/annotate_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
511511
assert := assert.New(t)
512512
mockClient := &mocks.AcrCLIClientInterface{}
513513
mockOrasClient := &mocks.ORASClientInterface{}
514-
514+
515515
// Create a locked tag result
516516
lockedTagResult := &acr.RepositoryTagsType{
517517
Response: autorest.Response{
@@ -528,27 +528,27 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
528528
Digest: &digest,
529529
}},
530530
}
531-
531+
532532
mockClient.On("GetAcrTags", mock.Anything, testRepo, "timedesc", "").Return(lockedTagResult, nil).Once()
533533
mockOrasClient.On("DiscoverLifecycleAnnotation", mock.Anything, fmt.Sprintf("%s/%s:%s", testLoginURL, testRepo, tagName), testArtifactType).Return(false, nil).Once()
534-
534+
535535
regex, _ := common.BuildRegexFilter(".*", 60)
536-
manifests, _, skipped, err := getManifestsToAnnotate(testCtx, mockClient, mockOrasClient, testLoginURL, testRepo,
536+
manifests, _, skipped, err := getManifestsToAnnotate(testCtx, mockClient, mockOrasClient, testLoginURL, testRepo,
537537
regex, "", testArtifactType, false, true) // include-locked = true
538-
538+
539539
assert.Equal(1, len(manifests), "Should include locked tag when include-locked is true")
540540
assert.Equal(0, skipped, "Should not skip any tags")
541541
assert.Equal(nil, err, "Error should be nil")
542542
mockClient.AssertExpectations(t)
543543
mockOrasClient.AssertExpectations(t)
544544
})
545-
545+
546546
// Test that without include-locked flag, locked tags are filtered out
547547
t.Run("NoIncludeLockedSkipsLockedTag", func(t *testing.T) {
548548
assert := assert.New(t)
549549
mockClient := &mocks.AcrCLIClientInterface{}
550550
mockOrasClient := &mocks.ORASClientInterface{}
551-
551+
552552
// Create a locked tag result
553553
lockedTagResult := &acr.RepositoryTagsType{
554554
Response: autorest.Response{
@@ -565,26 +565,26 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
565565
Digest: &digest,
566566
}},
567567
}
568-
568+
569569
mockClient.On("GetAcrTags", mock.Anything, testRepo, "timedesc", "").Return(lockedTagResult, nil).Once()
570-
570+
571571
regex, _ := common.BuildRegexFilter(".*", 60)
572-
manifests, _, skipped, err := getManifestsToAnnotate(testCtx, mockClient, mockOrasClient, testLoginURL, testRepo,
572+
manifests, _, skipped, err := getManifestsToAnnotate(testCtx, mockClient, mockOrasClient, testLoginURL, testRepo,
573573
regex, "", testArtifactType, false, false) // include-locked = false
574-
574+
575575
assert.Equal(0, len(manifests), "Should not include locked tag when include-locked is false")
576576
assert.Equal(1, skipped, "Should skip locked tags")
577577
assert.Equal(nil, err, "Error should be nil")
578578
mockClient.AssertExpectations(t)
579579
mockOrasClient.AssertExpectations(t)
580580
})
581-
581+
582582
// Test that with include-locked flag, locked untagged manifests are included
583583
t.Run("IncludeLockedIncludesLockedManifest", func(t *testing.T) {
584584
assert := assert.New(t)
585585
mockClient := &mocks.AcrCLIClientInterface{}
586586
mockOrasClient := &mocks.ORASClientInterface{}
587-
587+
588588
// Create a locked manifest without tags
589589
lockedManifest := &acr.Manifests{
590590
Registry: &testLoginURL,
@@ -597,25 +597,25 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
597597
Tags: nil, // No tags - untagged manifest
598598
}},
599599
}
600-
600+
601601
mockClient.On("GetAcrManifests", mock.Anything, testRepo, "", "").Return(lockedManifest, nil).Once()
602602
mockClient.On("GetAcrManifests", mock.Anything, testRepo, "", digest).Return(EmptyListManifestsResult, nil).Once()
603-
603+
604604
mockOrasClient.On("Annotate", mock.Anything, fmt.Sprintf("%s/%s@%s", testLoginURL, testRepo, digest), testArtifactType, annotationMap).Return(nil).Once()
605-
605+
606606
annotatedManifests, err := annotateUntaggedManifests(testCtx, mockClient, mockOrasClient, defaultPoolSize, testLoginURL, testRepo, testArtifactType, testAnnotations[:], false, true)
607607
assert.Equal(1, annotatedManifests, "Should annotate locked manifest when include-locked is true")
608608
assert.Equal(nil, err, "Error should be nil")
609609
mockClient.AssertExpectations(t)
610610
mockOrasClient.AssertExpectations(t)
611611
})
612-
612+
613613
// Test dry run with include-locked shows locked manifests
614614
t.Run("DryRunWithIncludeLockedShowsLockedManifests", func(t *testing.T) {
615615
assert := assert.New(t)
616616
mockClient := &mocks.AcrCLIClientInterface{}
617617
mockOrasClient := &mocks.ORASClientInterface{}
618-
618+
619619
// Create a locked manifest without tags
620620
lockedManifest := &acr.Manifests{
621621
Registry: &testLoginURL,
@@ -628,10 +628,10 @@ func TestIncludeLockedFlagAnnotate(t *testing.T) {
628628
Tags: nil, // No tags - untagged manifest
629629
}},
630630
}
631-
631+
632632
mockClient.On("GetAcrManifests", mock.Anything, testRepo, "", "").Return(lockedManifest, nil).Once()
633633
mockClient.On("GetAcrManifests", mock.Anything, testRepo, "", digest).Return(EmptyListManifestsResult, nil).Once()
634-
634+
635635
annotatedManifests, err := annotateUntaggedManifests(testCtx, mockClient, mockOrasClient, defaultPoolSize, testLoginURL, testRepo, testArtifactType, testAnnotations[:], true, true)
636636
assert.Equal(1, annotatedManifests, "Should count locked manifest in dry run when include-locked is true")
637637
assert.Equal(nil, err, "Error should be nil")
@@ -851,6 +851,6 @@ var (
851851
"vnd.microsoft.artifact.lifecycle.end-of-life.date": "2024-03-21",
852852
}
853853
// Variables for testing --include-locked flag
854-
writeDisabledBool = false
854+
writeDisabledBool = false
855855
lastUpdateTimeTest = time.Now().Add(-15 * time.Minute).UTC().Format(time.RFC3339Nano)
856856
)

internal/worker/purger.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
// Purger purges tags or manifests concurrently.
1818
type Purger struct {
1919
Executer
20-
acrClient api.AcrCLIClientInterface
20+
acrClient api.AcrCLIClientInterface
2121
includeLocked bool
2222
}
2323

@@ -31,8 +31,8 @@ func NewPurger(repoParallelism int, acrClient api.AcrCLIClientInterface, loginUR
3131
repoName: repoName,
3232
}
3333
return &Purger{
34-
Executer: executeBase,
35-
acrClient: acrClient,
34+
Executer: executeBase,
35+
acrClient: acrClient,
3636
includeLocked: includeLocked,
3737
}
3838
}
@@ -47,13 +47,13 @@ func (p *Purger) PurgeTags(ctx context.Context, tags []acr.TagAttributesBase) (i
4747
if p.includeLocked && tag.ChangeableAttributes != nil {
4848
if (tag.ChangeableAttributes.DeleteEnabled != nil && !*tag.ChangeableAttributes.DeleteEnabled) ||
4949
(tag.ChangeableAttributes.WriteEnabled != nil && !*tag.ChangeableAttributes.WriteEnabled) {
50-
50+
5151
enabledTrue := true
5252
unlockAttrs := &acr.ChangeableAttributes{
5353
DeleteEnabled: &enabledTrue,
5454
WriteEnabled: &enabledTrue,
5555
}
56-
56+
5757
_, unlockErr := p.acrClient.UpdateAcrTagAttributes(ctx, p.repoName, *tag.Name, unlockAttrs)
5858
if unlockErr != nil {
5959
fmt.Printf("Warning: Failed to unlock %s/%s:%s, error: %v. Will attempt deletion anyway.\n", p.loginURL, p.repoName, *tag.Name, unlockErr)
@@ -63,7 +63,7 @@ func (p *Purger) PurgeTags(ctx context.Context, tags []acr.TagAttributesBase) (i
6363
}
6464
}
6565
}
66-
66+
6767
resp, err := p.acrClient.DeleteAcrTag(ctx, p.repoName, *tag.Name)
6868
if err == nil {
6969
fmt.Printf("Deleted %s/%s:%s\n", p.loginURL, p.repoName, *tag.Name)
@@ -104,13 +104,13 @@ func (p *Purger) PurgeManifests(ctx context.Context, manifests []acr.ManifestAtt
104104
if p.includeLocked && manifest.ChangeableAttributes != nil {
105105
if (manifest.ChangeableAttributes.DeleteEnabled != nil && !*manifest.ChangeableAttributes.DeleteEnabled) ||
106106
(manifest.ChangeableAttributes.WriteEnabled != nil && !*manifest.ChangeableAttributes.WriteEnabled) {
107-
107+
108108
enabledTrue := true
109109
unlockAttrs := &acr.ChangeableAttributes{
110110
DeleteEnabled: &enabledTrue,
111111
WriteEnabled: &enabledTrue,
112112
}
113-
113+
114114
_, unlockErr := p.acrClient.UpdateAcrManifestAttributes(ctx, p.repoName, *manifest.Digest, unlockAttrs)
115115
if unlockErr != nil {
116116
fmt.Printf("Warning: Failed to unlock %s/%s@%s, error: %v. Will attempt deletion anyway.\n", p.loginURL, p.repoName, *manifest.Digest, unlockErr)
@@ -120,7 +120,7 @@ func (p *Purger) PurgeManifests(ctx context.Context, manifests []acr.ManifestAtt
120120
}
121121
}
122122
}
123-
123+
124124
resp, err := p.acrClient.DeleteManifest(ctx, p.repoName, *manifest.Digest)
125125
if err == nil {
126126
fmt.Printf("Deleted %s/%s@%s\n", p.loginURL, p.repoName, *manifest.Digest)

0 commit comments

Comments
 (0)