Skip to content
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

fix: keep time objects as time.Time in serialize #86

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

yashmehrotra
Copy link
Member

jp.Walk does not work for nested structs and we don't use time.Duration anywhere

Fixes: flanksource/mission-control-registry#265

@yashmehrotra yashmehrotra force-pushed the keep-time-object-as-time-object branch 3 times, most recently from ece3eec to 3a9e16d Compare August 28, 2024 06:11
@yashmehrotra yashmehrotra force-pushed the keep-time-object-as-time-object branch from 3a9e16d to 2e82dc1 Compare August 28, 2024 06:16
@moshloop
Copy link
Member

@yashmehrotra - I think this might break existing scripts:

Instead of time.Since(results.rows[0].time_end).getMinutes() > 2

We should be using `Age(results.rows[0].time_end) > Duration("2m")

Where Age takes an interface which can be a time.Time, or protobuf.Timestamp or string (to parse as timestamp)

@moshloop
Copy link
Member

Add a test / fixture / docs

  folder:
    - name: Correspondence/Mail - Failed
      path: /mnt/efs//correspondence/out/mailoutbox/failed
      filter:
        regex: ".*.err"
        # use the last known max, or 60 days ago if no last known max
        since: |
          {{`
            {{-  if last_result.results.max }}
            {{  last_result.results.max }}
            {{- else}}
            now-60d
            {{- end}}
          `}}
      transform:
        # Save the newest modified time to the results, overriding the full file listing that would normally be saved
        # if no new files detected, use the last known max
        expr: |
          {
            "detail": {
              "max": string(results.?newest.modified.orValue(last_result().results.?max.orValue("now-60d"))),
            }
          }.toJSON()

@moshloop
Copy link
Member

        'detail': { 'max':     string(results.?rows[0].max.orValue(last_result().?results.max.orValue(time.Now()))) },

@moshloop moshloop merged commit 7341e9c into main Aug 30, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mission-control-watchtower: error in Last full reconcile check
2 participants