aboutsummaryrefslogtreecommitdiffstats
path: root/internal/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkg/config/config.go')
-rw-r--r--internal/pkg/config/config.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index 002ad80..e9ad3e1 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -1,6 +1,7 @@
package config
import (
+ "encoding/json"
"fmt"
"os"
"path/filepath"
@@ -8,6 +9,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
+ "github.com/containernetworking/cni/pkg/types"
+ "github.com/containernetworking/cni/pkg/version"
gcfg "gopkg.in/gcfg.v1"
"k8s.io/client-go/kubernetes"
@@ -283,3 +286,17 @@ func NewClientset(conf *KubernetesConfig) (*kubernetes.Clientset, error) {
return kubernetes.NewForConfig(kconfig)
}
+
+func ConfigureNetConf(bytes []byte) (*types.NetConf, error) {
+ conf := &types.NetConf{}
+ if err := json.Unmarshal(bytes, conf); err != nil {
+ return nil, fmt.Errorf("failed to load netconf: %v", err)
+ }
+
+ if conf.RawPrevResult != nil {
+ if err := version.ParsePrevResult(conf); err != nil {
+ return nil, err
+ }
+ }
+ return conf, nil
+}