Skip to content

Commit

Permalink
add sample test
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Tingajkin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed Oct 29, 2020
1 parent 930a397 commit 9bbbe23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package k8s

import (
"context"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -73,7 +74,7 @@ func ApplyDeployment(path string, mutators ...func(deployment *v1.Deployment)) e
for _, m := range mutators {
m(&d)
}
_, err = client.AppsV1().Deployments(namespace).Create(&d)
_, err = client.AppsV1().Deployments(namespace).Create(context.Background(), &d, metav1.CreateOptions{})
return err
}

Expand All @@ -86,7 +87,7 @@ func ShowLogs(options ...*exechelper.Option) {
return
}

pods, err := client.CoreV1().Pods(namespace).List(metav1.ListOptions{})
pods, err := client.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{})

if err != nil {
logrus.Errorf("Cannot get pods: %v", err.Error())
Expand Down
3 changes: 2 additions & 1 deletion k8s/require/require.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package require

import (
"context"
"fmt"
"testing"

Expand All @@ -31,7 +32,7 @@ import (
func NoRestarts(t *testing.T) {
c, err := k8s.Client()
require.NoError(t, err)
list, err := c.CoreV1().Pods("default").List(metav1.ListOptions{})
list, err := c.CoreV1().Pods("default").List(context.Background(), metav1.ListOptions{})
require.NoError(t, err)
for i := 0; i < len(list.Items); i++ {
pod := &list.Items[i]
Expand Down
4 changes: 3 additions & 1 deletion spire/spire.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package spire

import (
"context"

"github.com/edwarnicke/exechelper"
"github.com/pkg/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -30,7 +32,7 @@ func exist() bool {
if err != nil {
return false
}
_, err = client.CoreV1().Namespaces().Get("spire", v1.GetOptions{})
_, err = client.CoreV1().Namespaces().Get(context.Background(), "spire", v1.GetOptions{})
return err == nil
}

Expand Down

0 comments on commit 9bbbe23

Please sign in to comment.