Skip to content

Commit

Permalink
Merge pull request #404 from barney-s/return-objects-after-apply
Browse files Browse the repository at this point in the history
Return the last applied object in status
  • Loading branch information
k8s-ci-robot authored Aug 30, 2024
2 parents a8a1382 + 8542d89 commit 1a63d5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion applylib/applyset/applyset.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (a *ApplySet) ApplyOnce(ctx context.Context) (*ApplyResults, error) {
results.applySuccess(gvk, nn)
message := ""
tracker.isHealthy, message, err = a.computeHealth(lastApplied)
results.reportHealth(gvk, nn, tracker.isHealthy, message, err)
results.reportHealth(gvk, nn, lastApplied, tracker.isHealthy, message, err)
}

// We want to be more cautions on pruning and only do it if all manifests are applied.
Expand Down
5 changes: 4 additions & 1 deletion applylib/applyset/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package applyset

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
Expand All @@ -39,6 +40,7 @@ type ObjectStatus struct {
NameNamespace types.NamespacedName
Apply ApplyInfo
Health HealthInfo
LastApplied *unstructured.Unstructured
}

// ApplyResults contains the results of an Apply operation.
Expand Down Expand Up @@ -136,7 +138,7 @@ func (r *ApplyResults) pruneSuccess(gvk schema.GroupVersionKind, nn types.Namesp
}

// reportHealth records the health of an object.
func (r *ApplyResults) reportHealth(gvk schema.GroupVersionKind, nn types.NamespacedName, isHealthy bool, message string, err error) {
func (r *ApplyResults) reportHealth(gvk schema.GroupVersionKind, nn types.NamespacedName, lastApplied *unstructured.Unstructured, isHealthy bool, message string, err error) {
r.Objects = append(r.Objects, ObjectStatus{
GVK: gvk,
NameNamespace: nn,
Expand All @@ -148,6 +150,7 @@ func (r *ApplyResults) reportHealth(gvk schema.GroupVersionKind, nn types.Namesp
Apply: ApplyInfo{
IsPruned: false,
},
LastApplied: lastApplied,
})
if isHealthy {
r.healthyCount++
Expand Down

0 comments on commit 1a63d5a

Please sign in to comment.