diff --git a/internal/adapter/adapter.go b/internal/adapter/adapter.go index 0c277c7..898f1c7 100644 --- a/internal/adapter/adapter.go +++ b/internal/adapter/adapter.go @@ -18,6 +18,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/kubernetes/pkg/apis/apps" appsv1 "k8s.io/kubernetes/pkg/apis/apps/v1" + "k8s.io/kubernetes/pkg/apis/batch" + batchv1 "k8s.io/kubernetes/pkg/apis/batch/v1" "k8s.io/kubernetes/pkg/apis/core" corev1 "k8s.io/kubernetes/pkg/apis/core/v1" "k8s.io/kubernetes/pkg/apis/storage" @@ -196,6 +198,8 @@ func initConversionScheme() *runtime.Scheme { apps.AddToScheme(scheme) appsv1.AddToScheme(scheme) + batch.AddToScheme(scheme) + batchv1.AddToScheme(scheme) core.AddToScheme(scheme) corev1.AddToScheme(scheme) storage.AddToScheme(scheme) diff --git a/internal/adapter/converter/job.go b/internal/adapter/converter/job.go index b4ce213..7eefb49 100644 --- a/internal/adapter/converter/job.go +++ b/internal/adapter/converter/job.go @@ -24,24 +24,31 @@ func (converter *DockerAPIConverter) UpdateJobFromContainerInfo(job *batch.Job, containerState := container.State + startTime, _ := time.Parse(time.RFC3339Nano, json.State.StartedAt) + + metaStartTime := &metav1.Time{ + Time: startTime, + } + + job.Status.StartTime = metaStartTime + job.Status.Active = 0 if containerState == "running" { job.Status.Active = 1 } else { - // TODO: handle completion status? if json.State.ExitCode == 0 { job.Status.Succeeded = 1 + + completionTime, _ := time.Parse(time.RFC3339Nano, json.State.FinishedAt) + + metaCompletionTime := &metav1.Time{ + Time: completionTime, + } + + job.Status.CompletionTime = metaCompletionTime } else { job.Status.Failed = 1 } - } - - // TODO: handle duration? - // /containers//json ? This will allow getting: - // - State.ExitCode - // - State.StartedAt - // - State.FinishedAt - job.Status.CompletionTime.Time, _ = time.Parse("", json.State.FinishedAt) }