Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
  • Loading branch information
fahedouch committed Oct 26, 2023
1 parent 6c67a1f commit 36e1772
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/netutil/netutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (e *CNIEnv) generateNetworkConfig(name string, labels []string, plugins []C
return nil, fmt.Errorf("needs CNI plugin %q to be installed in CNI_PATH (%q), see https://github.com/containernetworking/plugins/releases: %w", f.GetPluginType(), e.Path, err)
}
}
id := NetworkID(name)
id := networkID(name)
labelsMap := strutil.ConvertKVStringsToMap(labels)

conf := &cniNetworkConfig{
Expand Down Expand Up @@ -460,7 +460,7 @@ func nerdctlIDLabels(b []byte) (*string, *map[string]string) {
return idl.ID, idl.Labels
}

func NetworkID(name string) string {
func networkID(name string) string {
hash := sha256.Sum256([]byte(name))
return hex.EncodeToString(hash[:])
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/netutil/netutil_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (e *CNIEnv) generateCNIPlugins(driver string, name string, ipam map[string]
if name == DefaultNetworkName {
bridge = newBridgePlugin("nerdctl0")
} else {
bridge = newBridgePlugin("br-" + NetworkID(name)[:12])
bridge = newBridgePlugin("br-" + networkID(name)[:12])
}
bridge.MTU = mtu
bridge.IPAM = ipam
Expand Down

0 comments on commit 36e1772

Please sign in to comment.