@@ -248,13 +248,7 @@ func Create(ctx context.Context, client *containerd.Client, args []string, netMa
248
248
envs = append (envs , "HOSTNAME=" + netLabelOpts .Hostname )
249
249
opts = append (opts , oci .WithEnv (envs ))
250
250
251
- // TODO(aznashwan): more formal way to load net opts into internalLabels:
252
- internalLabels .hostname = netLabelOpts .Hostname
253
- internalLabels .ports = netLabelOpts .PortMappings
254
- internalLabels .ipAddress = netLabelOpts .IPAddress
255
- internalLabels .ip6Address = netLabelOpts .IP6Address
256
- internalLabels .networks = netLabelOpts .NetworkSlice
257
- internalLabels .macAddress = netLabelOpts .MACAddress
251
+ internalLabels .loadNetOpts (netLabelOpts )
258
252
259
253
// NOTE: OCI hooks are currently not supported on Windows so we skip setting them altogether.
260
254
// The OCI hooks we define (whose logic can be found in pkg/ocihook) primarily
@@ -732,6 +726,16 @@ func withInternalLabels(internalLabels internalLabels) (containerd.NewContainerO
732
726
return containerd .WithAdditionalContainerLabels (m ), nil
733
727
}
734
728
729
+ // loadNetOpts loads network options into InternalLabels.
730
+ func (il * internalLabels ) loadNetOpts (opts types.NetworkOptions ) {
731
+ il .hostname = opts .Hostname
732
+ il .ports = opts .PortMappings
733
+ il .ipAddress = opts .IPAddress
734
+ il .ip6Address = opts .IP6Address
735
+ il .networks = opts .NetworkSlice
736
+ il .macAddress = opts .MACAddress
737
+ }
738
+
735
739
func dockercompatMounts (mountPoints []* mountutil.Processed ) []dockercompat.MountPoint {
736
740
result := make ([]dockercompat.MountPoint , len (mountPoints ))
737
741
for i := range mountPoints {
0 commit comments