-
Notifications
You must be signed in to change notification settings - Fork 36
PR Controller PoC #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
PR Controller PoC #514
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3dfdad8
PR Controller PoC
efiacor ea783d8
Fix failing CI checks
efiacor 319f15a
Fix failing upgrade cli test client failure
efiacor dd4b53a
Add SS field selectors to CRD
efiacor 29aa620
Bump to kpt beta.62
efiacor 2a6a9b6
Add --show-kptfile impl to v1alpha2
efiacor 39804d5
Revert ResolveToImage call signature
efiacor dc9e1fc
Rebase on main
efiacor 98fc2b6
Update to use kptfilev1.Locator api change
efiacor aa08536
Address review comments
efiacor 7fa04fb
Add missed finalizer RBAC etc
efiacor 14a2dbf
Add ownerRef and finalizer logic to rpkg ctr
efiacor 7963023
Reimpl v1alpha2 repo filtering on packagecommon
efiacor 3d86429
Fix missed mocks
efiacor 141bb16
Address review comments
efiacor a04b3ab
Fix SSA field ownership, controller bugs, and lifecycle handling
efiacor a1979ee
Fix failing tests
efiacor 8d2c180
Add more test coverage
efiacor 0d6ef29
Fix repo resync and add launch
efiacor 6835050
Impl missed DeletePackage fn for git cleanup
efiacor 9e11d7f
Add missed DbPushDraftsToGit flag to ctr cache
efiacor e688d57
Add missed rebase removal
efiacor 1386352
Address review comments
efiacor 0dac197
Address review comments
efiacor 4b66cd2
Add FnConfigRec wiring to PR Controller
efiacor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Copyright 2026 The kpt and Nephio Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package v1alpha2 | ||
|
|
||
| import ( | ||
| kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1" | ||
| ) | ||
|
|
||
| // KptfileToPackageConditions converts Kptfile status conditions to v1alpha2 PackageConditions. | ||
| func KptfileToPackageConditions(kf kptfilev1.KptFile) []PackageCondition { | ||
| if kf.Status == nil { | ||
| return nil | ||
| } | ||
| conds := make([]PackageCondition, 0, len(kf.Status.Conditions)) | ||
| for _, c := range kf.Status.Conditions { | ||
| conds = append(conds, PackageCondition{ | ||
| Type: c.Type, | ||
| Status: PackageConditionStatus(c.Status), | ||
| Reason: c.Reason, | ||
| Message: c.Message, | ||
| }) | ||
| } | ||
| return conds | ||
| } | ||
|
|
||
| // KptfileToReadinessGates converts Kptfile readiness gates to v1alpha2 ReadinessGates. | ||
| func KptfileToReadinessGates(kf kptfilev1.KptFile) []ReadinessGate { | ||
| if kf.Info == nil { | ||
| return nil | ||
| } | ||
| gates := make([]ReadinessGate, 0, len(kf.Info.ReadinessGates)) | ||
| for _, rg := range kf.Info.ReadinessGates { | ||
| gates = append(gates, ReadinessGate{ConditionType: rg.ConditionType}) | ||
| } | ||
| return gates | ||
| } | ||
|
|
||
| // KptfileToPackageMetadata converts Kptfile labels and annotations to v1alpha2 PackageMetadata. | ||
| func KptfileToPackageMetadata(kf kptfilev1.KptFile) *PackageMetadata { | ||
| if len(kf.Labels) == 0 && len(kf.Annotations) == 0 { | ||
| return nil | ||
| } | ||
| return &PackageMetadata{ | ||
| Labels: kf.Labels, | ||
| Annotations: kf.Annotations, | ||
| } | ||
| } | ||
|
|
||
| // KptLocatorToLocator converts a kpt Locator to a v1alpha2 Locator. | ||
| // The two types are structurally identical but live in different packages. | ||
| func KptLocatorToLocator(lock kptfilev1.Locator) *Locator { | ||
| if lock.Git == nil { | ||
| return nil | ||
| } | ||
| return &Locator{ | ||
| Type: OriginType(lock.Type), | ||
| Git: &GitLock{ | ||
| Repo: lock.Git.Repo, | ||
| Directory: lock.Git.Directory, | ||
| Ref: lock.Git.Ref, | ||
| Commit: lock.Git.Commit, | ||
| }, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| // Copyright 2026 The kpt and Nephio Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package v1alpha2 | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestKptfileToPackageConditions(t *testing.T) { | ||
| // nil status | ||
| assert.Nil(t, KptfileToPackageConditions(kptfilev1.KptFile{})) | ||
|
|
||
| // empty conditions | ||
| kf := kptfilev1.KptFile{Status: &kptfilev1.Status{}} | ||
| assert.Empty(t, KptfileToPackageConditions(kf)) | ||
|
|
||
| // populated conditions | ||
| kf.Status.Conditions = []kptfilev1.Condition{ | ||
| {Type: "Ready", Status: kptfilev1.ConditionTrue, Reason: "AllGood", Message: "all good"}, | ||
| {Type: "Validated", Status: kptfilev1.ConditionFalse, Reason: "Failed", Message: "bad input"}, | ||
| } | ||
| conds := KptfileToPackageConditions(kf) | ||
| assert.Len(t, conds, 2) | ||
| assert.Equal(t, "Ready", conds[0].Type) | ||
| assert.Equal(t, PackageConditionTrue, conds[0].Status) | ||
| assert.Equal(t, "AllGood", conds[0].Reason) | ||
| assert.Equal(t, "all good", conds[0].Message) | ||
| assert.Equal(t, "Validated", conds[1].Type) | ||
| assert.Equal(t, PackageConditionFalse, conds[1].Status) | ||
| } | ||
|
|
||
| func TestKptfileToReadinessGates(t *testing.T) { | ||
| // nil info | ||
| assert.Nil(t, KptfileToReadinessGates(kptfilev1.KptFile{})) | ||
|
|
||
| // empty gates | ||
| kf := kptfilev1.KptFile{Info: &kptfilev1.PackageInfo{}} | ||
| assert.Empty(t, KptfileToReadinessGates(kf)) | ||
|
|
||
| // populated gates | ||
| kf.Info.ReadinessGates = []kptfilev1.ReadinessGate{ | ||
| {ConditionType: "Ready"}, | ||
| {ConditionType: "Validated"}, | ||
| } | ||
| gates := KptfileToReadinessGates(kf) | ||
| assert.Len(t, gates, 2) | ||
| assert.Equal(t, "Ready", gates[0].ConditionType) | ||
| assert.Equal(t, "Validated", gates[1].ConditionType) | ||
| } | ||
|
|
||
| func TestKptfileToPackageMetadata(t *testing.T) { | ||
| // no labels or annotations | ||
| assert.Nil(t, KptfileToPackageMetadata(kptfilev1.KptFile{})) | ||
|
|
||
| // labels only | ||
| kf := kptfilev1.KptFile{} | ||
| kf.Labels = map[string]string{"app": "foo"} | ||
| meta := KptfileToPackageMetadata(kf) | ||
| assert.Equal(t, "foo", meta.Labels["app"]) | ||
| assert.Nil(t, meta.Annotations) | ||
|
|
||
| // annotations only | ||
| kf = kptfilev1.KptFile{} | ||
| kf.Annotations = map[string]string{"note": "bar"} | ||
| meta = KptfileToPackageMetadata(kf) | ||
| assert.Nil(t, meta.Labels) | ||
| assert.Equal(t, "bar", meta.Annotations["note"]) | ||
|
|
||
| // both | ||
| kf = kptfilev1.KptFile{} | ||
| kf.Labels = map[string]string{"app": "foo"} | ||
| kf.Annotations = map[string]string{"note": "bar"} | ||
| meta = KptfileToPackageMetadata(kf) | ||
| assert.Equal(t, "foo", meta.Labels["app"]) | ||
| assert.Equal(t, "bar", meta.Annotations["note"]) | ||
| } | ||
|
|
||
| func TestKptLocatorToLocator(t *testing.T) { | ||
| // nil git | ||
| assert.Nil(t, KptLocatorToLocator(kptfilev1.Locator{})) | ||
|
|
||
| // populated | ||
| lock := kptfilev1.Locator{ | ||
| Type: kptfilev1.GitOrigin, | ||
| Git: &kptfilev1.GitLock{ | ||
| Repo: "https://github.com/example/repo.git", | ||
| Directory: "pkg/foo", | ||
| Ref: "v1.0.0", | ||
| Commit: "abc123", | ||
| }, | ||
| } | ||
| loc := KptLocatorToLocator(lock) | ||
| assert.Equal(t, OriginType(kptfilev1.GitOrigin), loc.Type) | ||
| assert.Equal(t, "https://github.com/example/repo.git", loc.Git.Repo) | ||
| assert.Equal(t, "pkg/foo", loc.Git.Directory) | ||
| assert.Equal(t, "v1.0.0", loc.Git.Ref) | ||
| assert.Equal(t, "abc123", loc.Git.Commit) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.