ipam/host-local: Move allocator and config to backend

Signed-off-by: André Martins <aanm90@gmail.com>
This commit is contained in:
André Martins
2016-02-06 21:52:27 +00:00
parent 98ff61aac3
commit f60111b093
6 changed files with 13 additions and 12 deletions

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package allocator
import (
"fmt"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main_test
package allocator_test
import (
. "github.com/onsi/ginkgo"
@ -21,7 +21,7 @@ import (
"testing"
)
func TestHostLocal(t *testing.T) {
func TestAllocator(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "HostLocal Suite")
RunSpecs(t, "Allocator Suite")
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package allocator
import (
"fmt"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package allocator
import (
"encoding/json"

View File

@ -15,6 +15,7 @@
package main
import (
"github.com/containernetworking/cni/plugins/ipam/host-local/backend/allocator"
"github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk"
"github.com/containernetworking/cni/pkg/skel"
@ -27,7 +28,7 @@ func main() {
}
func cmdAdd(args *skel.CmdArgs) error {
ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args)
ipamConf, err := allocator.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
return err
}
@ -38,7 +39,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}
defer store.Close()
allocator, err := NewIPAllocator(ipamConf, store)
allocator, err := allocator.NewIPAllocator(ipamConf, store)
if err != nil {
return err
}
@ -55,7 +56,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}
func cmdDel(args *skel.CmdArgs) error {
ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args)
ipamConf, err := allocator.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
return err
}
@ -66,10 +67,10 @@ func cmdDel(args *skel.CmdArgs) error {
}
defer store.Close()
allocator, err := NewIPAllocator(ipamConf, store)
ipAllocator, err := allocator.NewIPAllocator(ipamConf, store)
if err != nil {
return err
}
return allocator.Release(args.ContainerID)
return ipAllocator.Release(args.ContainerID)
}