Skip to content

Commit 1a63d5a

Browse files
authored
Merge pull request #404 from barney-s/return-objects-after-apply
Return the last applied object in status
2 parents a8a1382 + 8542d89 commit 1a63d5a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

applylib/applyset/applyset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (a *ApplySet) ApplyOnce(ctx context.Context) (*ApplyResults, error) {
271271
results.applySuccess(gvk, nn)
272272
message := ""
273273
tracker.isHealthy, message, err = a.computeHealth(lastApplied)
274-
results.reportHealth(gvk, nn, tracker.isHealthy, message, err)
274+
results.reportHealth(gvk, nn, lastApplied, tracker.isHealthy, message, err)
275275
}
276276

277277
// We want to be more cautions on pruning and only do it if all manifests are applied.

applylib/applyset/results.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package applyset
1818

1919
import (
20+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2021
"k8s.io/apimachinery/pkg/runtime/schema"
2122
"k8s.io/apimachinery/pkg/types"
2223
"k8s.io/klog/v2"
@@ -39,6 +40,7 @@ type ObjectStatus struct {
3940
NameNamespace types.NamespacedName
4041
Apply ApplyInfo
4142
Health HealthInfo
43+
LastApplied *unstructured.Unstructured
4244
}
4345

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

138140
// reportHealth records the health of an object.
139-
func (r *ApplyResults) reportHealth(gvk schema.GroupVersionKind, nn types.NamespacedName, isHealthy bool, message string, err error) {
141+
func (r *ApplyResults) reportHealth(gvk schema.GroupVersionKind, nn types.NamespacedName, lastApplied *unstructured.Unstructured, isHealthy bool, message string, err error) {
140142
r.Objects = append(r.Objects, ObjectStatus{
141143
GVK: gvk,
142144
NameNamespace: nn,
@@ -148,6 +150,7 @@ func (r *ApplyResults) reportHealth(gvk schema.GroupVersionKind, nn types.Namesp
148150
Apply: ApplyInfo{
149151
IsPruned: false,
150152
},
153+
LastApplied: lastApplied,
151154
})
152155
if isHealthy {
153156
r.healthyCount++

0 commit comments

Comments
 (0)