Skip to content

Commit ddf6acf

Browse files
liamfallonCopilot
andauthored
Bump kpt version in Porch to v1.0.0-beta.62 (kptdev#526)
* Rebased uplift Signed-off-by: liamfallon <liam.fallon@est.tech> * Rebasing following other merges Signed-off-by: liamfallon <liam.fallon@est.tech> * Update pkg/engine/engine_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update pkg/cache/dbcache/dbpackagerevision.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update pkg/cache/dbcache/dbpackagerevision.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Resolve copilot comment Signed-off-by: liamfallon <liam.fallon@est.tech> * Updated for rebase Signed-off-by: liamfallon <liam.fallon@est.tech> --------- Signed-off-by: liamfallon <liam.fallon@est.tech> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 315f5df commit ddf6acf

46 files changed

Lines changed: 260 additions & 223 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/porch/v1alpha2/packagerevision_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ type PackageRevisionStatus struct {
183183
type PackageSource struct {
184184
// Init creates a brand new package from scratch.
185185
Init *PackageInitSpec `json:"init,omitempty"`
186-
186+
187187
// CloneFrom copies a package from an upstream source (first time).
188188
CloneFrom *UpstreamPackage `json:"cloneFrom,omitempty"`
189-
189+
190190
// CopyFrom creates a new revision from an existing package in the same repository.
191191
CopyFrom *PackageRevisionRef `json:"copyFrom,omitempty"`
192-
192+
193193
// Upgrade merges changes from a new upstream version into a local package.
194194
Upgrade *PackageUpgradeSpec `json:"upgrade,omitempty"`
195195
}

api/porch/v1alpha2/source_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package v1alpha2
2222
// PackageInitSpec defines the package initialization parameters.
2323
// Used when creating a brand new package from scratch.
2424
type PackageInitSpec struct {
25-
// Subpackage is a directory path to a subpackage to initialize.
25+
// Subpackage is a directory path to a subpackage to initialize.
2626
// If unspecified, the main package will be initialized.
2727
Subpackage string `json:"subpackage,omitempty"`
2828
// Description is a short description of the package.

api/porch/v1alpha2/util.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ func LifecycleIsPublished(lifecycle PackageRevisionLifecycle) bool {
2222
return lifecycle == PackageRevisionLifecyclePublished || lifecycle == PackageRevisionLifecycleDeletionProposed
2323
}
2424

25-
2625
// PackageRevisionIsReady checks if the package has met all readiness gates
2726
func PackageRevisionIsReady(readinessGates []ReadinessGate, packageConditions []PackageCondition) bool {
2827
// Index our package conditions

controllers/repositories/integration/repository_integration_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ var _ = Describe("Repository Controller Integration", func() {
223223
})
224224
})
225225

226-
227226
Context("When testing error recovery scenarios", func() {
228227
It("Should handle RunOnceAt not yet due", func() {
229228
_, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: namespacedName})

controllers/repositories/integration/suite_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,50 +96,50 @@ func createTestRepository(name, namespace string) *configapi.Repository {
9696
func createReconcilerWithMockCache() (*repository.RepositoryReconciler, *mockcache.MockCache) {
9797
mockCache := mockcache.NewMockCache(GinkgoT())
9898
mockRepo := mockrepo.NewMockRepository(GinkgoT())
99-
99+
100100
// Setup default mock behaviors for successful sync operations
101101
mockCache.EXPECT().OpenRepository(mock.Anything, mock.Anything).Return(mockRepo, nil).Maybe()
102102
mockCache.EXPECT().CheckRepositoryConnectivity(mock.Anything, mock.Anything).Return(nil).Maybe()
103103
mockCache.EXPECT().UpdateRepository(mock.Anything, mock.Anything).Return(nil).Maybe()
104104
mockCache.EXPECT().CloseRepository(mock.Anything, mock.Anything, mock.Anything).Return(nil).Maybe()
105-
105+
106106
// Mock repository operations for sync
107107
mockRepo.EXPECT().Refresh(mock.Anything).Return(nil).Maybe()
108108
mockRepo.EXPECT().ListPackageRevisions(mock.Anything, mock.Anything).Return(nil, nil).Maybe()
109109
mockRepo.EXPECT().BranchCommitHash(mock.Anything).Return("", nil).Maybe()
110-
110+
111111
reconciler := &repository.RepositoryReconciler{
112-
Client: k8sClient,
113-
Scheme: k8sClient.Scheme(),
114-
Cache: mockCache,
115-
HealthCheckFrequency: 2 * time.Second,
116-
FullSyncFrequency: 5 * time.Second,
117-
SyncStaleTimeout: 10 * time.Second,
118-
MaxConcurrentReconciles: 1,
119-
MaxConcurrentSyncs: 10,
112+
Client: k8sClient,
113+
Scheme: k8sClient.Scheme(),
114+
Cache: mockCache,
115+
HealthCheckFrequency: 2 * time.Second,
116+
FullSyncFrequency: 5 * time.Second,
117+
SyncStaleTimeout: 10 * time.Second,
118+
MaxConcurrentReconciles: 1,
119+
MaxConcurrentSyncs: 10,
120120
}
121-
121+
122122
// Initialize sync limiter manually instead of calling SetupWithManager
123123
reconciler.InitializeSyncLimiter()
124-
124+
125125
return reconciler, mockCache
126126
}
127127

128128
// createMockCacheWithSlowSync creates a mock cache that simulates slow sync operations
129129
func createMockCacheWithSlowSync() *mockcache.MockCache {
130130
mockCache := mockcache.NewMockCache(GinkgoT())
131131
mockRepo := mockrepo.NewMockRepository(GinkgoT())
132-
132+
133133
// Setup slow sync operations
134134
mockCache.EXPECT().OpenRepository(mock.Anything, mock.Anything).Return(mockRepo, nil).Maybe()
135135
mockCache.EXPECT().CheckRepositoryConnectivity(mock.Anything, mock.Anything).Return(nil).Maybe()
136-
136+
137137
// Slow refresh operation
138138
mockRepo.EXPECT().Refresh(mock.Anything).Run(func(ctx context.Context) {
139139
time.Sleep(2 * time.Second) // Simulate slow operation
140140
}).Return(nil).Maybe()
141141
mockRepo.EXPECT().ListPackageRevisions(mock.Anything, mock.Anything).Return(nil, nil).Maybe()
142142
mockRepo.EXPECT().BranchCommitHash(mock.Anything).Return("", nil).Maybe()
143-
143+
144144
return mockCache
145-
}
145+
}

controllers/repositories/pkg/controllers/repository/cache_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
1615
package repository
1716

1817
import (
@@ -311,7 +310,7 @@ func TestBuildCacheOptions(t *testing.T) {
311310
func TestCreateCredentialResolvers(t *testing.T) {
312311
// Use the existing mockery client
313312
mockClient := mockclient.NewMockClient(t)
314-
313+
315314
r := &RepositoryReconciler{}
316315
credResolver, caResolver := r.createCredentialResolvers(mockClient)
317316

controllers/repositories/pkg/controllers/repository/config_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ func TestInitDefaults(t *testing.T) {
3434
func TestBindFlags(t *testing.T) {
3535
r := &RepositoryReconciler{}
3636
flags := flag.NewFlagSet("test", flag.ContinueOnError)
37-
37+
3838
r.BindFlags("repo-", flags)
39-
39+
4040
// Parse test flags
4141
err := flags.Parse([]string{
4242
"--repo-max-concurrent-reconciles=100",
@@ -56,9 +56,9 @@ func (m *mockLogger) Info(msg string, keysAndValues ...interface{}) {
5656

5757
func TestLogConfig(t *testing.T) {
5858
tests := []struct {
59-
name string
60-
reconciler *RepositoryReconciler
61-
expectWarnings int
59+
name string
60+
reconciler *RepositoryReconciler
61+
expectWarnings int
6262
}{
6363
{
6464
name: "default config - no warnings",
@@ -126,4 +126,4 @@ func TestLogConfig(t *testing.T) {
126126
assert.Equal(t, tt.expectWarnings, warningCount)
127127
})
128128
}
129-
}
129+
}

controllers/repositories/pkg/controllers/repository/deletion_test.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2828

2929
configapi "github.com/nephio-project/porch/api/porchconfig/v1alpha1"
30-
cachetypes "github.com/nephio-project/porch/test/mockery/mocks/porch/pkg/cache/types"
3130
mockclient "github.com/nephio-project/porch/test/mockery/mocks/external/sigs.k8s.io/controller-runtime/pkg/client"
31+
cachetypes "github.com/nephio-project/porch/test/mockery/mocks/porch/pkg/cache/types"
3232
)
3333

3434
func TestGetAllRepositories(t *testing.T) {
@@ -57,7 +57,7 @@ func TestGetAllRepositories(t *testing.T) {
5757
for _, tt := range tests {
5858
t.Run(tt.name, func(t *testing.T) {
5959
mockClient := mockclient.NewMockClient(t)
60-
60+
6161
if tt.listError != nil {
6262
mockClient.EXPECT().List(ctx, &configapi.RepositoryList{}).Return(tt.listError)
6363
} else {
@@ -101,7 +101,7 @@ func TestCleanupRepositoryCache(t *testing.T) {
101101
for _, tt := range tests {
102102
t.Run(tt.name, func(t *testing.T) {
103103
mockCache := cachetypes.NewMockCache(t)
104-
104+
105105
if tt.cacheError != nil {
106106
mockCache.EXPECT().CloseRepository(ctx, repo, allRepos).Return(tt.cacheError)
107107
} else {
@@ -137,7 +137,7 @@ func TestRemoveFinalizer(t *testing.T) {
137137
t.Run(tt.name, func(t *testing.T) {
138138
repo := createTestRepoWithFinalizer("test-repo", "test-ns")
139139
mockClient := mockclient.NewMockClient(t)
140-
140+
141141
if tt.updateError != nil {
142142
mockClient.EXPECT().Update(ctx, repo).Return(tt.updateError)
143143
} else {
@@ -152,7 +152,7 @@ func TestRemoveFinalizer(t *testing.T) {
152152
} else {
153153
assert.NoError(t, err)
154154
}
155-
155+
156156
// Finalizer should always be removed regardless of update result
157157
assert.False(t, controllerutil.ContainsFinalizer(repo, RepositoryFinalizer))
158158
})
@@ -163,14 +163,14 @@ func TestHandleDeletion(t *testing.T) {
163163
ctx := context.Background()
164164

165165
tests := []struct {
166-
name string
167-
repo *configapi.Repository
168-
allRepos []configapi.Repository
169-
cacheError error
170-
listError error
171-
updateError error
172-
expectRequeue bool
173-
expectError bool
166+
name string
167+
repo *configapi.Repository
168+
allRepos []configapi.Repository
169+
cacheError error
170+
listError error
171+
updateError error
172+
expectRequeue bool
173+
expectError bool
174174
expectFinalizer bool
175175
}{
176176
{
@@ -182,16 +182,16 @@ func TestHandleDeletion(t *testing.T) {
182182
expectFinalizer: false,
183183
},
184184
{
185-
name: "successful deletion with empty repo list",
186-
repo: createTestRepoWithFinalizer("test-repo", "test-ns"),
187-
allRepos: []configapi.Repository{},
185+
name: "successful deletion with empty repo list",
186+
repo: createTestRepoWithFinalizer("test-repo", "test-ns"),
187+
allRepos: []configapi.Repository{},
188188
expectFinalizer: false,
189189
},
190190
{
191-
name: "list repositories error",
192-
repo: createTestRepoWithFinalizer("test-repo", "test-ns"),
193-
listError: errors.New("list failed"),
194-
expectError: true,
191+
name: "list repositories error",
192+
repo: createTestRepoWithFinalizer("test-repo", "test-ns"),
193+
listError: errors.New("list failed"),
194+
expectError: true,
195195
expectFinalizer: true,
196196
},
197197
{
@@ -200,8 +200,8 @@ func TestHandleDeletion(t *testing.T) {
200200
allRepos: []configapi.Repository{
201201
*createTestRepo("other-repo", "test-ns"),
202202
},
203-
cacheError: errors.New("cache close failed"),
204-
expectRequeue: true,
203+
cacheError: errors.New("cache close failed"),
204+
expectRequeue: true,
205205
expectFinalizer: true,
206206
},
207207
{
@@ -217,7 +217,7 @@ func TestHandleDeletion(t *testing.T) {
217217
t.Run(tt.name, func(t *testing.T) {
218218
// Create mock client
219219
mockClient := mockclient.NewMockClient(t)
220-
220+
221221
// Setup List expectation
222222
if tt.listError != nil {
223223
mockClient.EXPECT().List(mock.Anything, &configapi.RepositoryList{}).Return(tt.listError)
@@ -227,7 +227,7 @@ func TestHandleDeletion(t *testing.T) {
227227
repoList.Items = tt.allRepos
228228
}).Return(nil)
229229
}
230-
230+
231231
// Setup Update expectation (only if no list error and no cache error)
232232
if tt.listError == nil && tt.cacheError == nil {
233233
if tt.updateError != nil {
@@ -279,12 +279,12 @@ func TestHandleDeletionTimeout(t *testing.T) {
279279
// Create context that will timeout quickly
280280
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Millisecond)
281281
defer cancel()
282-
282+
283283
// Wait for context to timeout
284284
time.Sleep(10 * time.Millisecond)
285285

286286
repo := createTestRepoWithFinalizer("test-repo", "test-ns")
287-
287+
288288
fakeClient := mockclient.NewMockClient(t)
289289
fakeClient.EXPECT().List(mock.Anything, &configapi.RepositoryList{}).Return(context.DeadlineExceeded)
290290

@@ -305,4 +305,4 @@ func createTestRepoWithFinalizer(name, namespace string) *configapi.Repository {
305305
repo := createTestRepo(name, namespace)
306306
controllerutil.AddFinalizer(repo, RepositoryFinalizer)
307307
return repo
308-
}
308+
}

controllers/repositories/pkg/controllers/repository/status_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ func TestUpdateRepoStatusWithBackoff(t *testing.T) {
8383
for _, tt := range tests {
8484
t.Run(tt.name, func(t *testing.T) {
8585
repo := createTestRepo("test-repo", "test-ns")
86-
86+
8787
mockClient := mockclient.NewMockClient(t)
8888
mockStatusWriter := mockclient.NewMockSubResourceWriter(t)
89-
89+
9090
mockClient.EXPECT().Status().Return(mockStatusWriter)
9191
if tt.name == "conflict error retries" {
9292
// First call returns conflict, second call succeeds
@@ -114,8 +114,8 @@ func TestHasSpecChanged(t *testing.T) {
114114
expected bool
115115
}{
116116
{
117-
name: "no conditions - new repo",
118-
repo: createTestRepo("test-repo", "test-ns"),
117+
name: "no conditions - new repo",
118+
repo: createTestRepo("test-repo", "test-ns"),
119119
expected: true, // New repos have Generation=1, ObservedGeneration=0, so spec changed
120120
},
121121
{
@@ -137,7 +137,7 @@ func TestHasSpecChanged(t *testing.T) {
137137
name: "controller restart during spec change - generation mismatch",
138138
repo: func() *configapi.Repository {
139139
repo := createTestRepo("test-repo", "test-ns")
140-
repo.Generation = 6 // Spec was changed
140+
repo.Generation = 6 // Spec was changed
141141
repo.Status.ObservedGeneration = 5 // Controller crashed before updating status
142142
repo.Status.Conditions = []metav1.Condition{{
143143
Type: configapi.RepositoryReady,
@@ -198,38 +198,38 @@ func TestUpdateRepoStatusWithBackoffExtended(t *testing.T) {
198198
expectError bool
199199
}{
200200
{
201-
name: "status ready with next sync time",
202-
status: RepositoryStatusReady,
203-
syncError: nil,
201+
name: "status ready with next sync time",
202+
status: RepositoryStatusReady,
203+
syncError: nil,
204204
nextSyncTime: func() *time.Time { t := time.Now().Add(time.Hour); return &t }(),
205-
expectError: false,
205+
expectError: false,
206206
},
207207
{
208-
name: "status error with sync error",
209-
status: RepositoryStatusError,
210-
syncError: errors.New("sync failed"),
208+
name: "status error with sync error",
209+
status: RepositoryStatusError,
210+
syncError: errors.New("sync failed"),
211211
nextSyncTime: nil,
212-
expectError: false,
212+
expectError: false,
213213
},
214214
{
215-
name: "status sync in progress",
216-
status: RepositoryStatusSyncInProgress,
217-
syncError: nil,
215+
name: "status sync in progress",
216+
status: RepositoryStatusSyncInProgress,
217+
syncError: nil,
218218
nextSyncTime: nil,
219-
expectError: false,
219+
expectError: false,
220220
},
221221
}
222222

223223
for _, tt := range tests {
224224
t.Run(tt.name, func(t *testing.T) {
225225
repo := createTestRepo("test-repo", "test-ns")
226-
226+
227227
mockClient := mockclient.NewMockClient(t)
228228
mockStatusWriter := mockclient.NewMockSubResourceWriter(t)
229-
229+
230230
mockClient.EXPECT().Status().Return(mockStatusWriter)
231231
mockStatusWriter.EXPECT().Patch(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
232-
232+
233233
reconciler := &RepositoryReconciler{Client: mockClient}
234234
err := reconciler.updateRepoStatusWithBackoff(ctx, repo, tt.status, tt.syncError, tt.nextSyncTime)
235235
if tt.expectError {

0 commit comments

Comments
 (0)