toObservedContainer extracts the relevant fields from a container.Summary, parsing labels into typed values.
(c container.Summary)
| 161 | // toObservedContainer extracts the relevant fields from a container.Summary, |
| 162 | // parsing labels into typed values. |
| 163 | func toObservedContainer(c container.Summary) ObservedContainer { |
| 164 | number, _ := strconv.Atoi(c.Labels[api.ContainerNumberLabel]) |
| 165 | |
| 166 | networks := map[string]string{} |
| 167 | if c.NetworkSettings != nil { |
| 168 | for name, settings := range c.NetworkSettings.Networks { |
| 169 | networks[name] = settings.NetworkID |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | return ObservedContainer{ |
| 174 | ID: c.ID, |
| 175 | Name: getCanonicalContainerName(c), |
| 176 | State: c.State, |
| 177 | ConfigHash: c.Labels[api.ConfigHashLabel], |
| 178 | ImageDigest: c.Labels[api.ImageDigestLabel], |
| 179 | Number: number, |
| 180 | ConnectedNetworks: networks, |
| 181 | Summary: c, |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | // setResolvedNetworks injects network IDs already resolved by ensureNetworks |
| 186 | // into the observed state, so the reconciler can compare container connections |