44 "context"
55 "fmt"
66 "os"
7+ "strings"
78 "sync"
89 "time"
910
@@ -103,6 +104,8 @@ func (d *Integration) Collect(ctx context.Context) (*models.IntegrationData, err
103104 dockerData := & models.DockerData {
104105 Containers : make ([]models.DockerContainer , 0 ),
105106 Images : make ([]models.DockerImage , 0 ),
107+ Volumes : make ([]models.DockerVolume , 0 ),
108+ Networks : make ([]models.DockerNetwork , 0 ),
106109 Updates : make ([]models.DockerImageUpdate , 0 ),
107110 }
108111
@@ -124,6 +127,24 @@ func (d *Integration) Collect(ctx context.Context) (*models.IntegrationData, err
124127 d .logger .WithField ("count" , len (images )).Info ("Collected images" )
125128 }
126129
130+ // Collect volumes
131+ volumes , err := d .collectVolumes (ctx )
132+ if err != nil {
133+ d .logger .WithError (err ).Warn ("Failed to collect volumes" )
134+ } else {
135+ dockerData .Volumes = volumes
136+ d .logger .WithField ("count" , len (volumes )).Info ("Collected volumes" )
137+ }
138+
139+ // Collect networks
140+ networks , err := d .collectNetworks (ctx )
141+ if err != nil {
142+ d .logger .WithError (err ).Warn ("Failed to collect networks" )
143+ } else {
144+ dockerData .Networks = networks
145+ d .logger .WithField ("count" , len (networks )).Info ("Collected networks" )
146+ }
147+
127148 // Collect daemon info
128149 daemonInfo , err := d .collectDaemonInfo (ctx )
129150 if err != nil {
@@ -213,32 +234,47 @@ func determineImageSource(imageName string) string {
213234 return "unknown"
214235 }
215236
216- // Check for common registries
217- if len (imageName ) > 9 && imageName [:9 ] == "ghcr.io/" {
218- return "github"
237+ // Extract domain from image name
238+ parts := strings .SplitN (imageName , "/" , 2 )
239+ if len (parts ) == 1 {
240+ // No domain specified, it's Docker Hub (implicit docker.io)
241+ return "docker-hub"
219242 }
220- if len (imageName ) > 20 && imageName [:20 ] == "registry.gitlab.com/" {
221- return "gitlab"
243+
244+ domain := parts [0 ]
245+
246+ // Check if first part contains a dot or colon (indicates it's a domain)
247+ if ! strings .Contains (domain , "." ) && ! strings .Contains (domain , ":" ) {
248+ // It's a Docker Hub image with org/repo format (e.g., "library/nginx")
249+ return "docker-hub"
222250 }
223- if len (imageName ) > 4 && imageName [:4 ] == "gcr." {
251+
252+ // Match known registry domains (inspired by diun)
253+ switch {
254+ case domain == "docker.io" :
255+ return "docker-hub"
256+ case domain == "ghcr.io" :
257+ return "github"
258+ case domain == "docker.pkg.github.com" :
259+ return "github"
260+ case domain == "registry.gitlab.com" :
261+ return "gitlab"
262+ case strings .HasPrefix (domain , "gcr.io" ):
224263 return "google"
225- }
226- if len (imageName ) > 4 && imageName [:4 ] == "quay" {
264+ case strings .Contains (domain , "pkg.dev" ): // Google Artifact Registry
265+ return "google"
266+ case domain == "quay.io" :
227267 return "quay"
228- }
229-
230- // Count slashes to determine if it's a private registry
231- slashCount := 0
232- for _ , ch := range imageName {
233- if ch == '/' {
234- slashCount ++
235- }
236- }
237- if slashCount >= 2 {
268+ case domain == "registry.access.redhat.com" :
269+ return "redhat"
270+ case strings .Contains (domain , "azurecr.io" ):
271+ return "azure"
272+ case strings .Contains (domain , "amazonaws.com" ): // ECR
273+ return "aws"
274+ default :
275+ // Private registry
238276 return "private"
239277 }
240-
241- return "docker-hub"
242278}
243279
244280// parseImageName parses image name into repository and tag
0 commit comments