func LoadDBConfig() (*ipstore.Config, error) {
	dbConf := &ipstore.Config{PersistConnection: true}
	db := os.Getenv(EnvDBPath)
	if len(strings.TrimSpace(db)) == 0 {
		db = DefaultDBPath
	}
	dbConf.DB = db
	dbConf.Bucket = BucketName
	dbTimeoutStr := os.Getenv(EnvIpamTimeout)
	if len(strings.TrimSpace(dbTimeoutStr)) == 0 {
		dbConf.ConnectionTimeout = DefaultConnectionTimeout
	} else {
		duration, err := time.ParseDuration(dbTimeoutStr)
		if err != nil {
			return nil, errors.Errorf("loadDBConfig config: parsing timeout string failed: %v", duration)
		}
		dbConf.ConnectionTimeout = duration
	}
	return dbConf, nil
}
LoadDBConfig will read the configuration of db from environment variable
package config
import (
	"encoding/json"
	"net"
	"os"
	"strings"
	"time"
	"github.com/aws/amazon-ecs-cni-plugins/plugins/ipam/ipstore"
	"github.com/containernetworking/cni/pkg/ip"
	"github.com/containernetworking/cni/pkg/types"
	"github.com/pkg/errors"
)
const (
	EnvDBPath                = "IPAM_DB_PATH"
	EnvIpamTimeout           = "IPAM_DB_CONNECTION_TIMEOUT"
	LastKnownIPKey           = "lastKnownIP"
	GatewayValue             = "GateWay"
	DefaultDBPath            = "/data/eni-ipam.db"
	BucketName               = "IPAM"
	DefaultConnectionTimeout = 5 * time.Second
)
type IPAMConfig struct {
	types.CommonArgs
	Type        string         `json:"type,omitempty"`
	IPV4Subnet  types.IPNet    `json:"ipv4-subnet,omitempty"`
	IPV4Address types.IPNet    `json:"ipv4-address,omitempty"`
	IPV4Gateway net.IP         `json:"ipv4-gateway,omitempty"`
	IPV4Routes  []*types.Route `json:"ipv4-routes,omitempty"`
	ID          string         `json:id,omitempty`
}
type Conf struct {
	Name       string      `json:"name,omitempty"`
	CNIVersion string      `json:"cniVersion,omitempty"`
	IPAM       *IPAMConfig `json:"ipam"`
}
func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, string, error) {
	ipamConf := &Conf{}
	if err := json.Unmarshal(bytes, &ipamConf); err != nil {
		return nil, "", errors.Wrapf(err, "loadIPAMConfig config: failed to load netconf, %s", string(bytes))
	}
	if ipamConf.IPAM == nil {
		return nil, "", errors.New("loadIPAMConfig config: 'IPAM' field missing in configuration: " + string(bytes))
	}
	if ipamConf.IPAM.IPV4Subnet.IP == nil || ipamConf.IPAM.IPV4Subnet.Mask == nil {
		return nil, "", errors.New("loadIPAMConfig config: subnet is required")
	}
	if ones, _ := ipamConf.IPAM.IPV4Subnet.Mask.Size(); ones > ipstore.MaxMask {
		return nil, "", errors.New("loadIPAMConfig config: no available ip in the subnet")
	}
	subnet := net.IPNet{
		IP:   ipamConf.IPAM.IPV4Subnet.IP,
		Mask: ipamConf.IPAM.IPV4Subnet.Mask,
	}
	if ipamConf.IPAM.IPV4Address.IP != nil {
		err := verifyIPSubnet(ipamConf.IPAM.IPV4Address.IP, subnet)
		if err != nil {
			return nil, "", err
		}
		if isNetworkOrBroadcast(subnet, ipamConf.IPAM.IPV4Address.IP) {
			return nil, "", errors.Errorf("ip specified is reserved by default: %v", ipamConf.IPAM.IPV4Address)
		}
	}
	if ipamConf.IPAM.IPV4Gateway == nil {
		ipamConf.IPAM.IPV4Gateway = getDefaultIPV4GW(ipamConf.IPAM.IPV4Subnet)
	} else {
		if isNetworkOrBroadcast(subnet, ipamConf.IPAM.IPV4Gateway) {
			return nil, "", errors.Errorf("gateway specified is reserved by default: %v", ipamConf.IPAM.IPV4Gateway)
		}
		if err := verifyIPSubnet(ipamConf.IPAM.IPV4Gateway, subnet); err != nil {
			return nil, "", err
		}
	}
	return ipamConf.IPAM, ipamConf.CNIVersion, nil
}