Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #43 from jschwinger233/zc/cni
Browse files Browse the repository at this point in the history
enable cni for custom network by config
  • Loading branch information
nyanpassu authored Nov 29, 2021
2 parents c6e5347 + dbc0761 commit 074f5fe
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 21 deletions.
5 changes: 2 additions & 3 deletions barrel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"os"
"path"
"strings"
"time"

Expand Down Expand Up @@ -101,8 +100,8 @@ func main() {
}

var app *cli.App
switch path.Base(os.Args[0]) {
case "barrel-cni":
switch {
case strings.HasSuffix(os.Args[0], "barrel-cni"):
store, err := filesystem.NewStore("/var/lib/barrel/cni")
if err != nil {
log.Fatalf("failed to new store: %+v", err)
Expand Down
5 changes: 5 additions & 0 deletions cni/subhandler/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func NewBase(conf config.Config, store store.Store) *Base {
}
}

// Enabled .
func (h *Base) Enabled() bool {
return h.conf != config.Config{}
}

// BorrowNetEndpoint will snatch the nep
func (h *Base) BorrowNetEndpoint(containerMeta *cni.ContainerMeta, nep *cni.NetEndpoint) (err error) {
if err = h.store.OccupyNetEndpoint(containerMeta.ID(), nep); err != nil {
Expand Down
Loading

0 comments on commit 074f5fe

Please sign in to comment.