diff --git a/README.md b/README.md index 2a7eb07..0b193e4 100644 --- a/README.md +++ b/README.md @@ -108,12 +108,18 @@ hosts: destination: root@10.10.10.10 ## SSH options (optional) options: ["-i", "/keys/hebele.pri"] + ## External identifier of the host (optional) + id: 20b88669-743f-4ae5-9823-5aacc2df7086 ## External URL for the host (optional) url: https://internal.documentation/hosts/somehost ## List of tags for the host (optional) tags: - oranges - strawberries + ## Arbitrary JSON data for the host (optional) + data: + owner: Client-1 + cost: 50 - name: otherhost url: https://internal.documentation/hosts/otherhost tags: diff --git a/config.yaml b/config.yaml index 1f400bb..820d705 100644 --- a/config.yaml +++ b/config.yaml @@ -15,12 +15,18 @@ hosts: destination: root@10.10.10.10 ## SSH options (optional) options: ["-i", "/keys/hebele.pri"] + ## External identifier of the host (optional) + id: 20b88669-743f-4ae5-9823-5aacc2df7086 ## External URL for the host (optional) url: https://internal.documentation/hosts/somehost ## List of tags for the host (optional) tags: - oranges - strawberries + ## Arbitrary JSON data for the host (optional) + data: + owner: Client-1 + cost: 50 - name: otherhost url: https://internal.documentation/hosts/otherhost tags: diff --git a/src/Lhp/Cli.hs b/src/Lhp/Cli.hs index 1874bda..e59c790 100644 --- a/src/Lhp/Cli.hs +++ b/src/Lhp/Cli.hs @@ -81,7 +81,15 @@ doCompile cpath dests par = do Left err -> BLC.hPutStrLn stderr (Aeson.encode err) >> pure (ExitFailure 1) Right sr -> BLC.putStrLn (Aeson.encode sr) >> pure ExitSuccess where - _mkHost d = Types.Host {Types._hostName = d, Types._hostSsh = Nothing, Types._hostUrl = Nothing, Types._hostTags = []} + _mkHost d = + Types.Host + { Types._hostName = d + , Types._hostSsh = Nothing + , Types._hostId = Nothing + , Types._hostUrl = Nothing + , Types._hostTags = [] + , Types._hostData = Aeson.Null + } -- ** schema diff --git a/src/Lhp/Types.hs b/src/Lhp/Types.hs index 9927342..240d476 100644 --- a/src/Lhp/Types.hs +++ b/src/Lhp/Types.hs @@ -46,8 +46,10 @@ instance ADC.HasCodec Report where data Host = Host { _hostName :: !T.Text , _hostSsh :: !(Maybe SshConfig) + , _hostId :: !(Maybe T.Text) , _hostUrl :: !(Maybe T.Text) , _hostTags :: ![T.Text] + , _hostData :: !Aeson.Value } deriving (Eq, Generic, Show) deriving (Aeson.FromJSON, Aeson.ToJSON) via (ADC.Autodocodec Host) @@ -62,8 +64,10 @@ instance ADC.HasCodec Host where Host <$> ADC.requiredField "name" "Name of the host." ADC..= _hostName <*> ADC.optionalField "ssh" "SSH configuration." ADC..= _hostSsh + <*> ADC.optionalField "id" "External identifier of the host." ADC..= _hostId <*> ADC.optionalField "url" "URL to external host information." ADC..= _hostUrl <*> ADC.optionalFieldWithDefault "tags" [] "Arbitrary tags for the host." ADC..= _hostTags + <*> ADC.optionalFieldWithDefault "data" Aeson.Null "Arbitrary data for the host." ADC..= _hostData -- * Host Report diff --git a/website/src/components/report/ShowHostDetails.tsx b/website/src/components/report/ShowHostDetails.tsx index b5b1f57..ddfdd52 100644 --- a/website/src/components/report/ShowHostDetails.tsx +++ b/website/src/components/report/ShowHostDetails.tsx @@ -17,6 +17,16 @@ export function ShowHostDetails({ host }: { host: LhpHostReport }) { 🔗 )} + {host.host.id && ( + { + navigator.clipboard.writeText(host.host.id || ''); + toast('External host identifier is copied to clipboard.'); + }} + > + {host.host.id} + + )}
@@ -139,6 +149,14 @@ export function ShowHostDetails({ host }: { host: LhpHostReport }) { ({ key: x, value: '✅' }))} />
+ + + Extra Host Data + + +
{host.host.data ? JSON.stringify(host.host.data || '#N/A', null, 2) : '#N/A'}
+
+
); } diff --git a/website/src/lib/data.ts b/website/src/lib/data.ts index 1738e73..d137d3e 100644 --- a/website/src/lib/data.ts +++ b/website/src/lib/data.ts @@ -137,6 +137,8 @@ export const LHP_PATROL_REPORT_SCHEMA = { host: { $comment: 'Host descriptor.\nHost Descriptor\nHost', properties: { + data: { $comment: 'Arbitrary data for the host.' }, + id: { $comment: 'External identifier of the host.', type: 'string' }, name: { $comment: 'Name of the host.', type: 'string' }, ssh: { $comment: 'SSH configuration.\nSSH Configuration\nSshConfig',