mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-17 23:11:18 +00:00
Update source for k8s bump to v0.18.3
Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# This dockerfile is specific to building Multus for OpenShift
|
||||
FROM openshift/origin-release:golang-1.10 as builder
|
||||
FROM openshift/origin-release:golang-1.15 as builder
|
||||
|
||||
ADD . /usr/src/multus-cni
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
package k8sclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -66,22 +67,22 @@ type ClientInfo struct {
|
||||
|
||||
// AddPod adds pod into kubernetes
|
||||
func (c *ClientInfo) AddPod(pod *v1.Pod) (*v1.Pod, error) {
|
||||
return c.Client.Core().Pods(pod.ObjectMeta.Namespace).Create(pod)
|
||||
return c.Client.CoreV1().Pods(pod.ObjectMeta.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
// GetPod gets pod from kubernetes
|
||||
func (c *ClientInfo) GetPod(namespace, name string) (*v1.Pod, error) {
|
||||
return c.Client.Core().Pods(namespace).Get(name, metav1.GetOptions{})
|
||||
return c.Client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
// DeletePod deletes a pod from kubernetes
|
||||
func (c *ClientInfo) DeletePod(namespace, name string) error {
|
||||
return c.Client.Core().Pods(namespace).Delete(name, &metav1.DeleteOptions{})
|
||||
return c.Client.CoreV1().Pods(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
// AddNetAttachDef adds net-attach-def into kubernetes
|
||||
func (c *ClientInfo) AddNetAttachDef(netattach *nettypes.NetworkAttachmentDefinition) (*nettypes.NetworkAttachmentDefinition, error) {
|
||||
return c.NetClient.NetworkAttachmentDefinitions(netattach.ObjectMeta.Namespace).Create(netattach)
|
||||
return c.NetClient.NetworkAttachmentDefinitions(netattach.ObjectMeta.Namespace).Create(context.TODO(), netattach, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
// Eventf puts event into kubernetes events
|
||||
@@ -241,7 +242,7 @@ func parsePodNetworkAnnotation(podNetworks, defaultNamespace string) ([]*types.N
|
||||
func getKubernetesDelegate(client *ClientInfo, net *types.NetworkSelectionElement, confdir string, pod *v1.Pod, resourceMap map[string]*types.ResourceInfo) (*types.DelegateNetConf, map[string]*types.ResourceInfo, error) {
|
||||
|
||||
logging.Debugf("getKubernetesDelegate: %v, %v, %s, %v, %v", client, net, confdir, pod, resourceMap)
|
||||
customResource, err := client.NetClient.NetworkAttachmentDefinitions(net.Namespace).Get(net.Name, metav1.GetOptions{})
|
||||
customResource, err := client.NetClient.NetworkAttachmentDefinitions(net.Namespace).Get(context.TODO(), net.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
errMsg := fmt.Sprintf("cannot find a network-attachment-definition (%s) in namespace (%s): %v", net.Name, net.Namespace, err)
|
||||
if client != nil {
|
||||
|
@@ -1395,7 +1395,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
|
||||
}, nil)
|
||||
|
||||
clientInfo := NewFakeClientInfo()
|
||||
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
|
||||
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
|
||||
context.TODO(), fakePod, metav1.CreateOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = clientInfo.AddNetAttachDef(
|
||||
@@ -1473,7 +1474,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
|
||||
}, nil)
|
||||
|
||||
clientInfo := NewFakeClientInfo()
|
||||
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
|
||||
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
|
||||
context.TODO(), fakePod, metav1.CreateOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = clientInfo.AddNetAttachDef(
|
||||
@@ -1549,7 +1551,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
|
||||
}, nil)
|
||||
|
||||
clientInfo := NewFakeClientInfo()
|
||||
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
|
||||
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
|
||||
context.TODO(), fakePod, metav1.CreateOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = clientInfo.AddNetAttachDef(
|
||||
@@ -1570,8 +1573,8 @@ var _ = Describe("multus operations cniVersion 0.2.0 config", func() {
|
||||
|
||||
// delete pod to emulate no pod info
|
||||
clientInfo.DeletePod(fakePod.ObjectMeta.Namespace, fakePod.ObjectMeta.Name)
|
||||
nilPod, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Get(
|
||||
fakePod.ObjectMeta.Name, metav1.GetOptions{})
|
||||
nilPod, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Get(
|
||||
context.TODO(), fakePod.ObjectMeta.Name, metav1.GetOptions{})
|
||||
Expect(nilPod).To(BeNil())
|
||||
Expect(errors.IsNotFound(err)).To(BeTrue())
|
||||
|
||||
@@ -2641,7 +2644,8 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
|
||||
}, nil)
|
||||
|
||||
clientInfo := NewFakeClientInfo()
|
||||
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
|
||||
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
|
||||
context.TODO(), fakePod, metav1.CreateOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = clientInfo.AddNetAttachDef(
|
||||
@@ -2723,7 +2727,8 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
|
||||
}, nil)
|
||||
|
||||
clientInfo := NewFakeClientInfo()
|
||||
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
|
||||
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
|
||||
context.TODO(), fakePod, metav1.CreateOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = clientInfo.AddNetAttachDef(
|
||||
@@ -2793,7 +2798,8 @@ var _ = Describe("multus operations cniVersion 0.4.0 config", func() {
|
||||
}, nil)
|
||||
|
||||
clientInfo := NewFakeClientInfo()
|
||||
_, err := clientInfo.Client.Core().Pods(fakePod.ObjectMeta.Namespace).Create(fakePod)
|
||||
_, err := clientInfo.Client.CoreV1().Pods(fakePod.ObjectMeta.Namespace).Create(
|
||||
context.TODO(), fakePod, metav1.CreateOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = clientInfo.AddNetAttachDef(
|
||||
|
Reference in New Issue
Block a user