Skip to content

Return the last applied object in status #404

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading