Skip to content

Commit fd82475

Browse files
authored
feat: logs prev container (#3469)
* minor-change * conditional break fixed * changing names
1 parent 47bc404 commit fd82475

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

client/k8s/application/Application.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ type K8sRequestBean struct {
5454
}
5555

5656
type PodLogsRequest struct {
57-
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
58-
TailLines int `json:"tailLines"`
59-
Follow bool `json:"follow"`
60-
ContainerName string `json:"containerName"`
57+
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
58+
TailLines int `json:"tailLines"`
59+
Follow bool `json:"follow"`
60+
ContainerName string `json:"containerName"`
61+
IsPrevContainerLogsEnabled bool `json:"previous"`
6162
}
6263

6364
type ResourceIdentifier struct {
@@ -236,6 +237,7 @@ func (impl K8sClientServiceImpl) GetPodLogs(ctx context.Context, restConfig *res
236237
TailLines: &tailLines,
237238
Container: podLogsRequest.ContainerName,
238239
Timestamps: true,
240+
Previous: podLogsRequest.IsPrevContainerLogsEnabled,
239241
}
240242
if podLogsRequest.SinceTime != nil {
241243
podLogOptions.SinceTime = podLogsRequest.SinceTime

util/ValidatorHelper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func AutoScale(dat map[string]interface{}) (bool, error) {
232232
if dat["kedaAutoscaling"] != nil {
233233
kedaAutoScale, ok := dat["kedaAutoscaling"].(map[string]interface{})["enabled"]
234234
if ok {
235-
kedaAutoScaleEnabled=kedaAutoScale.(bool)
235+
kedaAutoScaleEnabled = kedaAutoScale.(bool)
236236
}
237237
}
238238
if dat["autoscaling"] != nil {

util/k8s/k8sApplicationService.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ func (impl *K8sApplicationServiceImpl) ValidatePodLogsRequestQuery(r *http.Reque
148148
sinceSeconds = 0
149149
}*/
150150
containerName, clusterIdString := v.Get("containerName"), v.Get("clusterId")
151+
prevContainerLogs := v.Get("previous")
152+
isPrevLogs, err := strconv.ParseBool(prevContainerLogs)
153+
if err != nil {
154+
isPrevLogs = false
155+
}
151156
appId := v.Get("appId")
152157
follow, err := strconv.ParseBool(v.Get("follow"))
153158
if err != nil {
@@ -164,9 +169,10 @@ func (impl *K8sApplicationServiceImpl) ValidatePodLogsRequestQuery(r *http.Reque
164169
},
165170
PodLogsRequest: application.PodLogsRequest{
166171
//SinceTime: sinceSeconds,
167-
TailLines: tailLines,
168-
Follow: follow,
169-
ContainerName: containerName,
172+
TailLines: tailLines,
173+
Follow: follow,
174+
ContainerName: containerName,
175+
IsPrevContainerLogsEnabled: isPrevLogs,
170176
},
171177
}
172178
request.K8sRequest = k8sRequest

0 commit comments

Comments
 (0)