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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package allocator
import ( import (
"fmt" "fmt"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main_test package allocator_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -21,7 +21,7 @@ import (
"testing" "testing"
) )
func TestHostLocal(t *testing.T) { func TestAllocator(t *testing.T) {
RegisterFailHandler(Fail) 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package allocator
import ( import (
"fmt" "fmt"

View File

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

View File

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

2
test
View File

@ -11,7 +11,7 @@ set -e
source ./build source ./build
TESTABLE="libcni plugins/ipam/dhcp plugins/ipam/host-local plugins/main/loopback pkg/invoke pkg/ns pkg/skel pkg/types pkg/utils plugins/main/ipvlan plugins/main/macvlan plugins/main/bridge plugins/main/ptp plugins/test/noop pkg/utils/hwaddr pkg/ip pkg/version pkg/version/testhelpers plugins/meta/flannel" TESTABLE="libcni plugins/ipam/dhcp plugins/ipam/dhcp plugins/ipam/host-local/backend/allocator plugins/ipam/host-local/backend plugins/main/loopback pkg/invoke pkg/ns pkg/skel pkg/types pkg/utils plugins/main/ipvlan plugins/main/macvlan plugins/main/bridge plugins/main/ptp plugins/test/noop pkg/utils/hwaddr pkg/ip pkg/version pkg/version/testhelpers plugins/meta/flannel"
FORMATTABLE="$TESTABLE pkg/testutils plugins/meta/flannel plugins/meta/tuning" FORMATTABLE="$TESTABLE pkg/testutils plugins/meta/flannel plugins/meta/tuning"
# user has not provided PKG override # user has not provided PKG override