Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go and pkg deps #475

Merged
merged 5 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.16
- name: Install golint
run: |
go get -u golang.org/x/lint/golint
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Development image
FROM golang:1.13-alpine3.12 AS BUILD-ENV
FROM golang:1.16-alpine3.12 AS BUILD-ENV

ARG GOOS_VAL
ARG GOARCH_VAL
Expand Down
42 changes: 12 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,38 @@ module github.com/infracloudio/botkube
require (
github.com/Masterminds/squirrel v1.1.0 // indirect
github.com/aws/aws-sdk-go v1.32.12
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/bwmarrin/discordgo v0.20.3
github.com/docker/docker v1.13.1 // indirect
github.com/dyatlov/go-opengraph v0.0.0-20180429202543-816b6608b3c8 // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/fsnotify/fsnotify v1.4.7
github.com/go-gorp/gorp v2.0.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.4.9
github.com/go-ldap/ldap v3.0.3+incompatible // indirect
github.com/go-redis/redis v6.15.2+incompatible // indirect
github.com/gogo/protobuf v1.3.0 // indirect
github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/google/go-github/v27 v27.0.4
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gorilla/websocket v1.4.1 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/infracloudio/msbotbuilder-go v0.2.1
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/infracloudio/msbotbuilder-go v0.2.4
github.com/lib/pq v1.2.0 // indirect
github.com/mattermost/gorp v2.0.0+incompatible // indirect
github.com/mattermost/mattermost-server v5.11.1+incompatible
github.com/mattn/go-sqlite3 v1.11.0 // indirect
github.com/nicksnyder/go-i18n v1.10.1 // indirect
github.com/nlopes/slack v0.6.1-0.20191106133607-d06c2a2b3249
github.com/olivere/elastic v6.2.21+incompatible
github.com/onsi/ginkgo v1.10.2 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pelletier/go-toml v1.5.0 // indirect
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/client_golang v1.7.1
github.com/sha1sum/aws_signing_client v0.0.0-20200229211254-f7815c59d5c1
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.5.1
github.com/ziutek/mymysql v1.5.4 // indirect
go.uber.org/atomic v1.4.0 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.7.0
go.uber.org/multierr v1.2.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
google.golang.org/appengine v1.6.5 // indirect
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.17.0
k8s.io/kubectl v0.17.0
k8s.io/sample-controller v0.17.0
k8s.io/api v0.20.5
k8s.io/apimachinery v0.20.5
k8s.io/client-go v0.20.5
k8s.io/kubectl v0.20.5
k8s.io/sample-controller v0.20.5
)

go 1.13
go 1.16
622 changes: 441 additions & 181 deletions go.sum

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pkg/filterengine/filters/ingress_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package filters

import (
"context"
"fmt"
"reflect"

Expand Down Expand Up @@ -68,7 +69,7 @@ func (iv IngressValidator) Run(object interface{}, event *events.Event) {
if ns == "default" {
ns = ingNs
}
_, err := ValidServicePort(serviceName, ns, int32(servicePort))
_, err := ValidServicePort(context.Background(), serviceName, ns, int32(servicePort))
if err != nil {
event.Warnings = append(event.Warnings, fmt.Sprintf("Service '%s' used in ingress '%s' config does not exist or port '%v' not exposed", serviceName, ingressObj.Name, servicePort))
}
Expand All @@ -77,7 +78,7 @@ func (iv IngressValidator) Run(object interface{}, event *events.Event) {

// Check if tls secret exists
for _, tls := range ingressObj.Spec.TLS {
_, err := ValidSecret(tls.SecretName, ingNs)
_, err := ValidSecret(context.Background(), tls.SecretName, ingNs)
if err != nil {
event.Recommendations = append(event.Recommendations, fmt.Sprintf("TLS secret %s does not exist", tls.SecretName))
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/filterengine/filters/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package filters

import (
"context"
"fmt"
"strings"

Expand All @@ -42,8 +43,8 @@ var (
)

// ValidService returns Service object is service given service exists in the given namespace
func ValidService(name, namespace string) (*coreV1.Service, error) {
unstructuredService, err := utils.DynamicKubeClient.Resource(serviceGVR).Namespace(namespace).Get(name, metaV1.GetOptions{})
func ValidService(ctx context.Context, name, namespace string) (*coreV1.Service, error) {
unstructuredService, err := utils.DynamicKubeClient.Resource(serviceGVR).Namespace(namespace).Get(ctx, name, metaV1.GetOptions{})
if err != nil {
return nil, err
}
Expand All @@ -56,8 +57,8 @@ func ValidService(name, namespace string) (*coreV1.Service, error) {
}

// ValidServicePort returns valid Service object if given service with the port exists in the given namespace
func ValidServicePort(name, namespace string, port int32) (*coreV1.Service, error) {
unstructuredService, err := utils.DynamicKubeClient.Resource(serviceGVR).Namespace(namespace).Get(name, metaV1.GetOptions{})
func ValidServicePort(ctx context.Context, name, namespace string, port int32) (*coreV1.Service, error) {
unstructuredService, err := utils.DynamicKubeClient.Resource(serviceGVR).Namespace(namespace).Get(ctx, name, metaV1.GetOptions{})
if err != nil {
return nil, err
}
Expand All @@ -75,8 +76,8 @@ func ValidServicePort(name, namespace string, port int32) (*coreV1.Service, erro
}

// ValidSecret return Secret object if the secret is present in the specified object
func ValidSecret(name, namespace string) (*coreV1.Secret, error) {
unstructuredSecret, err := utils.DynamicKubeClient.Resource(secretGVR).Namespace(namespace).Get(name, metaV1.GetOptions{})
func ValidSecret(ctx context.Context, name, namespace string) (*coreV1.Secret, error) {
unstructuredSecret, err := utils.DynamicKubeClient.Resource(secretGVR).Namespace(namespace).Get(ctx, name, metaV1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package utils

import (
"bytes"
"context"
"fmt"
"os"
"reflect"
Expand Down Expand Up @@ -272,7 +273,7 @@ func ExtractAnnotationsFromEvent(obj *coreV1.Event) map[string]string {
log.Error(err)
return nil
}
annotations, err := DynamicKubeClient.Resource(gvr).Namespace(obj.InvolvedObject.Namespace).Get(obj.InvolvedObject.Name, metaV1.GetOptions{})
annotations, err := DynamicKubeClient.Resource(gvr).Namespace(obj.InvolvedObject.Namespace).Get(context.Background(), obj.InvolvedObject.Name, metaV1.GetOptions{})
if err != nil {
log.Error(err)
return nil
Expand Down
11 changes: 6 additions & 5 deletions test/e2e/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package utils

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -107,7 +108,7 @@ func CreateResource(t *testing.T, obj CreateObjects) {
s.Object = k
s.SetGroupVersionKind(obj.GVR.GroupVersion().WithKind(obj.Kind))
// Create resource
_, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Create(&s, v1.CreateOptions{})
_, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Create(context.TODO(), &s, v1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create %s: %v", obj.GVR.Resource, err)
}
Expand All @@ -123,14 +124,14 @@ func UpdateResource(t *testing.T, obj UpdateObjects) (*unstructured.Unstructured
s.Object = k
s.SetGroupVersionKind(obj.GVR.GroupVersion().WithKind(obj.Kind))
// Create resource and get the old object
oldObj, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Create(&s, v1.CreateOptions{})
oldObj, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Create(context.TODO(), &s, v1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create %s: %v", obj.GVR.Resource, err)
}
// Mock the time delay involved in listening, filtering, and notifying events to all notifiers
time.Sleep(30 * time.Second)
// Applying patch
newObj, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Patch(s.GetName(), types.MergePatchType, obj.Patch, v1.PatchOptions{})
newObj, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Patch(context.TODO(), s.GetName(), types.MergePatchType, obj.Patch, v1.PatchOptions{})
if err != nil {
t.Fatalf("Failed to update %s: %v", obj.GVR.Resource, err)
}
Expand All @@ -149,12 +150,12 @@ func DeleteResource(t *testing.T, obj DeleteObjects) {
s.Object = k
s.SetGroupVersionKind(obj.GVR.GroupVersion().WithKind(obj.Kind))

_, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Create(&s, v1.CreateOptions{})
_, err := utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Create(context.TODO(), &s, v1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create %s: %v", obj.GVR.Resource, err)
}
// Delete resource
err = utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Delete(s.GetName(), &v1.DeleteOptions{})
err = utils.DynamicKubeClient.Resource(obj.GVR).Namespace(obj.Namespace).Delete(context.TODO(), s.GetName(), v1.DeleteOptions{})

if err != nil {
t.Fatalf("Failed to delete %s: %v", obj.GVR.Resource, err)
Expand Down