Skip to content

Commit 90ec9ca

Browse files
committed
refactor: JSON columns now JSON not JSONString
1 parent a8240cc commit 90ec9ca

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

config/github_connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package config
22

3-
import "github.com/turbot/tailpipe-plugin-sdk/parse"
3+
const PluginName = "github"
44

55
type GitHubConnection struct {
66
}
77

8-
func NewGitHubConnection() parse.Config {
9-
return &GitHubConnection{}
8+
func (c *GitHubConnection) Identifier() string {
9+
return PluginName
1010
}
1111

1212
func (c *GitHubConnection) Validate() error {

github/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func NewPlugin() (_ plugin.TailpipePlugin, err error) {
2121
}()
2222

2323
p := &Plugin{
24-
PluginImpl: plugin.NewPluginImpl[*config.GitHubConnection]("github"),
24+
PluginImpl: plugin.NewPluginImpl(config.PluginName),
2525
}
2626

2727
return p, nil

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
github.com/jackc/pgx/v5 v5.6.0 // indirect
2020
github.com/jackc/puddle/v2 v2.2.1 // indirect
2121
github.com/jtolds/gls v4.20.0+incompatible // indirect
22+
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 // indirect
2223
github.com/satyrius/gonx v1.4.0 // indirect
2324
github.com/smarty/assertions v1.16.0 // indirect
2425
github.com/turbot/pipes-sdk-go v0.9.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
592592
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
593593
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
594594
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
595+
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 h1:18kd+8ZUlt/ARXhljq+14TwAoKa61q6dX8jtwOf6DH8=
596+
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
595597
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
596598
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
597599
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

rows/audit_log.go

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package rows
22

33
import (
4-
"encoding/json"
54
"strconv"
65
"time"
76

87
"github.com/turbot/tailpipe-plugin-sdk/enrichment"
9-
"github.com/turbot/tailpipe-plugin-sdk/types"
108
)
119

1210
/*
@@ -22,26 +20,26 @@ import (
2220
type AuditLog struct {
2321
enrichment.CommonFields
2422

25-
Action *string `json:"action,omitempty"`
26-
Actor *string `json:"actor,omitempty"`
27-
ActorID *int64 `json:"actor_id,omitempty"`
28-
ActorIP *string `json:"actor_ip,omitempty"`
29-
ActorLocation *types.JSONString `json:"actor_location,omitempty"`
30-
Business *string `json:"business,omitempty"`
31-
BusinessID *int64 `json:"business_id,omitempty"`
32-
CreatedAt *time.Time `json:"created_at,omitempty"`
33-
DocumentID *string `json:"_document_id,omitempty"`
34-
ExternalIdentityNameID *string `json:"external_identity_nameid,omitempty"`
35-
ExternalIdentityUsername *string `json:"external_identity_username,omitempty"`
36-
HashedToken *string `json:"hashed_token,omitempty"`
37-
Org *string `json:"org,omitempty"`
38-
OrgID *string `json:"org_id,omitempty"`
39-
Timestamp *time.Time `json:"timestamp,omitempty"`
40-
TokenID *int64 `json:"token_id,omitempty"`
41-
TokenScopes *string `json:"token_scopes,omitempty"`
42-
User *string `json:"user,omitempty"`
43-
UserID *int64 `json:"user_id,omitempty"`
44-
AdditionalFields *types.JSONString `json:"additional_fields,omitempty"`
23+
Action *string `json:"action,omitempty"`
24+
Actor *string `json:"actor,omitempty"`
25+
ActorID *int64 `json:"actor_id,omitempty"`
26+
ActorIP *string `json:"actor_ip,omitempty"`
27+
ActorLocation *map[string]interface{} `json:"actor_location,omitempty" parquet:"type=JSON"`
28+
Business *string `json:"business,omitempty"`
29+
BusinessID *int64 `json:"business_id,omitempty"`
30+
CreatedAt *time.Time `json:"created_at,omitempty"`
31+
DocumentID *string `json:"_document_id,omitempty"`
32+
ExternalIdentityNameID *string `json:"external_identity_nameid,omitempty"`
33+
ExternalIdentityUsername *string `json:"external_identity_username,omitempty"`
34+
HashedToken *string `json:"hashed_token,omitempty"`
35+
Org *string `json:"org,omitempty"`
36+
OrgID *string `json:"org_id,omitempty"`
37+
Timestamp *time.Time `json:"timestamp,omitempty"`
38+
TokenID *int64 `json:"token_id,omitempty"`
39+
TokenScopes *string `json:"token_scopes,omitempty"`
40+
User *string `json:"user,omitempty"`
41+
UserID *int64 `json:"user_id,omitempty"`
42+
AdditionalFields *map[string]interface{} `json:"additional_fields,omitempty" parquet:"type=JSON"`
4543
}
4644

4745
type ActorLocation struct {
@@ -77,11 +75,7 @@ func (a *AuditLog) FromMap(in map[string]interface{}) {
7775
}
7876
case "actor_location":
7977
if location, ok := value.(map[string]interface{}); ok {
80-
locJSON, err := json.Marshal(location)
81-
if err == nil {
82-
locStr := types.JSONString(locJSON)
83-
a.ActorLocation = &locStr
84-
}
78+
a.ActorLocation = &location
8579
}
8680
case "business":
8781
if strVal, ok := value.(string); ok {
@@ -153,9 +147,6 @@ func (a *AuditLog) FromMap(in map[string]interface{}) {
153147

154148
// Marshal dynamic fields into JSON and store in AdditionalFields
155149
if len(dynamicFields) > 0 {
156-
if dynamicJSON, err := json.Marshal(dynamicFields); err == nil {
157-
djStr := types.JSONString(dynamicJSON)
158-
a.AdditionalFields = &djStr
159-
}
150+
a.AdditionalFields = &dynamicFields
160151
}
161152
}

tables/audit_log_table_config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ package tables
33
type AuditLogTableConfig struct {
44
}
55

6+
func (a *AuditLogTableConfig) Identifier() string {
7+
return AuditLogTableIdentifier
8+
}
9+
610
func (a *AuditLogTableConfig) Validate() error {
711
return nil
812
}

0 commit comments

Comments
 (0)