Renamed struct

This commit is contained in:
David Allen 2024-08-09 17:39:14 -06:00
parent fc6afc8559
commit 7beb7a33fc
Signed by: towk
GPG key ID: 793B2924A49B3A3F
3 changed files with 13 additions and 13 deletions

View file

@ -31,7 +31,7 @@ func CreateScannedAssetIfNotExists(path string) (*sqlx.DB, error) {
return db, nil
}
func InsertScannedAssets(path string, assets ...magellan.ScannedAsset) error {
func InsertScannedAssets(path string, assets ...magellan.RemoteAsset) error {
if assets == nil {
return fmt.Errorf("states == nil")
}
@ -59,7 +59,7 @@ func InsertScannedAssets(path string, assets ...magellan.ScannedAsset) error {
return nil
}
func DeleteScannedAssets(path string, results ...magellan.ScannedAsset) error {
func DeleteScannedAssets(path string, results ...magellan.RemoteAsset) error {
if results == nil {
return fmt.Errorf("no assets found")
}
@ -83,7 +83,7 @@ func DeleteScannedAssets(path string, results ...magellan.ScannedAsset) error {
return nil
}
func GetScannedAssets(path string) ([]magellan.ScannedAsset, error) {
func GetScannedAssets(path string) ([]magellan.RemoteAsset, error) {
// check if path exists first to prevent creating the database
exists, err := util.PathExists(path)
if !exists {
@ -98,7 +98,7 @@ func GetScannedAssets(path string) ([]magellan.ScannedAsset, error) {
return nil, fmt.Errorf("failed to open database: %v", err)
}
results := []magellan.ScannedAsset{}
results := []magellan.RemoteAsset{}
err = db.Select(&results, fmt.Sprintf("SELECT * FROM %s ORDER BY host ASC, port ASC;", TABLE_NAME))
if err != nil {
return nil, fmt.Errorf("failed to retrieve assets: %v", err)

View file

@ -48,7 +48,7 @@ type CollectParams struct {
//
// Requests can be made to several of the nodes using a goroutine by setting the q.Concurrency
// property value between 1 and 255.
func CollectInventory(scannedResults *[]ScannedAsset, params *CollectParams) error {
func CollectInventory(scannedResults *[]RemoteAsset, params *CollectParams) error {
// check for available probe states
if scannedResults == nil {
return fmt.Errorf("no probe states found")
@ -63,7 +63,7 @@ func CollectInventory(scannedResults *[]ScannedAsset, params *CollectParams) err
wg sync.WaitGroup
found = make([]string, 0, len(*scannedResults))
done = make(chan struct{}, params.Concurrency+1)
chanScannedResult = make(chan ScannedAsset, params.Concurrency+1)
chanScannedResult = make(chan RemoteAsset, params.Concurrency+1)
outputPath = path.Clean(params.OutputPath)
smdClient = client.NewClient[client.SmdClient](
client.WithSecureTLS[client.SmdClient](params.CaCertPath),

View file

@ -14,7 +14,7 @@ import (
"github.com/rs/zerolog/log"
)
type ScannedAsset struct {
type RemoteAsset struct {
Host string `json:"host"`
Port int `json:"port"`
Protocol string `json:"protocol"`
@ -49,9 +49,9 @@ type ScanParams struct {
// remove the service from being stored in the list of scanned results.
//
// Returns a list of scanned results to be stored in cache (but isn't doing here).
func ScanForAssets(params *ScanParams) []ScannedAsset {
func ScanForAssets(params *ScanParams) []RemoteAsset {
var (
results = make([]ScannedAsset, 0, len(params.TargetHosts))
results = make([]RemoteAsset, 0, len(params.TargetHosts))
done = make(chan struct{}, params.Concurrency+1)
chanHosts = make(chan []string, params.Concurrency+1)
)
@ -81,7 +81,7 @@ func ScanForAssets(params *ScanParams) []ScannedAsset {
return
}
if !params.DisableProbing {
assetsToAdd := []ScannedAsset{}
assetsToAdd := []RemoteAsset{}
for _, foundAsset := range foundAssets {
url := fmt.Sprintf("%s://%s/redfish/v1/", params.Scheme, foundAsset.Host)
res, _, err := util.MakeRequest(nil, url, http.MethodGet, nil, nil)
@ -177,7 +177,7 @@ func GetDefaultPorts() []int {
// until a response is receive or if the timeout (in seconds) expires. This
// function expects a full URL such as https://my.bmc.host:443/ to make the
// connection.
func rawConnect(address string, protocol string, timeoutSeconds int, keepOpenOnly bool) ([]ScannedAsset, error) {
func rawConnect(address string, protocol string, timeoutSeconds int, keepOpenOnly bool) ([]RemoteAsset, error) {
uri, err := url.ParseRequestURI(address)
if err != nil {
return nil, fmt.Errorf("failed to split host/port: %w", err)
@ -191,8 +191,8 @@ func rawConnect(address string, protocol string, timeoutSeconds int, keepOpenOnl
var (
timeoutDuration = time.Second * time.Duration(timeoutSeconds)
assets []ScannedAsset
asset = ScannedAsset{
assets []RemoteAsset
asset = RemoteAsset{
Host: uri.Hostname(),
Port: port,
Protocol: protocol,