mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Renamed struct
This commit is contained in:
parent
fc6afc8559
commit
7beb7a33fc
3 changed files with 13 additions and 13 deletions
8
internal/cache/sqlite/sqlite.go
vendored
8
internal/cache/sqlite/sqlite.go
vendored
|
|
@ -31,7 +31,7 @@ func CreateScannedAssetIfNotExists(path string) (*sqlx.DB, error) {
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertScannedAssets(path string, assets ...magellan.ScannedAsset) error {
|
func InsertScannedAssets(path string, assets ...magellan.RemoteAsset) error {
|
||||||
if assets == nil {
|
if assets == nil {
|
||||||
return fmt.Errorf("states == nil")
|
return fmt.Errorf("states == nil")
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ func InsertScannedAssets(path string, assets ...magellan.ScannedAsset) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteScannedAssets(path string, results ...magellan.ScannedAsset) error {
|
func DeleteScannedAssets(path string, results ...magellan.RemoteAsset) error {
|
||||||
if results == nil {
|
if results == nil {
|
||||||
return fmt.Errorf("no assets found")
|
return fmt.Errorf("no assets found")
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,7 @@ func DeleteScannedAssets(path string, results ...magellan.ScannedAsset) error {
|
||||||
return nil
|
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
|
// check if path exists first to prevent creating the database
|
||||||
exists, err := util.PathExists(path)
|
exists, err := util.PathExists(path)
|
||||||
if !exists {
|
if !exists {
|
||||||
|
|
@ -98,7 +98,7 @@ func GetScannedAssets(path string) ([]magellan.ScannedAsset, error) {
|
||||||
return nil, fmt.Errorf("failed to open database: %v", err)
|
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))
|
err = db.Select(&results, fmt.Sprintf("SELECT * FROM %s ORDER BY host ASC, port ASC;", TABLE_NAME))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to retrieve assets: %v", err)
|
return nil, fmt.Errorf("failed to retrieve assets: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ type CollectParams struct {
|
||||||
//
|
//
|
||||||
// Requests can be made to several of the nodes using a goroutine by setting the q.Concurrency
|
// Requests can be made to several of the nodes using a goroutine by setting the q.Concurrency
|
||||||
// property value between 1 and 255.
|
// 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
|
// check for available probe states
|
||||||
if scannedResults == nil {
|
if scannedResults == nil {
|
||||||
return fmt.Errorf("no probe states found")
|
return fmt.Errorf("no probe states found")
|
||||||
|
|
@ -63,7 +63,7 @@ func CollectInventory(scannedResults *[]ScannedAsset, params *CollectParams) err
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
found = make([]string, 0, len(*scannedResults))
|
found = make([]string, 0, len(*scannedResults))
|
||||||
done = make(chan struct{}, params.Concurrency+1)
|
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)
|
outputPath = path.Clean(params.OutputPath)
|
||||||
smdClient = client.NewClient[client.SmdClient](
|
smdClient = client.NewClient[client.SmdClient](
|
||||||
client.WithSecureTLS[client.SmdClient](params.CaCertPath),
|
client.WithSecureTLS[client.SmdClient](params.CaCertPath),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScannedAsset struct {
|
type RemoteAsset struct {
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
|
|
@ -49,9 +49,9 @@ type ScanParams struct {
|
||||||
// remove the service from being stored in the list of scanned results.
|
// 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).
|
// 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 (
|
var (
|
||||||
results = make([]ScannedAsset, 0, len(params.TargetHosts))
|
results = make([]RemoteAsset, 0, len(params.TargetHosts))
|
||||||
done = make(chan struct{}, params.Concurrency+1)
|
done = make(chan struct{}, params.Concurrency+1)
|
||||||
chanHosts = make(chan []string, params.Concurrency+1)
|
chanHosts = make(chan []string, params.Concurrency+1)
|
||||||
)
|
)
|
||||||
|
|
@ -81,7 +81,7 @@ func ScanForAssets(params *ScanParams) []ScannedAsset {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !params.DisableProbing {
|
if !params.DisableProbing {
|
||||||
assetsToAdd := []ScannedAsset{}
|
assetsToAdd := []RemoteAsset{}
|
||||||
for _, foundAsset := range foundAssets {
|
for _, foundAsset := range foundAssets {
|
||||||
url := fmt.Sprintf("%s://%s/redfish/v1/", params.Scheme, foundAsset.Host)
|
url := fmt.Sprintf("%s://%s/redfish/v1/", params.Scheme, foundAsset.Host)
|
||||||
res, _, err := util.MakeRequest(nil, url, http.MethodGet, nil, nil)
|
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
|
// 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
|
// function expects a full URL such as https://my.bmc.host:443/ to make the
|
||||||
// connection.
|
// 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)
|
uri, err := url.ParseRequestURI(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to split host/port: %w", err)
|
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 (
|
var (
|
||||||
timeoutDuration = time.Second * time.Duration(timeoutSeconds)
|
timeoutDuration = time.Second * time.Duration(timeoutSeconds)
|
||||||
assets []ScannedAsset
|
assets []RemoteAsset
|
||||||
asset = ScannedAsset{
|
asset = RemoteAsset{
|
||||||
Host: uri.Hostname(),
|
Host: uri.Hostname(),
|
||||||
Port: port,
|
Port: port,
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue