Переглянути джерело

Improve error message to include expected network label

Updated the error message when a network is found with an incorrect label to also display the expected label value. This provides more context for debugging.

Signed-off-by: divinity76 <[email protected]>
divinity76 1 рік тому
батько
коміт
0cbb73c024
1 змінених файлів з 7 додано та 1 видалено
  1. 7 1
      pkg/compose/create.go

+ 7 - 1
pkg/compose/create.go

@@ -1208,7 +1208,13 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, n *types.Ne
 					"Set `external: true` to use an existing network", n.Name, expectedProjectLabel)
 			}
 			if inspect.Labels[api.NetworkLabel] != expectedNetworkLabel {
-				return fmt.Errorf("network %s was found but has incorrect label %s set to %q", n.Name, api.NetworkLabel, inspect.Labels[api.NetworkLabel])
+				return fmt.Errorf(
+					"network %s was found but has incorrect label %s set to %q (expected: %q)",
+					n.Name,
+					api.NetworkLabel,
+					inspect.Labels[api.NetworkLabel],
+					expectedNetworkLabel,
+				)
 			}
 			return nil
 		}