Browse Source

Merge pull request #555 from chenchun/fix_doc

Fix outdated docs and comments
Madhu Venugopal 9 năm trước cách đây
mục cha
commit
0c089712ec
2 tập tin đã thay đổi với 12 bổ sung12 xóa
  1. 2 2
      libnetwork/README.md
  2. 10 10
      libnetwork/controller.go

+ 2 - 2
libnetwork/README.md

@@ -45,13 +45,13 @@ There are many networking solutions available to suit a broad range of use-cases
 		return
 		return
 	}
 	}
 
 
-	// Create the sandbox for the containr.
+	// Create the sandbox for the container.
+	// NewSandbox accepts Variadic optional arguments which libnetwork can use.
 	sbx, err := controller.NewSandbox("container1",
 	sbx, err := controller.NewSandbox("container1",
 		libnetwork.OptionHostname("test"),
 		libnetwork.OptionHostname("test"),
 		libnetwork.OptionDomainname("docker.io"))
 		libnetwork.OptionDomainname("docker.io"))
 
 
 	// A sandbox can join the endpoint via the join api.
 	// A sandbox can join the endpoint via the join api.
-	// Join accepts Variadic arguments which libnetwork and Drivers can use.
 	err = ep.Join(sbx)
 	err = ep.Join(sbx)
 	if err != nil {
 	if err != nil {
 		return
 		return

+ 10 - 10
libnetwork/controller.go

@@ -2,16 +2,13 @@
 Package libnetwork provides the basic functionality and extension points to
 Package libnetwork provides the basic functionality and extension points to
 create network namespaces and allocate interfaces for containers to use.
 create network namespaces and allocate interfaces for containers to use.
 
 
-	// Create a new controller instance
-	controller, _err := libnetwork.New(nil)
-
-	// Select and configure the network driver
 	networkType := "bridge"
 	networkType := "bridge"
 
 
+	// Create a new controller instance
 	driverOptions := options.Generic{}
 	driverOptions := options.Generic{}
 	genericOption := make(map[string]interface{})
 	genericOption := make(map[string]interface{})
 	genericOption[netlabel.GenericData] = driverOptions
 	genericOption[netlabel.GenericData] = driverOptions
-	err := controller.ConfigureNetworkDriver(networkType, genericOption)
+	controller, err := libnetwork.New(config.OptionDriverConfig(networkType, genericOption))
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}
@@ -32,11 +29,14 @@ create network namespaces and allocate interfaces for containers to use.
 		return
 		return
 	}
 	}
 
 
-	// A container can join the endpoint by providing the container ID to the join api.
-	// Join accepts Variadic arguments which will be made use of by libnetwork and Drivers
-	err = ep.Join("container1",
-		libnetwork.JoinOptionHostname("test"),
-		libnetwork.JoinOptionDomainname("docker.io"))
+	// Create the sandbox for the container.
+	// NewSandbox accepts Variadic optional arguments which libnetwork can use.
+	sbx, err := controller.NewSandbox("container1",
+		libnetwork.OptionHostname("test"),
+		libnetwork.OptionDomainname("docker.io"))
+
+	// A sandbox can join the endpoint via the join api.
+	err = ep.Join(sbx)
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}