Skip to content

Commit

Permalink
Renamed struct
Browse files Browse the repository at this point in the history
  • Loading branch information
davidallendj committed Aug 9, 2024
1 parent fc6afc8 commit 7beb7a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions internal/cache/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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),
Expand Down
14 changes: 7 additions & 7 deletions internal/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit 7beb7a3

Please sign in to comment.