Fix: Ensure all SSL Certs records are checked
- Addressing the issue where only a limited number (30) were being processed due to pagination. The fixed now fetches all records to ensure comprehensive SSL monitoring.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
package pocketbase
|
||||
|
||||
import (
|
||||
@@ -19,7 +18,15 @@ type SSLCertificatesResponse struct {
|
||||
}
|
||||
|
||||
func (c *PocketBaseClient) GetSSLCertificates() ([]types.SSLCertificate, error) {
|
||||
url := fmt.Sprintf("%s/api/collections/ssl_certificates/records", c.baseURL)
|
||||
var allCertificates []types.SSLCertificate
|
||||
page := 1
|
||||
perPage := 200 // You can increase up to 500 if needed
|
||||
|
||||
for {
|
||||
url := fmt.Sprintf(
|
||||
"%s/api/collections/ssl_certificates/records?page=%d&perPage=%d",
|
||||
c.baseURL, page, perPage,
|
||||
)
|
||||
|
||||
resp, err := c.httpClient.Get(url)
|
||||
if err != nil {
|
||||
@@ -36,7 +43,15 @@ func (c *PocketBaseClient) GetSSLCertificates() ([]types.SSLCertificate, error)
|
||||
return nil, fmt.Errorf("failed to decode SSL certificates response: %v", err)
|
||||
}
|
||||
|
||||
return response.Items, nil
|
||||
allCertificates = append(allCertificates, response.Items...)
|
||||
|
||||
if page >= response.TotalPages || len(response.Items) == 0 {
|
||||
break
|
||||
}
|
||||
page++
|
||||
}
|
||||
|
||||
return allCertificates, nil
|
||||
}
|
||||
|
||||
func (c *PocketBaseClient) UpdateSSLCertificate(id string, data map[string]interface{}) error {
|
||||
|
||||
Reference in New Issue
Block a user