Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Dec 18, 2024
1 parent 27201ef commit 46ebf82
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions task/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import (
"github.com/konveyor/tackle2-hub/model"
"github.com/konveyor/tackle2-hub/reflect"
"github.com/konveyor/tackle2-hub/settings"
"gopkg.in/yaml.v2"
"gorm.io/gorm"
core "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
k8r "k8s.io/apimachinery/pkg/runtime"
k8j "k8s.io/apimachinery/pkg/runtime/serializer/json"
k8y "k8s.io/apimachinery/pkg/runtime/serializer/yaml"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand"
Expand Down Expand Up @@ -1020,16 +1022,48 @@ func (m *Manager) podSnapshot(task *Task, pod *core.Pod) (err error) {
defer func() {
_ = f.Close()
}()
type Pod struct {
core.Pod `yaml:",inline"`
Events []Event `yaml:",omitempty"`
}
d := Pod{
Pod: *pod,
Events: events,
}
b, _ := yaml.Marshal(d)
serializer := k8j.NewSerializerWithOptions(
k8y.DefaultMetaFactory,
nil,
nil,
k8j.SerializerOptions{
Yaml: true,
Pretty: true,
Strict: false,
})
pod.ManagedFields = nil
format := " %-8s%-11s%-6s%-19s%s\n"
_, _ = f.WriteString("---\n")
b, _ := k8r.Encode(serializer, pod)
_, _ = f.Write(b)
_, _ = f.WriteString("\n---\n")
_, _ = f.WriteString("Events: |\n")
_, _ = f.WriteString(
fmt.Sprintf(
format,
"Type",
"Reason",
"Age",
"Reporter",
"Message"))
_, _ = f.WriteString(
fmt.Sprintf(
format,
"-------",
"----------",
"-----",
"------------------",
"------------------"))
for _, event := range events {
_, _ = f.WriteString(
fmt.Sprintf(
format,
event.Type,
event.Reason,
event.Age,
event.Reporter,
event.Message))
}
task.attach(file)
return
}
Expand Down

0 comments on commit 46ebf82

Please sign in to comment.