Skip to content

Commit 65e65a2

Browse files
committed
Use path, rather than URL for actioninfo and target
Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
1 parent 7e8011c commit 65e65a2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

pkg/collect.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"net"
8+
"net/url"
89
"os"
910
"path"
1011
"path/filepath"
@@ -121,6 +122,25 @@ func CollectInventory(assets *[]RemoteAsset, params *CollectParams) ([]map[strin
121122
continue
122123
}
123124

125+
// Post-process the crawled data to convert absolute URLs to relative paths.
126+
for i := range systems {
127+
// Fix the top-level URI for the system.
128+
if strings.HasPrefix(systems[i].URI, "http") {
129+
if parsedURL, err := url.Parse(systems[i].URI); err == nil {
130+
systems[i].URI = parsedURL.Path
131+
}
132+
}
133+
134+
// Fix the URIs for each ethernet interface.
135+
for j, eth := range systems[i].EthernetInterfaces {
136+
if strings.HasPrefix(eth.URI, "http") {
137+
if parsedURL, err := url.Parse(eth.URI); err == nil {
138+
systems[i].EthernetInterfaces[j].URI = parsedURL.Path
139+
}
140+
}
141+
}
142+
}
143+
124144
// get BMC username to send
125145
bmcCreds := bmc.GetBMCCredentialsOrDefault(params.SecretStore, config.URI)
126146
if bmcCreds == (bmc.BMCCredentials{}) {

0 commit comments

Comments
 (0)