From 2c8bef237fa286183c8f031b0ad27396a2cc2e7e Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 15 Nov 2026 18:11:38 +1100 Subject: [PATCH] refactor(connector): the SDK and Alertmanager connector use encoding/json/v2 and jsontext (archie #1980) --- connectors/alertmanager/alertmanager.go | 2 +- connectors/alertmanager/alertmanager_test.go | 2 +- sdk/connector/connector.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/connectors/alertmanager/alertmanager.go b/connectors/alertmanager/alertmanager.go index 3b982ae..05f8281 100644 --- a/connectors/alertmanager/alertmanager.go +++ b/connectors/alertmanager/alertmanager.go @@ -2,7 +2,7 @@ package main import ( "context" - "encoding/json" + json "encoding/json/v2" "errors" "fmt" "time" diff --git a/connectors/alertmanager/alertmanager_test.go b/connectors/alertmanager/alertmanager_test.go index 254a7b5..c20b338 100644 --- a/connectors/alertmanager/alertmanager_test.go +++ b/connectors/alertmanager/alertmanager_test.go @@ -1,7 +1,7 @@ package main import ( - "encoding/json" + json "encoding/json/v2" "testing" ) diff --git a/sdk/connector/connector.go b/sdk/connector/connector.go index fda9d82..29d09ab 100644 --- a/sdk/connector/connector.go +++ b/sdk/connector/connector.go @@ -7,7 +7,7 @@ import ( "context" "crypto/sha256" "encoding/hex" - "encoding/json" + "encoding/json/jsontext" "time" connectorv1 "github.com/samcharles93/archipelago/sdk/connector/v1" @@ -33,7 +33,7 @@ type Description struct { type Event struct { Type string SourceEventID string - Fields json.RawMessage + Fields jsontext.Value LinkKey string OccurredAt time.Time } @@ -52,13 +52,13 @@ type Parser interface { // any action that isn't read-only, and returns unknown=true when it can't // confirm what its effect did. type Actor interface { - Resolve(ctx context.Context, action string, input json.RawMessage) (*connectorv1.ResolveResponse, error) - Invoke(ctx context.Context, action string, input json.RawMessage, idempotencyKey string) (output json.RawMessage, unknown bool, err error) + Resolve(ctx context.Context, action string, input jsontext.Value) (*connectorv1.ResolveResponse, error) + Invoke(ctx context.Context, action string, input jsontext.Value, idempotencyKey string) (output jsontext.Value, unknown bool, err error) } // Looker answers read-only lookups. found=false means nothing was found. type Looker interface { - Lookup(ctx context.Context, name string, input json.RawMessage) (output json.RawMessage, found bool, err error) + Lookup(ctx context.Context, name string, input jsontext.Value) (output jsontext.Value, found bool, err error) } // Digest identifies one concrete action, the same way archie-core does: its