@@ -74,22 +74,22 @@ func (docker *Docker) DockerConnected() bool {
7474 return err == nil
7575}
7676
77- func (docker * Docker ) GetLabels (appId string ) (types.TinyauthLabels , error ) {
77+ func (docker * Docker ) GetLabels (appId string ) (types.Labels , error ) {
7878 // Check if we have access to the Docker API
7979 isConnected := docker .DockerConnected ()
8080
8181 // If we don't have access, return an empty struct
8282 if ! isConnected {
8383 log .Debug ().Msg ("Docker not connected, returning empty labels" )
84- return types.TinyauthLabels {}, nil
84+ return types.Labels {}, nil
8585 }
8686
8787 // Get the containers
8888 containers , err := docker .GetContainers ()
8989
9090 // If there is an error, return false
9191 if err != nil {
92- return types.TinyauthLabels {}, err
92+ return types.Labels {}, err
9393 }
9494
9595 log .Debug ().Msg ("Got containers" )
@@ -99,9 +99,10 @@ func (docker *Docker) GetLabels(appId string) (types.TinyauthLabels, error) {
9999 // Inspect the container
100100 inspect , err := docker .InspectContainer (container .ID )
101101
102- // If there is an error, return false
102+ // Check if there was an error
103103 if err != nil {
104- return types.TinyauthLabels {}, err
104+ log .Warn ().Str ("id" , container .ID ).Err (err ).Msg ("Error inspecting container, skipping" )
105+ continue
105106 }
106107
107108 // Get the container name (for some reason it is /name)
@@ -112,7 +113,13 @@ func (docker *Docker) GetLabels(appId string) (types.TinyauthLabels, error) {
112113 log .Debug ().Str ("container" , containerName ).Msg ("Found container" )
113114
114115 // Get only the tinyauth labels in a struct
115- labels := utils .GetTinyauthLabels (inspect .Config .Labels )
116+ labels , err := utils .GetLabels (inspect .Config .Labels )
117+
118+ // Check if there was an error
119+ if err != nil {
120+ log .Error ().Err (err ).Msg ("Error parsing labels" )
121+ return types.Labels {}, err
122+ }
116123
117124 log .Debug ().Msg ("Got labels" )
118125
@@ -125,5 +132,5 @@ func (docker *Docker) GetLabels(appId string) (types.TinyauthLabels, error) {
125132 log .Debug ().Msg ("No matching container found, returning empty labels" )
126133
127134 // If no matching container is found, return empty labels
128- return types.TinyauthLabels {}, nil
135+ return types.Labels {}, nil
129136}
0 commit comments