Skip to content

Commit

Permalink
chore: minor formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed May 2, 2024
1 parent 8c201c5 commit 5de8e7b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions controllers/v1beta1/podmonitor_buildhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Logs on pod %s, assigned to cluster %s
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -334,7 +334,7 @@ func (r *LagoonMonitorReconciler) updateDeploymentAndEnvironmentTask(
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-tasks:controller", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -429,7 +429,7 @@ func (r *LagoonMonitorReconciler) buildStatusLogsToLagoonLogs(
)
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -568,24 +568,24 @@ Build %s

// do any message publishing here, and update any pending messages if needed
if err = r.buildStatusLogsToLagoonLogs(opLog, &lagoonBuild, &jobPod, &lagoonEnv, namespace, buildCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish build status logs"))
opLog.Error(err, "unable to publish build status logs")
}
if err = r.updateDeploymentAndEnvironmentTask(opLog, &lagoonBuild, &jobPod, &lagoonEnv, namespace, buildCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish build update"))
opLog.Error(err, "unable to publish build update")
}
// if the container logs can't be retrieved, we don't want to send any build logs back, as this will nuke
// any previously received logs
if !strings.Contains(string(allContainerLogs), "unable to retrieve container logs for containerd") {
if err = r.buildLogsToLagoonLogs(opLog, &lagoonBuild, &jobPod, namespace, buildCondition.ToLower(), allContainerLogs); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish build logs"))
opLog.Error(err, "unable to publish build logs")
}
}
mergePatch, _ := json.Marshal(mergeMap)
// check if the build exists
if err := r.Get(ctx, req.NamespacedName, &lagoonBuild); err == nil {
// if it does, try to patch it
if err := r.Patch(ctx, &lagoonBuild, client.RawPatch(types.MergePatchType, mergePatch)); err != nil {
opLog.Error(err, "Unable to update resource")
opLog.Error(err, "unable to update resource")
}
}
// just delete the pod
Expand Down
14 changes: 7 additions & 7 deletions controllers/v1beta1/podmonitor_taskhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Logs on pod %s, assigned to cluster %s
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -200,7 +200,7 @@ func (r *LagoonMonitorReconciler) updateLagoonTask(opLog logr.Logger,
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-tasks:controller", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -246,7 +246,7 @@ func (r *LagoonMonitorReconciler) taskStatusLogsToLagoonLogs(opLog logr.Logger,
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -344,24 +344,24 @@ Task %s
// send any messages to lagoon message queues
// update the deployment with the status
if err = r.taskStatusLogsToLagoonLogs(opLog, &lagoonTask, &jobPod, taskCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish task status logs"))
opLog.Error(err, "unable to publish task status logs")
}
if err = r.updateLagoonTask(opLog, &lagoonTask, &jobPod, taskCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish task update"))
opLog.Error(err, "unable to publish task update")
}
// if the container logs can't be retrieved, we don't want to send any task logs back, as this will nuke
// any previously received logs
if !strings.Contains(string(allContainerLogs), "unable to retrieve container logs for containerd") {
if err = r.taskLogsToLagoonLogs(opLog, &lagoonTask, &jobPod, taskCondition.ToLower(), allContainerLogs); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish task logs"))
opLog.Error(err, "unable to publish task logs")
}
}
mergePatch, _ := json.Marshal(mergeMap)
// check if the task exists
if err := r.Get(ctx, req.NamespacedName, &lagoonTask); err == nil {
// if it does, try to patch it
if err := r.Patch(ctx, &lagoonTask, client.RawPatch(types.MergePatchType, mergePatch)); err != nil {
opLog.Error(err, "Unable to update resource")
opLog.Error(err, "unable to update resource")
}
}
// just delete the pod
Expand Down
14 changes: 7 additions & 7 deletions controllers/v1beta2/podmonitor_buildhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Logs on pod %s, assigned to cluster %s
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -340,7 +340,7 @@ func (r *LagoonMonitorReconciler) updateDeploymentAndEnvironmentTask(
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-tasks:controller", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -434,7 +434,7 @@ func (r *LagoonMonitorReconciler) buildStatusLogsToLagoonLogs(
)
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -574,24 +574,24 @@ Build %s

// do any message publishing here, and update any pending messages if needed
if err = r.buildStatusLogsToLagoonLogs(opLog, &lagoonBuild, &jobPod, &lagoonEnv, namespace, buildCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish build status logs"))
opLog.Error(err, "unable to publish build status logs")
}
if err = r.updateDeploymentAndEnvironmentTask(opLog, &lagoonBuild, &jobPod, &lagoonEnv, namespace, buildCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish build update"))
opLog.Error(err, "unable to publish build update")
}
// if the container logs can't be retrieved, we don't want to send any build logs back, as this will nuke
// any previously received logs
if !strings.Contains(string(allContainerLogs), "unable to retrieve container logs for containerd") {
if err = r.buildLogsToLagoonLogs(opLog, &lagoonBuild, &jobPod, namespace, buildCondition.ToLower(), allContainerLogs); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish build logs"))
opLog.Error(err, "unable to publish build logs")
}
}
mergePatch, _ := json.Marshal(mergeMap)
// check if the build exists
if err := r.Get(ctx, req.NamespacedName, &lagoonBuild); err == nil {
// if it does, try to patch it
if err := r.Patch(ctx, &lagoonBuild, client.RawPatch(types.MergePatchType, mergePatch)); err != nil {
opLog.Error(err, "Unable to update resource")
opLog.Error(err, "unable to update resource")
}
}
// just delete the pod
Expand Down
14 changes: 7 additions & 7 deletions controllers/v1beta2/podmonitor_taskhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Logs on pod %s, assigned to cluster %s
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -208,7 +208,7 @@ func (r *LagoonMonitorReconciler) updateLagoonTask(opLog logr.Logger,
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-tasks:controller", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -254,7 +254,7 @@ func (r *LagoonMonitorReconciler) taskStatusLogsToLagoonLogs(opLog logr.Logger,
}
msgBytes, err := json.Marshal(msg)
if err != nil {
opLog.Error(err, "Unable to encode message as JSON")
opLog.Error(err, "unable to encode message as JSON")
}
if err := r.Messaging.Publish("lagoon-logs", msgBytes); err != nil {
// if we can't publish the message, set it as a pending message
Expand Down Expand Up @@ -353,24 +353,24 @@ Task %s
// send any messages to lagoon message queues
// update the deployment with the status
if err = r.taskStatusLogsToLagoonLogs(opLog, &lagoonTask, &jobPod, taskCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish task status logs"))
opLog.Error(err, "unable to publish task status logs")
}
if err = r.updateLagoonTask(opLog, &lagoonTask, &jobPod, taskCondition.ToLower()); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish task update"))
opLog.Error(err, "unable to publish task update")
}
// if the container logs can't be retrieved, we don't want to send any task logs back, as this will nuke
// any previously received logs
if !strings.Contains(string(allContainerLogs), "unable to retrieve container logs for containerd") {
if err = r.taskLogsToLagoonLogs(opLog, &lagoonTask, &jobPod, taskCondition.ToLower(), allContainerLogs); err != nil {
opLog.Error(err, fmt.Sprintf("Unable to publish task logs"))
opLog.Error(err, "unable to publish task logs")
}
}
mergePatch, _ := json.Marshal(mergeMap)
// check if the task exists
if err := r.Get(ctx, req.NamespacedName, &lagoonTask); err == nil {
// if it does, try to patch it
if err := r.Patch(ctx, &lagoonTask, client.RawPatch(types.MergePatchType, mergePatch)); err != nil {
opLog.Error(err, "Unable to update resource")
opLog.Error(err, "unable to update resource")
}
}
// just delete the pod
Expand Down

0 comments on commit 5de8e7b

Please sign in to comment.