fix: seed now merges attributes instead of overwriting on upsert, add enrollment attrs to seed
This commit is contained in:
@@ -123,8 +123,10 @@ func IngestInventorySeed(ctx context.Context, tx pgx.Tx, data map[string]any) (*
|
||||
_, err = tx.Exec(ctx,
|
||||
`INSERT INTO entities (id, slug, type, name, state, attributes, version, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, 1, now(), now())
|
||||
ON CONFLICT (slug) DO UPDATE SET type = $3, name = $4, state = $5,
|
||||
attributes = $6, updated_at = now()`,
|
||||
ON CONFLICT (slug) DO UPDATE SET
|
||||
type = EXCLUDED.type, name = EXCLUDED.name,
|
||||
attributes = entities.attributes || EXCLUDED.attributes,
|
||||
updated_at = now()`,
|
||||
entityID, slug, typeName, name, nullableStr(state), string(attrsBytes))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("entity %s: %w", slug, err)
|
||||
|
||||
@@ -96,7 +96,10 @@ entities:
|
||||
lan_ip: 192.168.178.182
|
||||
mesh: {netbird: {fqdn: mac-mini-234-17.netbird.selfhosted}}
|
||||
age_pubkey: age169104ee1a9e1577d493820830560197f0adf56bf8f1c369d57c152c03f9437ae
|
||||
note: only macOS in fleet; future Oikos OS Docker host
|
||||
note: only macOS in fleet; Oikos Docker host. Enrolled 2026-07-08.
|
||||
enrolled_at: "2026-07-08T09:49:03Z"
|
||||
mesh_ip: 192.168.178.182
|
||||
hostname: mac-mini
|
||||
- slug: "ws:republic-laptop"
|
||||
type: workstation
|
||||
name: republic-laptop
|
||||
|
||||
Reference in New Issue
Block a user