From 0edff731dacb50cd43e39ef7946066314346b516 Mon Sep 17 00:00:00 2001 From: an1l4 <1995anila@gmail.com> Date: Fri, 3 May 2024 12:33:21 +0530 Subject: [PATCH 01/10] ketall-unit-test --- agent/kubviz/plugins/ketall/ketall_test.go | 505 +++++++++++++++++++++ 1 file changed, 505 insertions(+) create mode 100644 agent/kubviz/plugins/ketall/ketall_test.go diff --git a/agent/kubviz/plugins/ketall/ketall_test.go b/agent/kubviz/plugins/ketall/ketall_test.go new file mode 100644 index 00000000..836f9b23 --- /dev/null +++ b/agent/kubviz/plugins/ketall/ketall_test.go @@ -0,0 +1,505 @@ +package ketall + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "reflect" + "testing" + + "github.com/agiledragon/gomonkey" + "github.com/intelops/kubviz/model" + "github.com/nats-io/nats.go" + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/rest" +) + +type Resource struct { + Resource string `json:"resource"` + Namespace string `json:"namespace"` + ClusterName string `json:"clusterName"` +} + +type MockJetStreamContext struct{} + +func (m *MockJetStreamContext) AccountInfo(opts ...nats.JSOpt) (*nats.AccountInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) AddConsumer(stream string, cfg *nats.ConsumerConfig, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) AddStream(cfg *nats.StreamConfig, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ChanQueueSubscribe(subj, queue string, ch chan *nats.Msg, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ChanSubscribe(subj string, ch chan *nats.Msg, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ConsumerInfo(stream, consumer string, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ConsumerNames(stream string, opts ...nats.JSOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) Consumers(stream string, opts ...nats.JSOpt) <-chan *nats.ConsumerInfo { + return nil +} + +func (m *MockJetStreamContext) ConsumersInfo(stream string, opts ...nats.JSOpt) <-chan *nats.ConsumerInfo { + return nil +} + +func (m *MockJetStreamContext) CreateKeyValue(kv *nats.KeyValueConfig) (nats.KeyValue, error) { + return nil, nil +} + +func (m *MockJetStreamContext) CreateObjectStore(store *nats.ObjectStoreConfig) (nats.ObjectStore, error) { + return nil, nil +} + +func (m *MockJetStreamContext) DeleteConsumer(stream, consumer string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) DeleteKeyValue(key string) error { + return nil +} + +func (m *MockJetStreamContext) DeleteMsg(stream string, seq uint64, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) DeleteObjectStore(store string) error { + return nil +} + +func (m *MockJetStreamContext) DeleteStream(stream string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) GetLastMsg(stream string, lastBy string, opts ...nats.JSOpt) (*nats.RawStreamMsg, error) { + return nil, nil +} + +func (m *MockJetStreamContext) GetMsg(stream string, seq uint64, opts ...nats.JSOpt) (*nats.RawStreamMsg, error) { + return nil, nil +} + +func (m *MockJetStreamContext) KeyValue(stream string) (nats.KeyValue, error) { + return nil, nil +} + +func (m *MockJetStreamContext) KeyValueStoreNames() <-chan string { + return nil +} + +func (m *MockJetStreamContext) KeyValueStores() <-chan nats.KeyValueStatus { + return nil +} + +func (m *MockJetStreamContext) ObjectStore(stream string) (nats.ObjectStore, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ObjectStoreNames(opts ...nats.ObjectOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) ObjectStores(opts ...nats.ObjectOpt) <-chan nats.ObjectStoreStatus { + return nil +} + +func (m *MockJetStreamContext) PublishAsync(subj string, data []byte, opts ...nats.PubOpt) (nats.PubAckFuture, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PublishAsyncComplete() <-chan struct{} { + return nil +} + +func (m *MockJetStreamContext) PublishAsyncPending() int { + return 0 +} + +func (m *MockJetStreamContext) PublishMsg(msg *nats.Msg, opts ...nats.PubOpt) (*nats.PubAck, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PublishMsgAsync(msg *nats.Msg, opts ...nats.PubOpt) (nats.PubAckFuture, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PullSubscribe(subject, queue string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PurgeStream(stream string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) QueueSubscribe(subject, queue string, handler nats.MsgHandler, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) QueueSubscribeSync(subject, queue string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) SecureDeleteMsg(stream string, seq uint64, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) StreamInfo(stream string, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) StreamNameBySubject(subject string, opts ...nats.JSOpt) (string, error) { + return "", nil +} + +func (m *MockJetStreamContext) StreamNames(opts ...nats.JSOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) Streams(opts ...nats.JSOpt) <-chan *nats.StreamInfo { + return nil +} + +func (m *MockJetStreamContext) StreamsInfo(opts ...nats.JSOpt) <-chan *nats.StreamInfo { + return nil +} + +func (m *MockJetStreamContext) Subscribe(subject string, cb nats.MsgHandler, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) SubscribeSync(subject string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) UpdateConsumer(stream string, cfg *nats.ConsumerConfig, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) UpdateStream(cfg *nats.StreamConfig, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) Publish(subj string, data []byte, opts ...nats.PubOpt) (*nats.PubAck, error) { + resource := &Resource{} + json.Unmarshal(data, resource) + if resource.Resource == "test-error" { + return nil, errors.New("Error in publish") + } + return nil, nil +} + +type MockResourceInterface struct{} + +func (m *MockResourceInterface) Create(ctx context.Context, obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) Update(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) UpdateStatus(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) Delete(ctx context.Context, name string, options metav1.DeleteOptions, subresources ...string) error { + return nil +} +func (m *MockResourceInterface) DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error { + return nil +} +func (m *MockResourceInterface) Get(ctx context.Context, name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockResourceInterface) List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) { + fmt.Println("List 1 called") + return &unstructured.UnstructuredList{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "List", + }, + }, nil +} + +func (m *MockResourceInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return nil, nil +} +func (m *MockResourceInterface) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, options metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) Apply(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) ApplyStatus(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions) (*unstructured.Unstructured, error) { + return nil, nil +} + +type MockNamespaceableResourceInterface struct{} + +func (m *MockNamespaceableResourceInterface) Namespace(s string) dynamic.ResourceInterface { + return &MockResourceInterface{} +} + +func TestPublishAllResources(t *testing.T) { + mockResource := model.Resource{ + Resource: "test-resource", + Kind: "test-kind", + Namespace: "test-namespace", + Age: "test-age", + ClusterName: "test-cluster", + } + tests := []struct { + name string + resource model.Resource + }{ + {"success", mockResource}, + {"error", model.Resource{}}, + } + for _, tt := range tests { + mockJS := &MockJetStreamContext{} + + mockPublish := gomonkey.ApplyMethod( + reflect.TypeOf(mockJS), + "Publish", + func(*MockJetStreamContext, string, []byte, ...nats.PubOpt) (*nats.PubAck, error) { + if tt.name == "error" { + return nil, errors.New("Error in publish") + } + return nil, nil + }, + ) + defer mockPublish.Reset() + + t.Run(tt.name, func(t *testing.T) { + + err := PublishAllResources(tt.resource, mockJS) + if tt.name == "error" { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +type MockDynamicResource struct { + FnList func(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) + FnApply func(ctx context.Context, namespace string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) + FnApplyStat func(ctx context.Context, namespace string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) +} + +func (m *MockDynamicResource) List(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) { + fmt.Println("List 2 called") + return m.FnList(ctx, options) +} + +func (m *MockDynamicResource) Apply(ctx context.Context, namespace string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) { + return m.FnApply(ctx, namespace, obj, options, subresources...) +} + +func (m *MockDynamicResource) ApplyStatus(ctx context.Context, namespace string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) { + return m.FnApplyStat(ctx, namespace, obj, options, subresources...) +} + +func (m *MockNamespaceableResourceInterface) Create(ctx context.Context, obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) Update(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) UpdateStatus(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) Delete(ctx context.Context, name string, options metav1.DeleteOptions, subresources ...string) error { + return nil +} + +func (m *MockNamespaceableResourceInterface) DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error { + return nil +} + +func (m *MockNamespaceableResourceInterface) Get(ctx context.Context, name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) { + fmt.Println("List 3 called") + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, options metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) Apply(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} + +func (m *MockNamespaceableResourceInterface) ApplyStatus(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions) (*unstructured.Unstructured, error) { + return nil, nil +} + +type APIPathResolverFunc func(kind schema.GroupVersionKind) string + +func LegacyAPIPathResolverFunc(kind schema.GroupVersionKind) string { + if len(kind.Group) == 0 { + return "/api" + } + return "/apis" +} + +func TestGetAllResources2(t *testing.T) { + cases := []struct { + name string + isNameSpaceEmpty bool + wantErr bool + PublishAllResourcesErr bool + }{ + {"success with namespace", false, false, false}, + {"success without namespace", true, false, false}, + {"error in NewForConfig", false, true, false}, + } + + for _, tt := range cases { + mockConfig := &rest.Config{} + mockJS := &MockJetStreamContext{} + mockDC := &discovery.DiscoveryClient{} + mockGroupVersionResource := schema.GroupVersionResource{ + Group: "group", + Version: "version", + Resource: "resource", + } + mockgvrs := make(map[schema.GroupVersionResource]struct{}) + mockgvrs[mockGroupVersionResource] = struct{}{} + mockList := &unstructured.UnstructuredList{ + Items: []unstructured.Unstructured{ + { + Object: map[string]interface{}{ + "apiVersion": "group/version", + "kind": "resource", + }, + }, + }, + } + mockDyC := &dynamic.DynamicClient{} + mockNamespace := &MockNamespaceableResourceInterface{} + mockResourceInterface := &MockResourceInterface{} + + patchNewDiscovery := gomonkey.ApplyFunc( + discovery.NewDiscoveryClientForConfigOrDie, + func(*rest.Config) *discovery.DiscoveryClient { + return mockDC + }, + ) + defer patchNewDiscovery.Reset() + + if tt.wantErr { + patchNewDynamic := gomonkey.ApplyFunc( + dynamic.NewForConfig, + func(*rest.Config) (*dynamic.DynamicClient, error) { + return nil, errors.New("new dynamic client error") + }, + ) + defer patchNewDynamic.Reset() + } + + patchResourceLists := gomonkey.ApplyMethod( + reflect.TypeOf(mockDC), + "ServerPreferredResources", + func(*discovery.DiscoveryClient) ([]*metav1.APIResourceList, error) { + return []*metav1.APIResourceList{}, nil + }, + ) + defer patchResourceLists.Reset() + + patchgvrs := gomonkey.ApplyFunc( + discovery.GroupVersionResources, + func([]*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error) { + return mockgvrs, nil + }, + ) + defer patchgvrs.Reset() + + mockDynamicResourceInterface := &MockNamespaceableResourceInterface{} + patchResource := gomonkey.ApplyMethod( + reflect.TypeOf(mockDyC), + "Resource", + func(*dynamic.DynamicClient, schema.GroupVersionResource) dynamic.NamespaceableResourceInterface { + return mockDynamicResourceInterface + }, + ) + defer patchResource.Reset() + + patchNamespace := gomonkey.ApplyMethod( + reflect.TypeOf(mockNamespace), + "Namespace", + func(*MockNamespaceableResourceInterface, string) dynamic.ResourceInterface { + return mockResourceInterface + }, + ) + defer patchNamespace.Reset() + + patchList := gomonkey.ApplyMethod( + reflect.TypeOf(mockResourceInterface), + "List", + func(*MockResourceInterface, context.Context, metav1.ListOptions) (*unstructured.UnstructuredList, error) { + return mockList, nil + }, + ) + defer patchList.Reset() + + mockItem := &unstructured.Unstructured{} + patchGetNamespace := gomonkey.ApplyMethod( + reflect.TypeOf(mockItem), + "GetNamespace", + func(*unstructured.Unstructured) string { + if tt.isNameSpaceEmpty { + return "" + } + return "default" + }, + ) + defer patchGetNamespace.Reset() + + t.Run(tt.name, func(t *testing.T) { + err := GetAllResources(mockConfig, mockJS) + fmt.Println("Error in GetAllResources: ", err) + if tt.wantErr { + require.Error(t, err) + } else if tt.isNameSpaceEmpty { + require.NoError(t, err) + } else { + require.NoError(t, err) + } + }) + } +} From 6b62c5e9ff2398d5e8591aeb8da09d8927e1c15a Mon Sep 17 00:00:00 2001 From: Nithunikzz Date: Wed, 8 May 2024 15:09:22 +0530 Subject: [PATCH 02/10] kubescore testing --- .../plugins/kubescore/kubescore_test.go | 130 +++ agent/kubviz/plugins/trivy/trivy_image.go | 8 + go.mod | 14 +- go.sum | 26 +- mocks/trivy_client_mock.go | 840 ++++++++++++++++++ 5 files changed, 991 insertions(+), 27 deletions(-) create mode 100644 agent/kubviz/plugins/kubescore/kubescore_test.go create mode 100644 mocks/trivy_client_mock.go diff --git a/agent/kubviz/plugins/kubescore/kubescore_test.go b/agent/kubviz/plugins/kubescore/kubescore_test.go new file mode 100644 index 00000000..63e5d321 --- /dev/null +++ b/agent/kubviz/plugins/kubescore/kubescore_test.go @@ -0,0 +1,130 @@ +package kubescore + +import ( + "errors" + "testing" + + "bou.ke/monkey" + "github.com/golang/mock/gomock" + "github.com/intelops/kubviz/constants" + "github.com/intelops/kubviz/mocks" + "github.com/stretchr/testify/assert" + "github.com/zegl/kube-score/renderer/json_v2" +) + +func TestPublishKubescoreMetrics(t *testing.T) { + // Define the report data + report := []json_v2.ScoredObject{ + { + ObjectName: "object1", + // Define other fields as needed + }, + { + ObjectName: "object2", + // Define other fields as needed + }, + } + + // Initialize the MockJetStreamContextInterface + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + js := mocks.NewMockJetStreamContextInterface(ctrl) + + // Test case: Testing successful publishing of kube-score metrics + t.Run("Successful publishing", func(t *testing.T) { + + // Set the mock expectation for Publish + js.EXPECT().Publish(constants.KUBESCORE_SUBJECT, gomock.Any()).Return(nil, nil) + + // Call the function under test + err := publishKubescoreMetrics(report, js) + + // Assert that no error occurred during the function call + assert.NoError(t, err) + }) + // Test case: Error handling for Publish failure + t.Run("Error handling for Publish failure", func(t *testing.T) { + js.EXPECT().Publish(constants.KUBESCORE_SUBJECT, gomock.Any()).Return(nil, errors.New("publish error")) + err := publishKubescoreMetrics(report, js) + assert.Error(t, err) + }) + + // Test case: Nil input report + t.Run("Nil input report", func(t *testing.T) { + js.EXPECT().Publish(constants.KUBESCORE_SUBJECT, gomock.Any()).Return(nil, errors.New("publish error")) + + err := publishKubescoreMetrics(nil, js) + assert.Error(t, err) // Assuming this is the desired behavior for nil input + }) + + // Test case: Empty report + t.Run("Empty report", func(t *testing.T) { + js.EXPECT().Publish(constants.KUBESCORE_SUBJECT, gomock.Any()).Return(nil, errors.New("publish error")) + + err := publishKubescoreMetrics([]json_v2.ScoredObject{}, js) + assert.Error(t, err) // Assuming this is the desired behavior for an empty report + }) + +} +func TestExecuteCommand(t *testing.T) { + t.Run("Successful command execution", func(t *testing.T) { + command := "echo 'Hello, World!'" + output, err := ExecuteCommand(command) + + assert.NoError(t, err) + assert.Equal(t, "Hello, World!\n", output) + }) + + t.Run("Command execution error", func(t *testing.T) { + command := "non_existing_command" + _, err := ExecuteCommand(command) + + assert.Error(t, err) + }) + +} + +func TestPublish(t *testing.T) { + // Mock the ExecuteCommand function + var mockOutput = []byte(`[{"ObjectName":"test-object","TypeMeta":{"Kind":"Pod"},"ObjectMeta":{"Name":"test-pod"},"Checks":[{"ID":"check-id","Severity":"info","Message":"test message"}],"FileName":"test-file","FileRow":1}]`) + monkey.Patch(ExecuteCommand, func(command string) (string, error) { + return string(mockOutput), nil + }) + defer monkey.Unpatch(ExecuteCommand) + + // Create a new gomock controller + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // Create a JetStreamContext mock + jsMock := mocks.NewMockJetStreamContextInterface(ctrl) + + // Subtest for successful publish + t.Run("Successful publish", func(t *testing.T) { + jsMock.EXPECT().Publish(gomock.Any(), gomock.Any()).Return(nil, nil) + ns := "test-namespace" + err := publish(ns, jsMock) + if err != nil { + t.Errorf("publish returned an error: %v", err) + } + }) + + // Subtest for error in ExecuteCommand + t.Run("Error in ExecuteCommand", func(t *testing.T) { + // Mock ExecuteCommand to return an error + monkey.Patch(ExecuteCommand, func(command string) (string, error) { + return "", errors.New("command execution error") + }) + defer monkey.Unpatch(ExecuteCommand) + + ns := "test-namespace" + err := publish(ns, jsMock) + if err == nil { + t.Errorf("publish did not return an error") + } + + // Since ExecuteCommand failed, Publish should not be called + jsMock.EXPECT().Publish(gomock.Any(), gomock.Any()).Times(0) + }) +} diff --git a/agent/kubviz/plugins/trivy/trivy_image.go b/agent/kubviz/plugins/trivy/trivy_image.go index c4919a18..9628e31d 100644 --- a/agent/kubviz/plugins/trivy/trivy_image.go +++ b/agent/kubviz/plugins/trivy/trivy_image.go @@ -24,6 +24,14 @@ import ( "k8s.io/client-go/rest" ) +type JetStreamContextInterface interface { + nats.JetStream + nats.JetStreamManager + nats.KeyValueManager + nats.ObjectStoreManager + AccountInfo(opts ...nats.JSOpt) (*nats.AccountInfo, error) +} + func RunTrivyImageScans(config *rest.Config, js nats.JetStreamContext) error { pvcMountPath := "/mnt/agent/kbz" trivyImageCacheDir := fmt.Sprintf("%s/trivy-imagecache", pvcMountPath) diff --git a/go.mod b/go.mod index cbb62157..e666b12a 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/intelops/kubviz go 1.20 require ( - github.com/99designs/gqlgen v0.17.42 + bou.ke/monkey v1.0.2 github.com/ClickHouse/clickhouse-go/v2 v2.10.1 + github.com/agiledragon/gomonkey v2.0.2+incompatible github.com/aquasecurity/trivy v0.43.1 github.com/aws/aws-sdk-go v1.44.245 github.com/blang/semver v3.5.1+incompatible @@ -17,6 +18,7 @@ require ( github.com/go-co-op/gocron v1.30.1 github.com/go-playground/webhooks/v6 v6.2.0 github.com/golang-migrate/migrate/v4 v4.16.2 + github.com/golang/mock v1.5.0 github.com/google/uuid v1.3.1 github.com/hashicorp/go-version v1.6.0 github.com/intelops/go-common v1.0.19 @@ -27,7 +29,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 - github.com/vektah/gqlparser/v2 v2.5.10 + github.com/stretchr/testify v1.8.4 github.com/zegl/kube-score v1.17.0 go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.46.1 go.opentelemetry.io/otel v1.21.0 @@ -48,7 +50,6 @@ require ( cloud.google.com/go/storage v1.30.1 // indirect github.com/ClickHouse/ch-go v0.52.1 // indirect github.com/CycloneDX/cyclonedx-go v0.7.2-0.20230625092137-07e2f29defc3 // indirect - github.com/agnivade/levenshtein v1.1.1 // indirect github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/aquasecurity/go-dep-parser v0.0.0-20230626110909-e7ea5097483b // indirect @@ -89,12 +90,10 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect github.com/imdario/mergo v0.3.15 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/invopop/yaml v0.1.0 // indirect @@ -111,7 +110,6 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect @@ -133,13 +131,12 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/samber/lo v1.38.1 // indirect github.com/segmentio/asm v1.2.0 // indirect + github.com/sergi/go-diff v1.3.1 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/showa-93/go-mask v0.6.0 // indirect - github.com/sosodev/duration v1.1.0 // indirect github.com/spdx/tools-golang v0.5.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect - github.com/stretchr/testify v1.8.4 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/xlab/treeprint v1.1.0 // indirect @@ -159,6 +156,7 @@ require ( golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.9.3 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 4e586f75..e04eec7e 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI= +bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -44,8 +46,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/99designs/gqlgen v0.17.42 h1:BVWDOb2VVHQC5k3m6oa0XhDnxltLLrU4so7x/u39Zu4= -github.com/99designs/gqlgen v0.17.42/go.mod h1:GQ6SyMhwFbgHR0a8r2Wn8fYgEwPxxmndLFPhU63+cJE= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -79,20 +79,18 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0 github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/Pallinder/go-randomdata v1.1.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 h1:ZK3C5DtzV2nVAQTx5S5jQvMeDqWtD1By5mOoyY/xJek= -github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw= +github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= -github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092 h1:aM1rlcoLz8y5B2r4tTLMiVTrMtpfY0O8EScKJxaSaEc= github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092/go.mod h1:rYqSE9HbjzpHTI74vwPvae4ZVYZd1lue2ta6xHPdblA= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986 h1:2a30xLN2sUZcMXl50hg+PJCIDdJgIvIbVcKqLJ/ZrtM= @@ -109,8 +107,6 @@ github.com/aquasecurity/trivy-db v0.0.0-20230703082116-dc52e83376ce h1:swoQLWQoZ github.com/aquasecurity/trivy-db v0.0.0-20230703082116-dc52e83376ce/go.mod h1:cXuqKo+FaMY0ixJNoUcyDHdfCBRPWOysI2Td8N4fRsg= github.com/aquasecurity/trivy-kubernetes v0.5.7-0.20230628140707-dae3bdb6ee81 h1:5/tKpCr861auON/CMHSXnRzNixx1FTWAeHSwV0PtA0U= github.com/aquasecurity/trivy-kubernetes v0.5.7-0.20230628140707-dae3bdb6ee81/go.mod h1:GCm7uq++jz7Ij8cA9mAorpKJ9/qSBCl7v6EKYA8DxJ8= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/aws/aws-sdk-go v1.25.24/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -163,8 +159,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/denverdino/aliyungo v0.0.0-20191023002520-dba750c0c223/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dhui/dktest v0.3.16 h1:i6gq2YQEtcrjKbeJpBkWjE8MmLZPYllcjOFbTZuPDnw= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/docker/cli v0.0.0-20190913211141-95327f4e6241/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= @@ -295,6 +289,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -380,8 +375,6 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -401,8 +394,6 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru/v2 v2.0.3 h1:kmRrRLlInXvng0SmLxmQpQkpbYAvcXm7NPDrgxJa9mE= -github.com/hashicorp/golang-lru/v2 v2.0.3/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl/v2 v2.14.1 h1:x0BpjfZ+CYdbiz+8yZTQ+gdLO7IXvOut7Da+XJayx34= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -499,7 +490,6 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/moby/buildkit v0.11.6 h1:VYNdoKk5TVxN7k4RvZgdeM4GOyRvIi4Z8MXOY7xvyUs= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= @@ -607,6 +597,7 @@ github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/showa-93/go-mask v0.6.0 h1:nNW3dgEocYB7QCGzgRx9wlYrepEg+tRw/keg7u1ftY8= @@ -620,8 +611,6 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/skeema/knownhosts v1.1.1 h1:MTk78x9FPgDFVFkDLTrsnnfCJl7g1C/nnKvePgrIngE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/sosodev/duration v1.1.0 h1:kQcaiGbJaIsRqgQy7VGlZrVw1giWO+lDoX3MCPnpVO4= -github.com/sosodev/duration v1.1.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb/go.mod h1:uKWaldnbMnjsSAXRurWqqrdyZen1R7kxl8TkmWk2OyM= github.com/spdx/tools-golang v0.5.0 h1:/fqihV2Jna7fmow65dHpgKNsilgLK7ICpd2tkCnPEyY= github.com/spdx/tools-golang v0.5.0/go.mod h1:kkGlrSXXfHwuSzHQZJRV3aKu9ZXCq/MSf2+xyiJH1lM= @@ -662,8 +651,6 @@ github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95 github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= -github.com/vektah/gqlparser/v2 v2.5.10 h1:6zSM4azXC9u4Nxy5YmdmGu4uKamfwsdKTwp5zsEealU= -github.com/vektah/gqlparser/v2 v2.5.10/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= @@ -994,6 +981,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= +golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/mocks/trivy_client_mock.go b/mocks/trivy_client_mock.go new file mode 100644 index 00000000..8d6ba59c --- /dev/null +++ b/mocks/trivy_client_mock.go @@ -0,0 +1,840 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: /home/nithu/go/src/testing/kubviz/agent/kubviz/plugins/trivy/trivy_image.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + nats_go "github.com/nats-io/nats.go" +) + +// MockJetStreamContextInterface is a mock of JetStreamContextInterface interface. +type MockJetStreamContextInterface struct { + ctrl *gomock.Controller + recorder *MockJetStreamContextInterfaceMockRecorder +} + +// MockJetStreamContextInterfaceMockRecorder is the mock recorder for MockJetStreamContextInterface. +type MockJetStreamContextInterfaceMockRecorder struct { + mock *MockJetStreamContextInterface +} + +// NewMockJetStreamContextInterface creates a new mock instance. +func NewMockJetStreamContextInterface(ctrl *gomock.Controller) *MockJetStreamContextInterface { + mock := &MockJetStreamContextInterface{ctrl: ctrl} + mock.recorder = &MockJetStreamContextInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockJetStreamContextInterface) EXPECT() *MockJetStreamContextInterfaceMockRecorder { + return m.recorder +} + +// AccountInfo mocks base method. +func (m *MockJetStreamContextInterface) AccountInfo(opts ...nats_go.JSOpt) (*nats_go.AccountInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AccountInfo", varargs...) + ret0, _ := ret[0].(*nats_go.AccountInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AccountInfo indicates an expected call of AccountInfo. +func (mr *MockJetStreamContextInterfaceMockRecorder) AccountInfo(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AccountInfo", reflect.TypeOf((*MockJetStreamContextInterface)(nil).AccountInfo), opts...) +} + +// AddConsumer mocks base method. +func (m *MockJetStreamContextInterface) AddConsumer(stream string, cfg *nats_go.ConsumerConfig, opts ...nats_go.JSOpt) (*nats_go.ConsumerInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{stream, cfg} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AddConsumer", varargs...) + ret0, _ := ret[0].(*nats_go.ConsumerInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddConsumer indicates an expected call of AddConsumer. +func (mr *MockJetStreamContextInterfaceMockRecorder) AddConsumer(stream, cfg interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream, cfg}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddConsumer", reflect.TypeOf((*MockJetStreamContextInterface)(nil).AddConsumer), varargs...) +} + +// AddStream mocks base method. +func (m *MockJetStreamContextInterface) AddStream(cfg *nats_go.StreamConfig, opts ...nats_go.JSOpt) (*nats_go.StreamInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{cfg} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AddStream", varargs...) + ret0, _ := ret[0].(*nats_go.StreamInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddStream indicates an expected call of AddStream. +func (mr *MockJetStreamContextInterfaceMockRecorder) AddStream(cfg interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{cfg}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddStream", reflect.TypeOf((*MockJetStreamContextInterface)(nil).AddStream), varargs...) +} + +// ChanQueueSubscribe mocks base method. +func (m *MockJetStreamContextInterface) ChanQueueSubscribe(subj, queue string, ch chan *nats_go.Msg, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, queue, ch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ChanQueueSubscribe", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ChanQueueSubscribe indicates an expected call of ChanQueueSubscribe. +func (mr *MockJetStreamContextInterfaceMockRecorder) ChanQueueSubscribe(subj, queue, ch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, queue, ch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChanQueueSubscribe", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ChanQueueSubscribe), varargs...) +} + +// ChanSubscribe mocks base method. +func (m *MockJetStreamContextInterface) ChanSubscribe(subj string, ch chan *nats_go.Msg, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, ch} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ChanSubscribe", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ChanSubscribe indicates an expected call of ChanSubscribe. +func (mr *MockJetStreamContextInterfaceMockRecorder) ChanSubscribe(subj, ch interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, ch}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChanSubscribe", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ChanSubscribe), varargs...) +} + +// ConsumerInfo mocks base method. +func (m *MockJetStreamContextInterface) ConsumerInfo(stream, name string, opts ...nats_go.JSOpt) (*nats_go.ConsumerInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{stream, name} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ConsumerInfo", varargs...) + ret0, _ := ret[0].(*nats_go.ConsumerInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ConsumerInfo indicates an expected call of ConsumerInfo. +func (mr *MockJetStreamContextInterfaceMockRecorder) ConsumerInfo(stream, name interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream, name}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsumerInfo", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ConsumerInfo), varargs...) +} + +// ConsumerNames mocks base method. +func (m *MockJetStreamContextInterface) ConsumerNames(stream string, opts ...nats_go.JSOpt) <-chan string { + m.ctrl.T.Helper() + varargs := []interface{}{stream} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ConsumerNames", varargs...) + ret0, _ := ret[0].(<-chan string) + return ret0 +} + +// ConsumerNames indicates an expected call of ConsumerNames. +func (mr *MockJetStreamContextInterfaceMockRecorder) ConsumerNames(stream interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsumerNames", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ConsumerNames), varargs...) +} + +// Consumers mocks base method. +func (m *MockJetStreamContextInterface) Consumers(stream string, opts ...nats_go.JSOpt) <-chan *nats_go.ConsumerInfo { + m.ctrl.T.Helper() + varargs := []interface{}{stream} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Consumers", varargs...) + ret0, _ := ret[0].(<-chan *nats_go.ConsumerInfo) + return ret0 +} + +// Consumers indicates an expected call of Consumers. +func (mr *MockJetStreamContextInterfaceMockRecorder) Consumers(stream interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Consumers", reflect.TypeOf((*MockJetStreamContextInterface)(nil).Consumers), varargs...) +} + +// ConsumersInfo mocks base method. +func (m *MockJetStreamContextInterface) ConsumersInfo(stream string, opts ...nats_go.JSOpt) <-chan *nats_go.ConsumerInfo { + m.ctrl.T.Helper() + varargs := []interface{}{stream} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ConsumersInfo", varargs...) + ret0, _ := ret[0].(<-chan *nats_go.ConsumerInfo) + return ret0 +} + +// ConsumersInfo indicates an expected call of ConsumersInfo. +func (mr *MockJetStreamContextInterfaceMockRecorder) ConsumersInfo(stream interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConsumersInfo", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ConsumersInfo), varargs...) +} + +// CreateKeyValue mocks base method. +func (m *MockJetStreamContextInterface) CreateKeyValue(cfg *nats_go.KeyValueConfig) (nats_go.KeyValue, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateKeyValue", cfg) + ret0, _ := ret[0].(nats_go.KeyValue) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateKeyValue indicates an expected call of CreateKeyValue. +func (mr *MockJetStreamContextInterfaceMockRecorder) CreateKeyValue(cfg interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateKeyValue", reflect.TypeOf((*MockJetStreamContextInterface)(nil).CreateKeyValue), cfg) +} + +// CreateObjectStore mocks base method. +func (m *MockJetStreamContextInterface) CreateObjectStore(cfg *nats_go.ObjectStoreConfig) (nats_go.ObjectStore, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateObjectStore", cfg) + ret0, _ := ret[0].(nats_go.ObjectStore) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateObjectStore indicates an expected call of CreateObjectStore. +func (mr *MockJetStreamContextInterfaceMockRecorder) CreateObjectStore(cfg interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateObjectStore", reflect.TypeOf((*MockJetStreamContextInterface)(nil).CreateObjectStore), cfg) +} + +// DeleteConsumer mocks base method. +func (m *MockJetStreamContextInterface) DeleteConsumer(stream, consumer string, opts ...nats_go.JSOpt) error { + m.ctrl.T.Helper() + varargs := []interface{}{stream, consumer} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteConsumer", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteConsumer indicates an expected call of DeleteConsumer. +func (mr *MockJetStreamContextInterfaceMockRecorder) DeleteConsumer(stream, consumer interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream, consumer}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConsumer", reflect.TypeOf((*MockJetStreamContextInterface)(nil).DeleteConsumer), varargs...) +} + +// DeleteKeyValue mocks base method. +func (m *MockJetStreamContextInterface) DeleteKeyValue(bucket string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteKeyValue", bucket) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteKeyValue indicates an expected call of DeleteKeyValue. +func (mr *MockJetStreamContextInterfaceMockRecorder) DeleteKeyValue(bucket interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteKeyValue", reflect.TypeOf((*MockJetStreamContextInterface)(nil).DeleteKeyValue), bucket) +} + +// DeleteMsg mocks base method. +func (m *MockJetStreamContextInterface) DeleteMsg(name string, seq uint64, opts ...nats_go.JSOpt) error { + m.ctrl.T.Helper() + varargs := []interface{}{name, seq} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteMsg", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteMsg indicates an expected call of DeleteMsg. +func (mr *MockJetStreamContextInterfaceMockRecorder) DeleteMsg(name, seq interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name, seq}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMsg", reflect.TypeOf((*MockJetStreamContextInterface)(nil).DeleteMsg), varargs...) +} + +// DeleteObjectStore mocks base method. +func (m *MockJetStreamContextInterface) DeleteObjectStore(bucket string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteObjectStore", bucket) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteObjectStore indicates an expected call of DeleteObjectStore. +func (mr *MockJetStreamContextInterfaceMockRecorder) DeleteObjectStore(bucket interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteObjectStore", reflect.TypeOf((*MockJetStreamContextInterface)(nil).DeleteObjectStore), bucket) +} + +// DeleteStream mocks base method. +func (m *MockJetStreamContextInterface) DeleteStream(name string, opts ...nats_go.JSOpt) error { + m.ctrl.T.Helper() + varargs := []interface{}{name} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteStream", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteStream indicates an expected call of DeleteStream. +func (mr *MockJetStreamContextInterfaceMockRecorder) DeleteStream(name interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStream", reflect.TypeOf((*MockJetStreamContextInterface)(nil).DeleteStream), varargs...) +} + +// GetLastMsg mocks base method. +func (m *MockJetStreamContextInterface) GetLastMsg(name, subject string, opts ...nats_go.JSOpt) (*nats_go.RawStreamMsg, error) { + m.ctrl.T.Helper() + varargs := []interface{}{name, subject} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetLastMsg", varargs...) + ret0, _ := ret[0].(*nats_go.RawStreamMsg) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetLastMsg indicates an expected call of GetLastMsg. +func (mr *MockJetStreamContextInterfaceMockRecorder) GetLastMsg(name, subject interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name, subject}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastMsg", reflect.TypeOf((*MockJetStreamContextInterface)(nil).GetLastMsg), varargs...) +} + +// GetMsg mocks base method. +func (m *MockJetStreamContextInterface) GetMsg(name string, seq uint64, opts ...nats_go.JSOpt) (*nats_go.RawStreamMsg, error) { + m.ctrl.T.Helper() + varargs := []interface{}{name, seq} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetMsg", varargs...) + ret0, _ := ret[0].(*nats_go.RawStreamMsg) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetMsg indicates an expected call of GetMsg. +func (mr *MockJetStreamContextInterfaceMockRecorder) GetMsg(name, seq interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name, seq}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMsg", reflect.TypeOf((*MockJetStreamContextInterface)(nil).GetMsg), varargs...) +} + +// KeyValue mocks base method. +func (m *MockJetStreamContextInterface) KeyValue(bucket string) (nats_go.KeyValue, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "KeyValue", bucket) + ret0, _ := ret[0].(nats_go.KeyValue) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// KeyValue indicates an expected call of KeyValue. +func (mr *MockJetStreamContextInterfaceMockRecorder) KeyValue(bucket interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeyValue", reflect.TypeOf((*MockJetStreamContextInterface)(nil).KeyValue), bucket) +} + +// KeyValueStoreNames mocks base method. +func (m *MockJetStreamContextInterface) KeyValueStoreNames() <-chan string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "KeyValueStoreNames") + ret0, _ := ret[0].(<-chan string) + return ret0 +} + +// KeyValueStoreNames indicates an expected call of KeyValueStoreNames. +func (mr *MockJetStreamContextInterfaceMockRecorder) KeyValueStoreNames() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeyValueStoreNames", reflect.TypeOf((*MockJetStreamContextInterface)(nil).KeyValueStoreNames)) +} + +// KeyValueStores mocks base method. +func (m *MockJetStreamContextInterface) KeyValueStores() <-chan nats_go.KeyValueStatus { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "KeyValueStores") + ret0, _ := ret[0].(<-chan nats_go.KeyValueStatus) + return ret0 +} + +// KeyValueStores indicates an expected call of KeyValueStores. +func (mr *MockJetStreamContextInterfaceMockRecorder) KeyValueStores() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeyValueStores", reflect.TypeOf((*MockJetStreamContextInterface)(nil).KeyValueStores)) +} + +// ObjectStore mocks base method. +func (m *MockJetStreamContextInterface) ObjectStore(bucket string) (nats_go.ObjectStore, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ObjectStore", bucket) + ret0, _ := ret[0].(nats_go.ObjectStore) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ObjectStore indicates an expected call of ObjectStore. +func (mr *MockJetStreamContextInterfaceMockRecorder) ObjectStore(bucket interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectStore", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ObjectStore), bucket) +} + +// ObjectStoreNames mocks base method. +func (m *MockJetStreamContextInterface) ObjectStoreNames(opts ...nats_go.ObjectOpt) <-chan string { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ObjectStoreNames", varargs...) + ret0, _ := ret[0].(<-chan string) + return ret0 +} + +// ObjectStoreNames indicates an expected call of ObjectStoreNames. +func (mr *MockJetStreamContextInterfaceMockRecorder) ObjectStoreNames(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectStoreNames", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ObjectStoreNames), opts...) +} + +// ObjectStores mocks base method. +func (m *MockJetStreamContextInterface) ObjectStores(opts ...nats_go.ObjectOpt) <-chan nats_go.ObjectStoreStatus { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ObjectStores", varargs...) + ret0, _ := ret[0].(<-chan nats_go.ObjectStoreStatus) + return ret0 +} + +// ObjectStores indicates an expected call of ObjectStores. +func (mr *MockJetStreamContextInterfaceMockRecorder) ObjectStores(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectStores", reflect.TypeOf((*MockJetStreamContextInterface)(nil).ObjectStores), opts...) +} + +// Publish mocks base method. +func (m *MockJetStreamContextInterface) Publish(subj string, data []byte, opts ...nats_go.PubOpt) (*nats_go.PubAck, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, data} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Publish", varargs...) + ret0, _ := ret[0].(*nats_go.PubAck) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Publish indicates an expected call of Publish. +func (mr *MockJetStreamContextInterfaceMockRecorder) Publish(subj, data interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, data}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Publish", reflect.TypeOf((*MockJetStreamContextInterface)(nil).Publish), varargs...) +} + +// PublishAsync mocks base method. +func (m *MockJetStreamContextInterface) PublishAsync(subj string, data []byte, opts ...nats_go.PubOpt) (nats_go.PubAckFuture, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, data} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PublishAsync", varargs...) + ret0, _ := ret[0].(nats_go.PubAckFuture) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PublishAsync indicates an expected call of PublishAsync. +func (mr *MockJetStreamContextInterfaceMockRecorder) PublishAsync(subj, data interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, data}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishAsync", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PublishAsync), varargs...) +} + +// PublishAsyncComplete mocks base method. +func (m *MockJetStreamContextInterface) PublishAsyncComplete() <-chan struct{} { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PublishAsyncComplete") + ret0, _ := ret[0].(<-chan struct{}) + return ret0 +} + +// PublishAsyncComplete indicates an expected call of PublishAsyncComplete. +func (mr *MockJetStreamContextInterfaceMockRecorder) PublishAsyncComplete() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishAsyncComplete", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PublishAsyncComplete)) +} + +// PublishAsyncPending mocks base method. +func (m *MockJetStreamContextInterface) PublishAsyncPending() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PublishAsyncPending") + ret0, _ := ret[0].(int) + return ret0 +} + +// PublishAsyncPending indicates an expected call of PublishAsyncPending. +func (mr *MockJetStreamContextInterfaceMockRecorder) PublishAsyncPending() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishAsyncPending", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PublishAsyncPending)) +} + +// PublishMsg mocks base method. +func (m_2 *MockJetStreamContextInterface) PublishMsg(m *nats_go.Msg, opts ...nats_go.PubOpt) (*nats_go.PubAck, error) { + m_2.ctrl.T.Helper() + varargs := []interface{}{m} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m_2.ctrl.Call(m_2, "PublishMsg", varargs...) + ret0, _ := ret[0].(*nats_go.PubAck) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PublishMsg indicates an expected call of PublishMsg. +func (mr *MockJetStreamContextInterfaceMockRecorder) PublishMsg(m interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{m}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishMsg", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PublishMsg), varargs...) +} + +// PublishMsgAsync mocks base method. +func (m_2 *MockJetStreamContextInterface) PublishMsgAsync(m *nats_go.Msg, opts ...nats_go.PubOpt) (nats_go.PubAckFuture, error) { + m_2.ctrl.T.Helper() + varargs := []interface{}{m} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m_2.ctrl.Call(m_2, "PublishMsgAsync", varargs...) + ret0, _ := ret[0].(nats_go.PubAckFuture) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PublishMsgAsync indicates an expected call of PublishMsgAsync. +func (mr *MockJetStreamContextInterfaceMockRecorder) PublishMsgAsync(m interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{m}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishMsgAsync", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PublishMsgAsync), varargs...) +} + +// PullSubscribe mocks base method. +func (m *MockJetStreamContextInterface) PullSubscribe(subj, durable string, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, durable} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PullSubscribe", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PullSubscribe indicates an expected call of PullSubscribe. +func (mr *MockJetStreamContextInterfaceMockRecorder) PullSubscribe(subj, durable interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, durable}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PullSubscribe", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PullSubscribe), varargs...) +} + +// PurgeStream mocks base method. +func (m *MockJetStreamContextInterface) PurgeStream(name string, opts ...nats_go.JSOpt) error { + m.ctrl.T.Helper() + varargs := []interface{}{name} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "PurgeStream", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// PurgeStream indicates an expected call of PurgeStream. +func (mr *MockJetStreamContextInterfaceMockRecorder) PurgeStream(name interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PurgeStream", reflect.TypeOf((*MockJetStreamContextInterface)(nil).PurgeStream), varargs...) +} + +// QueueSubscribe mocks base method. +func (m *MockJetStreamContextInterface) QueueSubscribe(subj, queue string, cb nats_go.MsgHandler, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, queue, cb} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "QueueSubscribe", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// QueueSubscribe indicates an expected call of QueueSubscribe. +func (mr *MockJetStreamContextInterfaceMockRecorder) QueueSubscribe(subj, queue, cb interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, queue, cb}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueueSubscribe", reflect.TypeOf((*MockJetStreamContextInterface)(nil).QueueSubscribe), varargs...) +} + +// QueueSubscribeSync mocks base method. +func (m *MockJetStreamContextInterface) QueueSubscribeSync(subj, queue string, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, queue} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "QueueSubscribeSync", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// QueueSubscribeSync indicates an expected call of QueueSubscribeSync. +func (mr *MockJetStreamContextInterfaceMockRecorder) QueueSubscribeSync(subj, queue interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, queue}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueueSubscribeSync", reflect.TypeOf((*MockJetStreamContextInterface)(nil).QueueSubscribeSync), varargs...) +} + +// SecureDeleteMsg mocks base method. +func (m *MockJetStreamContextInterface) SecureDeleteMsg(name string, seq uint64, opts ...nats_go.JSOpt) error { + m.ctrl.T.Helper() + varargs := []interface{}{name, seq} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SecureDeleteMsg", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// SecureDeleteMsg indicates an expected call of SecureDeleteMsg. +func (mr *MockJetStreamContextInterfaceMockRecorder) SecureDeleteMsg(name, seq interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name, seq}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecureDeleteMsg", reflect.TypeOf((*MockJetStreamContextInterface)(nil).SecureDeleteMsg), varargs...) +} + +// StreamInfo mocks base method. +func (m *MockJetStreamContextInterface) StreamInfo(stream string, opts ...nats_go.JSOpt) (*nats_go.StreamInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{stream} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "StreamInfo", varargs...) + ret0, _ := ret[0].(*nats_go.StreamInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StreamInfo indicates an expected call of StreamInfo. +func (mr *MockJetStreamContextInterfaceMockRecorder) StreamInfo(stream interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamInfo", reflect.TypeOf((*MockJetStreamContextInterface)(nil).StreamInfo), varargs...) +} + +// StreamNameBySubject mocks base method. +func (m *MockJetStreamContextInterface) StreamNameBySubject(arg0 string, arg1 ...nats_go.JSOpt) (string, error) { + m.ctrl.T.Helper() + varargs := []interface{}{arg0} + for _, a := range arg1 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "StreamNameBySubject", varargs...) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StreamNameBySubject indicates an expected call of StreamNameBySubject. +func (mr *MockJetStreamContextInterfaceMockRecorder) StreamNameBySubject(arg0 interface{}, arg1 ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{arg0}, arg1...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamNameBySubject", reflect.TypeOf((*MockJetStreamContextInterface)(nil).StreamNameBySubject), varargs...) +} + +// StreamNames mocks base method. +func (m *MockJetStreamContextInterface) StreamNames(opts ...nats_go.JSOpt) <-chan string { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "StreamNames", varargs...) + ret0, _ := ret[0].(<-chan string) + return ret0 +} + +// StreamNames indicates an expected call of StreamNames. +func (mr *MockJetStreamContextInterfaceMockRecorder) StreamNames(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamNames", reflect.TypeOf((*MockJetStreamContextInterface)(nil).StreamNames), opts...) +} + +// Streams mocks base method. +func (m *MockJetStreamContextInterface) Streams(opts ...nats_go.JSOpt) <-chan *nats_go.StreamInfo { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Streams", varargs...) + ret0, _ := ret[0].(<-chan *nats_go.StreamInfo) + return ret0 +} + +// Streams indicates an expected call of Streams. +func (mr *MockJetStreamContextInterfaceMockRecorder) Streams(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Streams", reflect.TypeOf((*MockJetStreamContextInterface)(nil).Streams), opts...) +} + +// StreamsInfo mocks base method. +func (m *MockJetStreamContextInterface) StreamsInfo(opts ...nats_go.JSOpt) <-chan *nats_go.StreamInfo { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "StreamsInfo", varargs...) + ret0, _ := ret[0].(<-chan *nats_go.StreamInfo) + return ret0 +} + +// StreamsInfo indicates an expected call of StreamsInfo. +func (mr *MockJetStreamContextInterfaceMockRecorder) StreamsInfo(opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamsInfo", reflect.TypeOf((*MockJetStreamContextInterface)(nil).StreamsInfo), opts...) +} + +// Subscribe mocks base method. +func (m *MockJetStreamContextInterface) Subscribe(subj string, cb nats_go.MsgHandler, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj, cb} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Subscribe", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Subscribe indicates an expected call of Subscribe. +func (mr *MockJetStreamContextInterfaceMockRecorder) Subscribe(subj, cb interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj, cb}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Subscribe", reflect.TypeOf((*MockJetStreamContextInterface)(nil).Subscribe), varargs...) +} + +// SubscribeSync mocks base method. +func (m *MockJetStreamContextInterface) SubscribeSync(subj string, opts ...nats_go.SubOpt) (*nats_go.Subscription, error) { + m.ctrl.T.Helper() + varargs := []interface{}{subj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SubscribeSync", varargs...) + ret0, _ := ret[0].(*nats_go.Subscription) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SubscribeSync indicates an expected call of SubscribeSync. +func (mr *MockJetStreamContextInterfaceMockRecorder) SubscribeSync(subj interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{subj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeSync", reflect.TypeOf((*MockJetStreamContextInterface)(nil).SubscribeSync), varargs...) +} + +// UpdateConsumer mocks base method. +func (m *MockJetStreamContextInterface) UpdateConsumer(stream string, cfg *nats_go.ConsumerConfig, opts ...nats_go.JSOpt) (*nats_go.ConsumerInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{stream, cfg} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateConsumer", varargs...) + ret0, _ := ret[0].(*nats_go.ConsumerInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateConsumer indicates an expected call of UpdateConsumer. +func (mr *MockJetStreamContextInterfaceMockRecorder) UpdateConsumer(stream, cfg interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{stream, cfg}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateConsumer", reflect.TypeOf((*MockJetStreamContextInterface)(nil).UpdateConsumer), varargs...) +} + +// UpdateStream mocks base method. +func (m *MockJetStreamContextInterface) UpdateStream(cfg *nats_go.StreamConfig, opts ...nats_go.JSOpt) (*nats_go.StreamInfo, error) { + m.ctrl.T.Helper() + varargs := []interface{}{cfg} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateStream", varargs...) + ret0, _ := ret[0].(*nats_go.StreamInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateStream indicates an expected call of UpdateStream. +func (mr *MockJetStreamContextInterfaceMockRecorder) UpdateStream(cfg interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{cfg}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStream", reflect.TypeOf((*MockJetStreamContextInterface)(nil).UpdateStream), varargs...) +} From d876212fa54f3b26ffe46ac0de4b7a9d736bf2b0 Mon Sep 17 00:00:00 2001 From: an1l4 <1995anila@gmail.com> Date: Wed, 8 May 2024 16:28:11 +0530 Subject: [PATCH 03/10] kuberhealthy and outdated plugin unit test added --- agent/kubviz/plugins/ketall/ketall_test.go | 338 ++--- .../plugins/kuberhealthy/kuberhealthy_test.go | 434 ++++++ .../kubviz/plugins/outdated/outdated_test.go | 1173 +++++++++++++++++ 3 files changed, 1776 insertions(+), 169 deletions(-) create mode 100644 agent/kubviz/plugins/kuberhealthy/kuberhealthy_test.go create mode 100644 agent/kubviz/plugins/outdated/outdated_test.go diff --git a/agent/kubviz/plugins/ketall/ketall_test.go b/agent/kubviz/plugins/ketall/ketall_test.go index 836f9b23..3da5d46f 100644 --- a/agent/kubviz/plugins/ketall/ketall_test.go +++ b/agent/kubviz/plugins/ketall/ketall_test.go @@ -29,6 +29,175 @@ type Resource struct { ClusterName string `json:"clusterName"` } +func TestPublishAllResources(t *testing.T) { + mockResource := model.Resource{ + Resource: "test-resource", + Kind: "test-kind", + Namespace: "test-namespace", + Age: "test-age", + ClusterName: "test-cluster", + } + tests := []struct { + name string + resource model.Resource + }{ + {"success", mockResource}, + {"error", model.Resource{}}, + } + for _, tt := range tests { + mockJS := &MockJetStreamContext{} + + mockPublish := gomonkey.ApplyMethod( + reflect.TypeOf(mockJS), + "Publish", + func(*MockJetStreamContext, string, []byte, ...nats.PubOpt) (*nats.PubAck, error) { + if tt.name == "error" { + return nil, errors.New("Error in publish") + } + return nil, nil + }, + ) + defer mockPublish.Reset() + + t.Run(tt.name, func(t *testing.T) { + + err := PublishAllResources(tt.resource, mockJS) + if tt.name == "error" { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestGetAllResources(t *testing.T) { + cases := []struct { + name string + isNameSpaceEmpty bool + wantErr bool + PublishAllResourcesErr bool + }{ + {"success with namespace", false, false, false}, + {"success without namespace", true, false, false}, + {"error in NewForConfig", false, true, false}, + } + + for _, tt := range cases { + mockConfig := &rest.Config{} + mockJS := &MockJetStreamContext{} + mockDC := &discovery.DiscoveryClient{} + mockGroupVersionResource := schema.GroupVersionResource{ + Group: "group", + Version: "version", + Resource: "resource", + } + mockgvrs := make(map[schema.GroupVersionResource]struct{}) + mockgvrs[mockGroupVersionResource] = struct{}{} + mockList := &unstructured.UnstructuredList{ + Items: []unstructured.Unstructured{ + { + Object: map[string]interface{}{ + "apiVersion": "group/version", + "kind": "resource", + }, + }, + }, + } + mockDyC := &dynamic.DynamicClient{} + mockNamespace := &MockNamespaceableResourceInterface{} + mockResourceInterface := &MockResourceInterface{} + + patchNewDiscovery := gomonkey.ApplyFunc( + discovery.NewDiscoveryClientForConfigOrDie, + func(*rest.Config) *discovery.DiscoveryClient { + return mockDC + }, + ) + defer patchNewDiscovery.Reset() + + if tt.wantErr { + patchNewDynamic := gomonkey.ApplyFunc( + dynamic.NewForConfig, + func(*rest.Config) (*dynamic.DynamicClient, error) { + return nil, errors.New("new dynamic client error") + }, + ) + defer patchNewDynamic.Reset() + } + + patchResourceLists := gomonkey.ApplyMethod( + reflect.TypeOf(mockDC), + "ServerPreferredResources", + func(*discovery.DiscoveryClient) ([]*metav1.APIResourceList, error) { + return []*metav1.APIResourceList{}, nil + }, + ) + defer patchResourceLists.Reset() + + patchgvrs := gomonkey.ApplyFunc( + discovery.GroupVersionResources, + func([]*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error) { + return mockgvrs, nil + }, + ) + defer patchgvrs.Reset() + + mockDynamicResourceInterface := &MockNamespaceableResourceInterface{} + patchResource := gomonkey.ApplyMethod( + reflect.TypeOf(mockDyC), + "Resource", + func(*dynamic.DynamicClient, schema.GroupVersionResource) dynamic.NamespaceableResourceInterface { + return mockDynamicResourceInterface + }, + ) + defer patchResource.Reset() + + patchNamespace := gomonkey.ApplyMethod( + reflect.TypeOf(mockNamespace), + "Namespace", + func(*MockNamespaceableResourceInterface, string) dynamic.ResourceInterface { + return mockResourceInterface + }, + ) + defer patchNamespace.Reset() + + patchList := gomonkey.ApplyMethod( + reflect.TypeOf(mockResourceInterface), + "List", + func(*MockResourceInterface, context.Context, metav1.ListOptions) (*unstructured.UnstructuredList, error) { + return mockList, nil + }, + ) + defer patchList.Reset() + + mockItem := &unstructured.Unstructured{} + patchGetNamespace := gomonkey.ApplyMethod( + reflect.TypeOf(mockItem), + "GetNamespace", + func(*unstructured.Unstructured) string { + if tt.isNameSpaceEmpty { + return "" + } + return "default" + }, + ) + defer patchGetNamespace.Reset() + + t.Run(tt.name, func(t *testing.T) { + err := GetAllResources(mockConfig, mockJS) + fmt.Println("Error in GetAllResources: ", err) + if tt.wantErr { + require.Error(t, err) + } else if tt.isNameSpaceEmpty { + require.NoError(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + type MockJetStreamContext struct{} func (m *MockJetStreamContext) AccountInfo(opts ...nats.JSOpt) (*nats.AccountInfo, error) { @@ -262,48 +431,6 @@ func (m *MockNamespaceableResourceInterface) Namespace(s string) dynamic.Resourc return &MockResourceInterface{} } -func TestPublishAllResources(t *testing.T) { - mockResource := model.Resource{ - Resource: "test-resource", - Kind: "test-kind", - Namespace: "test-namespace", - Age: "test-age", - ClusterName: "test-cluster", - } - tests := []struct { - name string - resource model.Resource - }{ - {"success", mockResource}, - {"error", model.Resource{}}, - } - for _, tt := range tests { - mockJS := &MockJetStreamContext{} - - mockPublish := gomonkey.ApplyMethod( - reflect.TypeOf(mockJS), - "Publish", - func(*MockJetStreamContext, string, []byte, ...nats.PubOpt) (*nats.PubAck, error) { - if tt.name == "error" { - return nil, errors.New("Error in publish") - } - return nil, nil - }, - ) - defer mockPublish.Reset() - - t.Run(tt.name, func(t *testing.T) { - - err := PublishAllResources(tt.resource, mockJS) - if tt.name == "error" { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - type MockDynamicResource struct { FnList func(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) FnApply func(ctx context.Context, namespace string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) @@ -376,130 +503,3 @@ func LegacyAPIPathResolverFunc(kind schema.GroupVersionKind) string { } return "/apis" } - -func TestGetAllResources2(t *testing.T) { - cases := []struct { - name string - isNameSpaceEmpty bool - wantErr bool - PublishAllResourcesErr bool - }{ - {"success with namespace", false, false, false}, - {"success without namespace", true, false, false}, - {"error in NewForConfig", false, true, false}, - } - - for _, tt := range cases { - mockConfig := &rest.Config{} - mockJS := &MockJetStreamContext{} - mockDC := &discovery.DiscoveryClient{} - mockGroupVersionResource := schema.GroupVersionResource{ - Group: "group", - Version: "version", - Resource: "resource", - } - mockgvrs := make(map[schema.GroupVersionResource]struct{}) - mockgvrs[mockGroupVersionResource] = struct{}{} - mockList := &unstructured.UnstructuredList{ - Items: []unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "apiVersion": "group/version", - "kind": "resource", - }, - }, - }, - } - mockDyC := &dynamic.DynamicClient{} - mockNamespace := &MockNamespaceableResourceInterface{} - mockResourceInterface := &MockResourceInterface{} - - patchNewDiscovery := gomonkey.ApplyFunc( - discovery.NewDiscoveryClientForConfigOrDie, - func(*rest.Config) *discovery.DiscoveryClient { - return mockDC - }, - ) - defer patchNewDiscovery.Reset() - - if tt.wantErr { - patchNewDynamic := gomonkey.ApplyFunc( - dynamic.NewForConfig, - func(*rest.Config) (*dynamic.DynamicClient, error) { - return nil, errors.New("new dynamic client error") - }, - ) - defer patchNewDynamic.Reset() - } - - patchResourceLists := gomonkey.ApplyMethod( - reflect.TypeOf(mockDC), - "ServerPreferredResources", - func(*discovery.DiscoveryClient) ([]*metav1.APIResourceList, error) { - return []*metav1.APIResourceList{}, nil - }, - ) - defer patchResourceLists.Reset() - - patchgvrs := gomonkey.ApplyFunc( - discovery.GroupVersionResources, - func([]*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error) { - return mockgvrs, nil - }, - ) - defer patchgvrs.Reset() - - mockDynamicResourceInterface := &MockNamespaceableResourceInterface{} - patchResource := gomonkey.ApplyMethod( - reflect.TypeOf(mockDyC), - "Resource", - func(*dynamic.DynamicClient, schema.GroupVersionResource) dynamic.NamespaceableResourceInterface { - return mockDynamicResourceInterface - }, - ) - defer patchResource.Reset() - - patchNamespace := gomonkey.ApplyMethod( - reflect.TypeOf(mockNamespace), - "Namespace", - func(*MockNamespaceableResourceInterface, string) dynamic.ResourceInterface { - return mockResourceInterface - }, - ) - defer patchNamespace.Reset() - - patchList := gomonkey.ApplyMethod( - reflect.TypeOf(mockResourceInterface), - "List", - func(*MockResourceInterface, context.Context, metav1.ListOptions) (*unstructured.UnstructuredList, error) { - return mockList, nil - }, - ) - defer patchList.Reset() - - mockItem := &unstructured.Unstructured{} - patchGetNamespace := gomonkey.ApplyMethod( - reflect.TypeOf(mockItem), - "GetNamespace", - func(*unstructured.Unstructured) string { - if tt.isNameSpaceEmpty { - return "" - } - return "default" - }, - ) - defer patchGetNamespace.Reset() - - t.Run(tt.name, func(t *testing.T) { - err := GetAllResources(mockConfig, mockJS) - fmt.Println("Error in GetAllResources: ", err) - if tt.wantErr { - require.Error(t, err) - } else if tt.isNameSpaceEmpty { - require.NoError(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/agent/kubviz/plugins/kuberhealthy/kuberhealthy_test.go b/agent/kubviz/plugins/kuberhealthy/kuberhealthy_test.go new file mode 100644 index 00000000..c3b6fc31 --- /dev/null +++ b/agent/kubviz/plugins/kuberhealthy/kuberhealthy_test.go @@ -0,0 +1,434 @@ +package kuberhealthy + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "log" + "net/http" + "net/http/httptest" + "os" + "sync" + "testing" + "time" + + "github.com/agiledragon/gomonkey" + "github.com/intelops/kubviz/agent/config" + khstatev1 "github.com/kuberhealthy/kuberhealthy/v2/pkg/apis/khstate/v1" + "github.com/kuberhealthy/kuberhealthy/v2/pkg/health" + "github.com/nats-io/nats.go" + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +//Before running this test, go to agent/config/config.go file +//make sure set KHConfig put a default url and 0.01s poll interval +//example below +//type KHConfig struct { +//KuberhealthyURL string `envconfig:"KUBERHEALTHY_URL" required:"true" default:"test.com"` +//PollInterval time.Duration `envconfig:"POLL_INTERVAL" default:"0.01s"` +//} + +func TestStartKuberhealthy(t *testing.T) { + cases := []struct { + name string + wantErr bool + publishErr bool + }{ + {"success", false, false}, + {"failure in pollAndPublishKuberhealthy", false, true}, + } + for _, tt := range cases { + log.Println("Running test case: ", tt.name) + t.Run(tt.name, func(t *testing.T) { + mockJS := &MockJetStreamContext{} + + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mockResponse := `{"status": "ok"}` + w.Header().Set("Content-Type", "application/json") + fmt.Fprintln(w, mockResponse) + })) + defer testServer.Close() + + mockConfig := &config.KHConfig{ + PollInterval: time.Second * 1, + KuberhealthyURL: testServer.URL, + } + mockosexit := gomonkey.ApplyFunc(os.Exit, func(int) { + + }) + defer mockosexit.Reset() + + patchkhConfig := gomonkey.ApplyFunc( + config.GetKuberHealthyConfig, + func() (*config.KHConfig, error) { + log.Println("before tt.wantErr####", tt.wantErr) + if tt.wantErr { + log.Println(tt.name, "******") + return nil, errors.New("err") + } + return mockConfig, nil + }, + ) + defer patchkhConfig.Reset() + + mockTicker := time.NewTicker(time.Second * 10) + patchticker := gomonkey.ApplyFunc( + time.NewTicker, + func(time.Duration) *time.Ticker { + return mockTicker + }, + ) + defer patchticker.Reset() + + patchPollAndPublishKuberhealthy := gomonkey.ApplyFunc( + mockPollAndPublishKuberhealthy, + func(string, nats.JetStreamContext) error { + if tt.publishErr { + return errors.New("err") + } + return nil + }, + ) + defer patchPollAndPublishKuberhealthy.Reset() + + patchPublishKuberhealthyMetrics := gomonkey.ApplyFunc( + PublishKuberhealthyMetrics, + func(js nats.JetStreamContext, state health.State) error { + return nil + }, + ) + defer patchPublishKuberhealthyMetrics.Reset() + + wg := sync.WaitGroup{} + wg.Add(1) + + go func() { + defer wg.Done() + StartKuberHealthy(mockJS) + }() + if tt.wantErr { + t.Fatalf("Error getting Kuberhealthy config1: err") + + } + }) + } + +} + +func TestPollAndPublishKuberhealthy(t *testing.T) { + cases := []struct { + name string + wantErr bool + getErr bool + unMarshalErr bool + }{ + {"success", false, false, false}, + {"failure readAll", true, false, false}, + {"failure unMarshal", false, false, true}, + } + + for _, tt := range cases { + log.Println("Running test case: ", tt.name) + t.Run(tt.name, func(t *testing.T) { + mockJS := &MockJetStreamContext{} + if tt.wantErr { + patchReadAll := gomonkey.ApplyFunc( + io.ReadAll, + func(io.Reader) ([]byte, error) { + return nil, errors.New("err") + }, + ) + defer patchReadAll.Reset() + } + if tt.getErr { + patchGet := gomonkey.ApplyFunc( + http.Get, + func(string) (*http.Response, error) { + return nil, errors.New("err") + }, + ) + defer patchGet.Reset() + } + + if tt.unMarshalErr { + patchUnmarshal := gomonkey.ApplyFunc( + json.Unmarshal, + func([]byte, interface{}) error { + return errors.New("err") + }, + ) + defer patchUnmarshal.Reset() + } + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mockState := health.State{ + OK: true, + } + mockStateJSON, _ := json.Marshal(mockState) + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + w.Write(mockStateJSON) + })) + defer ts.Close() + + err := pollAndPublishKuberhealthy(ts.URL, mockJS) + if tt.wantErr { + assert.Error(t, err) + } else if tt.getErr { + assert.Error(t, err) + } else if tt.unMarshalErr { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + }) + } + +} + +var mockhealthstate health.State + +func TestPublishKuberhealthyMetrics(t *testing.T) { + + mockJS := &MockJetStreamContext{} + + dummyWorkloadDetails := khstatev1.WorkloadDetails{ + OK: true, + Errors: []string{"No errors"}, + RunDuration: "1s", + Namespace: "default", + Node: "node1", + LastRun: &metav1.Time{Time: time.Now()}, + AuthoritativePod: "pod1", + CurrentUUID: "12345678-1234-1234-1234-123456789abc", + } + mockResource := health.State{ + OK: true, + CheckDetails: map[string]khstatev1.WorkloadDetails{ + "dummyCheck": dummyWorkloadDetails, + }, + JobDetails: map[string]khstatev1.WorkloadDetails{ + "dummyJob": dummyWorkloadDetails, + }, + CurrentMaster: "master1", + } + + tests := []struct { + name string + resource health.State + }{ + {"success", mockResource}, + {"error", health.State{ + OK: false, + CheckDetails: map[string]khstatev1.WorkloadDetails{ + "dummyCheck": dummyWorkloadDetails, + }, + JobDetails: map[string]khstatev1.WorkloadDetails{ + "dummyJob": dummyWorkloadDetails, + }, + CurrentMaster: "master1", + }}, + } + + for i, tt := range tests { + fmt.Println("Running test : ", i) + t.Run(tt.name, func(t *testing.T) { + + err := PublishKuberhealthyMetrics(mockJS, tt.resource) + if tt.name == "success" { + + assert.NoError(t, err) + + assert.NoError(t, err, "PublishKuberhealthyMetrics() returned an error") + + assert.Equal(t, mockResource.CurrentMaster, "master1", "CurrentMaster doesn't match") + } else { + fmt.Println("Error in Publish error: ", err) + assert.EqualError(t, err, "Error in publish") + } + }) + } + + PublishKuberhealthyMetrics(mockJS, mockhealthstate) +} + +type MockJetStreamContext struct{} + +func (m *MockJetStreamContext) AccountInfo(opts ...nats.JSOpt) (*nats.AccountInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) AddConsumer(stream string, cfg *nats.ConsumerConfig, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} +func (m *MockJetStreamContext) AddStream(cfg *nats.StreamConfig, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ChanQueueSubscribe(subj, queue string, ch chan *nats.Msg, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ChanSubscribe(subj string, ch chan *nats.Msg, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ConsumerInfo(stream, consumer string, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} +func (m *MockJetStreamContext) ConsumerNames(stream string, opts ...nats.JSOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) Consumers(stream string, opts ...nats.JSOpt) <-chan *nats.ConsumerInfo { + return nil +} + +func (m *MockJetStreamContext) ConsumersInfo(stream string, opts ...nats.JSOpt) <-chan *nats.ConsumerInfo { + return nil +} + +func (m *MockJetStreamContext) CreateKeyValue(kv *nats.KeyValueConfig) (nats.KeyValue, error) { + return nil, nil +} + +func (m *MockJetStreamContext) CreateObjectStore(store *nats.ObjectStoreConfig) (nats.ObjectStore, error) { + return nil, nil +} +func (m *MockJetStreamContext) DeleteConsumer(stream, consumer string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) DeleteKeyValue(key string) error { + return nil +} + +func (m *MockJetStreamContext) DeleteMsg(stream string, seq uint64, opts ...nats.JSOpt) error { + return nil +} +func (m *MockJetStreamContext) DeleteObjectStore(store string) error { + return nil +} + +func (m *MockJetStreamContext) DeleteStream(stream string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) GetLastMsg(stream string, lastBy string, opts ...nats.JSOpt) (*nats.RawStreamMsg, error) { + return nil, nil +} +func (m *MockJetStreamContext) GetMsg(stream string, seq uint64, opts ...nats.JSOpt) (*nats.RawStreamMsg, error) { + return nil, nil +} + +func (m *MockJetStreamContext) KeyValue(stream string) (nats.KeyValue, error) { + return nil, nil +} + +func (m *MockJetStreamContext) KeyValueStoreNames() <-chan string { + return nil +} +func (m *MockJetStreamContext) KeyValueStores() <-chan nats.KeyValueStatus { + return nil +} + +func (m *MockJetStreamContext) ObjectStore(stream string) (nats.ObjectStore, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ObjectStoreNames(opts ...nats.ObjectOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) ObjectStores(opts ...nats.ObjectOpt) <-chan nats.ObjectStoreStatus { + return nil +} + +func (m *MockJetStreamContext) PublishAsync(subj string, data []byte, opts ...nats.PubOpt) (nats.PubAckFuture, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PublishAsyncComplete() <-chan struct{} { + return nil +} +func (m *MockJetStreamContext) PublishAsyncPending() int { + return 0 +} + +func (m *MockJetStreamContext) PublishMsg(msg *nats.Msg, opts ...nats.PubOpt) (*nats.PubAck, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PublishMsgAsync(msg *nats.Msg, opts ...nats.PubOpt) (nats.PubAckFuture, error) { + return nil, nil +} +func (m *MockJetStreamContext) PullSubscribe(subject, queue string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PurgeStream(stream string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) QueueSubscribe(subject, queue string, handler nats.MsgHandler, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) Publish(subj string, data []byte, opts ...nats.PubOpt) (*nats.PubAck, error) { + resource := &health.State{} + json.Unmarshal(data, resource) + if resource.OK == false { + return nil, errors.New("Error in publish") + } + return nil, nil +} + +func (m *MockJetStreamContext) QueueSubscribeSync(subject, queue string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) SecureDeleteMsg(stream string, seq uint64, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) StreamInfo(stream string, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) StreamNameBySubject(subject string, opts ...nats.JSOpt) (string, error) { + return "", nil +} + +func (m *MockJetStreamContext) StreamNames(opts ...nats.JSOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) Streams(opts ...nats.JSOpt) <-chan *nats.StreamInfo { + return nil +} + +func (m *MockJetStreamContext) StreamsInfo(opts ...nats.JSOpt) <-chan *nats.StreamInfo { + return nil +} + +func (m *MockJetStreamContext) Subscribe(subject string, cb nats.MsgHandler, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) SubscribeSync(subject string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) UpdateConsumer(stream string, cfg *nats.ConsumerConfig, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) UpdateStream(cfg *nats.StreamConfig, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func mockPollAndPublishKuberhealthy(url string, js nats.JetStreamContext) error { + return nil +} diff --git a/agent/kubviz/plugins/outdated/outdated_test.go b/agent/kubviz/plugins/outdated/outdated_test.go new file mode 100644 index 00000000..7c3d5fff --- /dev/null +++ b/agent/kubviz/plugins/outdated/outdated_test.go @@ -0,0 +1,1173 @@ +package outdated + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "reflect" + "sort" + "testing" + "time" + + "github.com/agiledragon/gomonkey" + "github.com/docker/distribution/manifest/schema1" + "github.com/genuinetools/reg/registry" + "github.com/hashicorp/go-version" + semver "github.com/hashicorp/go-version" + "github.com/intelops/kubviz/model" + "github.com/nats-io/nats.go" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/rest" +) + +func TestTruncateImageName(t *testing.T) { + input := "docker.io/library/nginx:latest12345678901234567890123456789012345678901234567890" + + result := truncateImageName(input) + + expected := "docker.io/library/nginx:latest12345678901234567..." + if result != expected { + t.Errorf("Expected '%s', but got '%s'", expected, result) + } +} + +func TestTruncateTagName(t *testing.T) { + input := "nginx:latest12345678901234567890123456789012345678901234567890" + + result := truncateTagName(input) + + expected := "nginx:latest12345678901234567890123456789012345..." + if result != expected { + t.Errorf("Expected '%s', but got '%s'", expected, result) + } +} + +func TestPublishOutdatedImages(t *testing.T) { + mockJS := &MockJetStreamContext{} + mockresult := model.CheckResultfinal{ + Image: "test-image", + Current: "test-current", + LatestVersion: "test-latest", + VersionsBehind: 23, + Pod: "test-pod", + Namespace: "test-namespace", + ClusterName: "test-cluster", + } + PublishOutdatedImages(mockresult, mockJS) +} + +func TestOutDatedImages(t *testing.T) { + cases := []struct { + name string + parseImgErr bool + listImgErr bool + isVersionNegative bool + }{ + {"success", false, false, false}, + {"parse image error", true, false, false}, + {"list image error", false, true, false}, + {"list image error -1", false, false, true}, + } + + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + + fmt.Println("test case", tt.name) + + mockConfig := &rest.Config{} + mockJS := &MockJetStreamContext{} + + mockInitContainer := "test-initcontainer" + mockContainer := "test-container" + mockImages := []model.RunningImage{ + { + Namespace: "test-namespace", + Pod: "test-pod", + Image: "test-image", + InitContainer: &mockInitContainer, + Container: &mockContainer, + PullableImage: "test-latest", + }, + } + patchImages := gomonkey.ApplyFunc( + ListImages, + func(config *rest.Config) ([]model.RunningImage, error) { + if tt.listImgErr { + return nil, errors.New("list image error") + } + return mockImages, nil + }, + ) + defer patchImages.Reset() + + mockCheckResult1 := model.CheckResult{ + IsAccessible: true, + LatestVersion: "test-latest", + VersionsBehind: 23, + CheckError: "test-error", + Path: "test-path", + } + mockCheckResult2 := model.CheckResult{ + IsAccessible: true, + LatestVersion: "test-latest", + VersionsBehind: -1, + CheckError: "test-error", + Path: "test-path", + } + patchcheckresult := gomonkey.ApplyFunc( + ParseImage, + func(string, string) (*model.CheckResult, error) { + if tt.parseImgErr { + return nil, errors.New("parse image error") + } else if tt.isVersionNegative { + return &mockCheckResult2, nil + } + return &mockCheckResult1, nil + }, + ) + defer patchcheckresult.Reset() + + patchImageName := gomonkey.ApplyFunc( + ParseImageName, + func(string) (string, string, string, error) { + if tt.parseImgErr { + return "", "", "", errors.New("parse image error") + } + return "", "", "", nil + }, + ) + defer patchImageName.Reset() + + patchPublishOutdatedImages := gomonkey.ApplyFunc( + PublishOutdatedImages, + func(model.CheckResultfinal, nats.JetStreamContext) error { + return nil + }, + ) + defer patchPublishOutdatedImages.Reset() + + error := OutDatedImages(mockConfig, mockJS) + if tt.listImgErr { + require.Error(t, error) + } else if tt.parseImgErr { + require.NoError(t, error) + } else if tt.isVersionNegative { + require.NoError(t, error) + } else { + require.NoError(t, error) + } + + }) + } +} + +func TestParseImageName(t *testing.T) { + url, image, tag, err := ParseImageName("redis:4") + require.NoError(t, err) + assert.Equal(t, "index.docker.io", url) + assert.Equal(t, "library/redis", image) + assert.Equal(t, "4", tag) + + url, image, tag, err = ParseImageName("k8s.gcr.io/cluster-proportional-autoscaler-amd64:1.1.2-r2") + require.NoError(t, err) + assert.Equal(t, "k8s.gcr.io", url) + assert.Equal(t, "library/cluster-proportional-autoscaler-amd64", image) + assert.Equal(t, "1.1.2-r2", tag) + + url, image, tag, err = ParseImageName("quay.io/coreos/grafana-watcher:v0.0.8") + require.NoError(t, err) + assert.Equal(t, "quay.io", url) + assert.Equal(t, "coreos/grafana-watcher", image) + assert.Equal(t, "v0.0.8", tag) + + url, image, tag, err = ParseImageName("grafana/grafana:5.0.1") + require.NoError(t, err) + assert.Equal(t, "index.docker.io", url) + assert.Equal(t, "grafana/grafana", image) + assert.Equal(t, "5.0.1", tag) + + url, image, tag, err = ParseImageName("postgres:10.0") + require.NoError(t, err) + assert.Equal(t, "index.docker.io", url) + assert.Equal(t, "library/postgres", image) + assert.Equal(t, "10.0", tag) + + url, image, tag, err = ParseImageName("localhost:32000/postgres:10.0") + require.NoError(t, err) + assert.Equal(t, "localhost:32000", url) + assert.Equal(t, "library/postgres", image) + assert.Equal(t, "10.0", tag) +} + +func TestParseImage(t *testing.T) { + cases := []struct { + name string + parseImgErr bool + registryClientErr bool + tagsErr bool + parsTagsErr bool + }{ + {"success", false, false, false, false}, + {"parse image error", true, false, false, false}, + {"registry client error", false, true, false, false}, + {"fetch tags error", false, false, true, false}, + {"pars tags error", false, false, false, true}, + } + + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + + patchImageName := gomonkey.ApplyFunc( + ParseImageName, + func(string) (string, string, string, error) { + if tt.parseImgErr { + return "", "", "", errors.New("parse image error") + } + return "", "", "", nil + }, + ) + defer patchImageName.Reset() + + patchRegistryClient := gomonkey.ApplyFunc( + initRegistryClient, + func(string) (*registry.Registry, error) { + if tt.registryClientErr { + return nil, errors.New("registry client error") + } + return ®istry.Registry{}, nil + }, + ) + defer patchRegistryClient.Reset() + + patchTags := gomonkey.ApplyFunc( + fetchTags, + func(*registry.Registry, string) ([]string, error) { + if tt.tagsErr { + return nil, errors.New("fetch tags error") + } + return []string{"test-tag"}, nil + }, + ) + defer patchTags.Reset() + + mockVersion := semver.Version{} + + patchParseTags := gomonkey.ApplyFunc( + parseTags, + func([]string) ([]*semver.Version, []string, error) { + if tt.parsTagsErr { + return nil, nil, errors.New("parse tags error") + } + return []*semver.Version{ + &mockVersion, + }, []string{"test-tag"}, nil + }, + ) + defer patchParseTags.Reset() + + patchNewVersion := gomonkey.ApplyFunc( + semver.NewVersion, + func(string) (*semver.Version, error) { + return &mockVersion, nil + }, + ) + defer patchNewVersion.Reset() + + patchParseNonServerImage := gomonkey.ApplyFunc( + parseNonSemverImage, + func(*registry.Registry, string, string, []string) (*model.CheckResult, error) { + return &model.CheckResult{}, nil + }, + ) + defer patchParseNonServerImage.Reset() + + mocksemvertags := []*semver.Version{} + collection := SemverTagCollection(mocksemvertags) + + mockSemverVersion := &semver.Version{} + + patchRemoveLeastspecific := gomonkey.ApplyMethod( + reflect.TypeOf(collection), + "RemoveLeastSpecific", + func(collection SemverTagCollection) []*semver.Version { + return []*semver.Version{ + mockSemverVersion, + } + }, + ) + defer patchRemoveLeastspecific.Reset() + + patchversionbehind := gomonkey.ApplyMethod( + reflect.TypeOf(collection), + "VersionsBehind", + func(collection SemverTagCollection, detected *semver.Version) ([]*semver.Version, error) { + return []*semver.Version{}, nil + }, + ) + defer patchversionbehind.Reset() + + patchresolvetagdata := gomonkey.ApplyFunc( + resolveTagDates, + func(*registry.Registry, string, []*semver.Version) ([]*VersionTag, error) { + return []*VersionTag{}, nil + }, + ) + defer patchresolvetagdata.Reset() + + resp, err := ParseImage("image", "pullableImage") + if tt.parseImgErr { + require.Error(t, err) + require.Nil(t, resp) + } else if tt.registryClientErr { + require.NoError(t, err) + } else if tt.tagsErr { + require.Error(t, err) + } else if tt.parsTagsErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.NotNil(t, resp) + require.Equal(t, "", resp.LatestVersion) + require.Equal(t, int64(0), resp.VersionsBehind) + if resp.LatestVersion == "" { + require.Equal(t, "", resp.LatestVersion) + require.Equal(t, int64(0), resp.VersionsBehind) + } else { + require.NotEqual(t, "", resp.LatestVersion) + require.NotEqual(t, int64(-1), resp.VersionsBehind) + } + } + + }) + } +} + +func TestParseNonSemverImage(t *testing.T) { + cases := []struct { + name string + dateErr bool + parseErr bool + }{ + {"success", false, false}, + {"date error", true, false}, + {"parse error", false, true}, + } + + for _, tt := range cases { + mockRegistry := ®istry.Registry{} + + patchgetTagDate := gomonkey.ApplyFunc( + getTagDate, + func(*registry.Registry, string, string) (string, error) { + if tt.dateErr { + return "", errors.New("date error") + } + return "", nil + }, + ) + defer patchgetTagDate.Reset() + + patchParse := gomonkey.ApplyFunc( + time.Parse, + func(string, string) (time.Time, error) { + if tt.parseErr { + return time.Time{}, errors.New("parse error") + } + return time.Now(), nil + }, + ) + defer patchParse.Reset() + + t.Run(tt.name, func(t *testing.T) { + resp, err := parseNonSemverImage(mockRegistry, "image", "tag", []string{"test-tag"}) + if tt.dateErr { + require.NoError(t, err) + } else if tt.parseErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.NotNil(t, resp) + } + }) + } +} + +func TestInitRegistryClient(t *testing.T) { + initRegistryClient("docker.io") +} + +func TestFetchTags(t *testing.T) { + mockConfig := ®istry.Registry{} + cases := []struct { + name string + wantErr bool + }{ + {"success", false}, + {"error", true}, + } + + for _, tt := range cases { + patchTags := gomonkey.ApplyMethod( + reflect.TypeOf(mockConfig), + "Tags", + func(*registry.Registry, context.Context, string) ([]string, error) { + if tt.wantErr { + return nil, errors.New("fetch tags error") + } + return []string{"test-tag"}, nil + }, + ) + defer patchTags.Reset() + + t.Run(tt.name, func(t *testing.T) { + _, err := fetchTags(mockConfig, "test-image") + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestParseTags(t *testing.T) { + cases := []struct { + name string + wantErr bool + }{ + {"success", false}, + {"error", true}, + } + + for _, tt := range cases { + + patchv := gomonkey.ApplyFunc( + semver.NewVersion, + func(string) (*semver.Version, error) { + return nil, errors.New("parse error") + }, + ) + defer patchv.Reset() + + patchsplit := gomonkey.ApplyFunc( + splitOutlierSemvers, + func([]*semver.Version) ([]*semver.Version, []*semver.Version, error) { + return []*semver.Version{}, []*semver.Version{}, nil + }, + ) + + defer patchsplit.Reset() + + t.Run(tt.name, func(t *testing.T) { + _, _, err := parseTags([]string{"test-tag"}) + if tt.wantErr { + require.NoError(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestSplitOutlierSemvers(t *testing.T) { + + cases := []struct { + name string + wantErr bool + }{ + {"success", false}, + } + + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + _, _, err := splitOutlierSemvers(makeVersions([]string{"1.0", "1.1", "1.2"})) + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestSemverTagCollection_Swap(t *testing.T) { + // Create a sample collection + collection := SemverTagCollection{ + version.Must(version.NewVersion("1.0.0")), + version.Must(version.NewVersion("2.0.0")), + version.Must(version.NewVersion("3.0.0")), + } + + // Swap elements at indices 0 and 2 + collection.Swap(0, 2) + + // Assert that the elements have been swapped + assert.Equal(t, "3.0.0", collection[0].String()) + assert.Equal(t, "2.0.0", collection[1].String()) + assert.Equal(t, "1.0.0", collection[2].String()) + + // Swap elements at indices 1 and 1 (no change) + collection.Swap(1, 1) + + // Assert that the collection remains unchanged + assert.Equal(t, "3.0.0", collection[0].String()) + assert.Equal(t, "2.0.0", collection[1].String()) + assert.Equal(t, "1.0.0", collection[2].String()) +} + +func makeVersions(versions []string) []*semver.Version { + allVersions := make([]*semver.Version, 0) + for _, version := range versions { + v, _ := semver.NewVersion(version) + allVersions = append(allVersions, v) + } + return allVersions +} + +func makeOriginal(versions []*semver.Version) []string { + allVersions := make([]string, 0) + for _, version := range versions { + v := version.Original() + allVersions = append(allVersions, v) + } + return allVersions +} + +func TestRemoveLeastSpecific(t *testing.T) { + tests := []struct { + name string + versions []string + expectVersions []string + }{ + { + name: "major", + versions: []string{"1.0", "1.1", "1.2", "1"}, + expectVersions: []string{"1.0", "1.1", "1.2"}, + }, + { + name: "zeros", + versions: []string{"1.0", "1"}, + expectVersions: []string{"1.0"}, + }, + { + name: "minor", + versions: []string{"0.1.1", "0.1.2", "0.1"}, + expectVersions: []string{"0.1.1", "0.1.2"}, + }, + { + name: "patch", + versions: []string{"0.2.1", "0.2.2", "0.2.3"}, + expectVersions: []string{"0.2.1", "0.2.2", "0.2.3"}, + }, + { + name: "similar version numbers", + versions: []string{"0.11.1", "0.11", "11.0"}, + expectVersions: []string{"0.11.1", "11.0"}, + }, + { + name: "different versions", + versions: []string{"0.1", "2.1"}, + expectVersions: []string{"0.1", "2.1"}, + }, + { + name: "include last", + versions: []string{"0.1", "0.2.1", "0.3.4", "0.4"}, + expectVersions: []string{"0.1", "0.2.1", "0.3.4", "0.4"}, + }, + { + name: "variety", + versions: []string{"0.1.0", "0.1", "0.2.0", "0.2", "0.10.0", "0.10", "0.11.0", "0.11", "0.13.0", "0.13.1", "0.13.2", "0.13.3", "0.13", "0.17.0", "0.17.1", "0.17", "0.18.0", "0.18", "0.21.0", "0.21", "0"}, + expectVersions: []string{"0.1.0", "0.2.0", "0.10.0", "0.11.0", "0.13.0", "0.13.1", "0.13.2", "0.13.3", "0.17.0", "0.17.1", "0.18.0", "0.21.0"}, + }, + { + name: "preserve major version", + versions: []string{"0.1", "0.2.1", "1", "2", "3.5", "3", "4"}, + expectVersions: []string{"0.1", "0.2.1", "1", "2", "3.5", "4"}, + }, + { + name: "variations", + versions: []string{"1.0.0", "1.0", "1"}, + expectVersions: []string{"1.0.0"}, + }, + { + name: "variations 2", + versions: []string{"0.0.0", "0.0", "0"}, + expectVersions: []string{"0.0.0"}, + }, + { + name: "more segments", + versions: []string{"3.5.1.1", "3.5.1", "4.5.1"}, + expectVersions: []string{"3.5.1.1", "4.5.1"}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + semverTags := makeVersions(test.versions) + collection := SemverTagCollection(semverTags) + tags := collection.RemoveLeastSpecific() + + originalRemoved := makeOriginal(tags) + require.EqualValues(t, test.expectVersions, originalRemoved) + }) + } +} + +func TestTagCollectionUnique(t *testing.T) { + tests := []struct { + name string + versions []string + expectVersions []string + }{ + { + name: "tagged versions", + versions: []string{"1.0.1", "1.0.2", "1.0.1-alpine", "1.0.1-debian"}, + expectVersions: []string{"1.0.1", "1.0.2"}, + }, + { + name: "tagged major version", + versions: []string{"4-alpine", "4"}, + expectVersions: []string{"4"}, + }, + { + name: "different major and minor versions", + versions: []string{"10.4", "9"}, + expectVersions: []string{"9", "10.4"}, + }, + { + name: "different major only versions", + versions: []string{"10", "11"}, + expectVersions: []string{"10", "11"}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + vers := makeVersions(test.versions) + uniqueVers, err := SemverTagCollection(vers).Unique() + require.NoError(t, err) + actualVers := makeOriginal(uniqueVers) + + require.Equal(t, test.expectVersions, actualVers) + }) + } +} + +func TestTagCollectionSort(t *testing.T) { + tests := []struct { + name string + versions []string + expectVersions []string + }{ + { + name: "same major versions", + versions: []string{"10", "10.4"}, + expectVersions: []string{"10", "10.4"}, + }, + { + name: "different major versions", + versions: []string{"10", "11.1"}, + expectVersions: []string{"10", "11.1"}, + }, + { + name: "same major and minor versions", + versions: []string{"9.1.3", "9.1.0", "9.1.4", "9.1"}, + expectVersions: []string{"9.1.0", "9.1", "9.1.3", "9.1.4"}, + }, + { + name: "different major and minor versions", + versions: []string{"10.1.2", "10.0", "10", "10.3.2", "11", "10.1.3", "10.1"}, + expectVersions: []string{"10.0", "10", "10.1", "10.1.2", "10.1.3", "10.3.2", "11"}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + vers := makeVersions(test.versions) + sort.Sort(SemverTagCollection(vers)) + actualVers := makeOriginal(vers) + + require.Equal(t, test.expectVersions, actualVers) + }) + } +} + +func TestCompareVersions(t *testing.T) { + tests := []struct { + name string + versions []string + expect int + }{ + { + name: "major versions match", + versions: []string{"10", "10"}, + expect: 0, + }, + { + name: "major version is less than", + versions: []string{"9", "10"}, + expect: -1, + }, + { + name: "minor versions is less than", + versions: []string{"10.1", "10"}, + expect: 1, + }, + { + name: "minor versions is greater than", + versions: []string{"10.3", "10.1"}, + expect: 1, + }, + { + name: "minor versions match", + versions: []string{"10.1", "10.1"}, + expect: 0, + }, + { + name: "patch versions is less than", + versions: []string{"10.1.2", "10.1.3"}, + expect: -1, + }, + { + name: "patch versions is greater than", + versions: []string{"10.1.4", "10.1.3"}, + expect: 1, + }, + { + name: "patch versions match", + versions: []string{"10.1.2", "10.1.2"}, + expect: 0, + }, + { + name: "major version only with patch", + versions: []string{"10", "10.1.2"}, + expect: -1, + }, + { + name: "minor version greater, patch version less", + versions: []string{"10.2.3", "10.1.4"}, + expect: 1, + }, + { + name: "major version less, minor version greater", + versions: []string{"9.1.2", "10.0.1"}, + expect: -1, + }, + { + name: "major version less, also shorter", + versions: []string{"9.1", "10.2.2"}, + expect: -1, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + vers := makeVersions(test.versions) + + actual := compareVersions(vers[0], vers[1]) + require.Equal(t, test.expect, actual) + + reverse := compareVersions(vers[1], vers[0]) + require.Equal(t, -test.expect, reverse) + }) + } +} + +func TestResolveTagDates(t *testing.T) { + tests := []struct { + name string + hostname string + imageName string + versions []string + }{ + { + name: "postgres", + hostname: "index.docker.io", + imageName: "library/postgres", + versions: []string{"10.0", "10.1", "10.2"}, + }, + { + name: "tiller", + hostname: "gcr.io", + imageName: "kubernetes-helm/tiller", + versions: []string{"v2.14.1"}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + req := require.New(t) + + allVersions := makeVersions(test.versions) + mockreg := ®istry.Registry{} + + patchgetTagDate := gomonkey.ApplyFunc( + getTagDate, + func(reg *registry.Registry, imageName string, versionFromTag string) (string, error) { + return "2006-01-02T15:04:05Z", nil + }, + ) + defer patchgetTagDate.Reset() + + versionTags, err := resolveTagDates(mockreg, test.imageName, allVersions) + req.NoError(err) + + for _, versionTag := range versionTags { + _, err = time.Parse(time.RFC3339, versionTag.Date) + req.NoError(err) + } + }) + } +} + +func TestGetTagDate(t *testing.T) { + cases := []struct { + name string + wantErr bool + unmarshalErr bool + }{ + {"success", false, false}, + {"error", true, false}, + {"unmarshal error 2", false, true}, + } + + for _, tt := range cases { + + mockRegistry := ®istry.Registry{ + Username: "test-username", + Password: "test-password", + Domain: "test-domain", + URL: "test-url", + Client: &http.Client{}, + Logf: func(string, ...interface{}) {}, + } + + mockManifest := schema1.SignedManifest{} + mockManifest.History = []schema1.History{ + {V1Compatibility: "history-1"}, + } + + patchmanifest := gomonkey.ApplyMethod( + reflect.TypeOf(mockRegistry), + "ManifestV1", + func(*registry.Registry, context.Context, string, string) (schema1.SignedManifest, error) { + if tt.wantErr { + return schema1.SignedManifest{}, errors.New("manifest error") + } + return mockManifest, nil + }, + ) + defer patchmanifest.Reset() + + patchUnmarshal := gomonkey.ApplyFunc( + json.Unmarshal, + func([]byte, interface{}) error { + if tt.unmarshalErr { + return errors.New("unmarshal error") + } + return nil + }, + ) + defer patchUnmarshal.Reset() + + t.Run(tt.name, func(t *testing.T) { + resp, err := getTagDate(mockRegistry, "test-image", "test-tag") + if tt.wantErr { + require.Error(t, err) + } else if tt.unmarshalErr { + require.Error(t, err) + } else { + if resp == "" { + require.Error(t, err) + } else { + require.NoError(t, err) + } + } + }) + } +} + +func TestVersionsBehind(t *testing.T) { + v1, _ := semver.NewVersion("1.0.0") + v2, _ := semver.NewVersion("1.1.0") + v3, _ := semver.NewVersion("1.2.3") + + collection := SemverTagCollection{v1, v2, v3} + + currentVersion := v1 + expectedResult := []*semver.Version{v1, v2, v3} + result, err := collection.VersionsBehind(currentVersion) + assert.NoError(t, err) + assert.Equal(t, expectedResult, result) + + currentVersion = v2 + expectedResult = []*semver.Version{v2, v3} + result, err = collection.VersionsBehind(currentVersion) + assert.NoError(t, err) + assert.Equal(t, expectedResult, result) + + currentVersion = v3 + expectedResult = []*semver.Version{v3} + result, err = collection.VersionsBehind(currentVersion) + assert.NoError(t, err) + assert.Equal(t, expectedResult, result) + + currentVersion, _ = semver.NewVersion("2.0.0") + expectedResult = []*semver.Version{currentVersion} + result, err = collection.VersionsBehind(currentVersion) + assert.NoError(t, err) + assert.Equal(t, expectedResult, result) +} + +func TestListImages(t *testing.T) { + cases := []struct { + name string + namespaceErr bool + }{ + {"namespace error", true}, + } + + for _, tt := range cases { + mockConfig := &rest.Config{} + + t.Run(tt.name, func(t *testing.T) { + _, err := ListImages(mockConfig) + fmt.Println(err) + if tt.namespaceErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + + } +} + +type MockJetStreamContext struct{} + +func (m *MockJetStreamContext) AccountInfo(opts ...nats.JSOpt) (*nats.AccountInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) AddConsumer(stream string, cfg *nats.ConsumerConfig, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) AddStream(cfg *nats.StreamConfig, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ChanQueueSubscribe(subj, queue string, ch chan *nats.Msg, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ChanSubscribe(subj string, ch chan *nats.Msg, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ConsumerInfo(stream, consumer string, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ConsumerNames(stream string, opts ...nats.JSOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) Consumers(stream string, opts ...nats.JSOpt) <-chan *nats.ConsumerInfo { + return nil +} + +func (m *MockJetStreamContext) ConsumersInfo(stream string, opts ...nats.JSOpt) <-chan *nats.ConsumerInfo { + return nil +} + +func (m *MockJetStreamContext) CreateKeyValue(kv *nats.KeyValueConfig) (nats.KeyValue, error) { + return nil, nil +} + +func (m *MockJetStreamContext) CreateObjectStore(store *nats.ObjectStoreConfig) (nats.ObjectStore, error) { + return nil, nil +} + +func (m *MockJetStreamContext) DeleteConsumer(stream, consumer string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) DeleteKeyValue(key string) error { + return nil +} + +func (m *MockJetStreamContext) DeleteMsg(stream string, seq uint64, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) DeleteObjectStore(store string) error { + return nil +} + +func (m *MockJetStreamContext) DeleteStream(stream string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) GetLastMsg(stream string, lastBy string, opts ...nats.JSOpt) (*nats.RawStreamMsg, error) { + return nil, nil +} + +func (m *MockJetStreamContext) GetMsg(stream string, seq uint64, opts ...nats.JSOpt) (*nats.RawStreamMsg, error) { + return nil, nil +} + +func (m *MockJetStreamContext) KeyValue(stream string) (nats.KeyValue, error) { + return nil, nil +} + +func (m *MockJetStreamContext) KeyValueStoreNames() <-chan string { + return nil +} + +func (m *MockJetStreamContext) KeyValueStores() <-chan nats.KeyValueStatus { + return nil +} + +func (m *MockJetStreamContext) ObjectStore(stream string) (nats.ObjectStore, error) { + return nil, nil +} + +func (m *MockJetStreamContext) ObjectStoreNames(opts ...nats.ObjectOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) ObjectStores(opts ...nats.ObjectOpt) <-chan nats.ObjectStoreStatus { + return nil +} + +func (m *MockJetStreamContext) PublishAsync(subj string, data []byte, opts ...nats.PubOpt) (nats.PubAckFuture, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PublishAsyncComplete() <-chan struct{} { + return nil +} + +func (m *MockJetStreamContext) PublishAsyncPending() int { + return 0 +} + +func (m *MockJetStreamContext) PublishMsg(msg *nats.Msg, opts ...nats.PubOpt) (*nats.PubAck, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PublishMsgAsync(msg *nats.Msg, opts ...nats.PubOpt) (nats.PubAckFuture, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PullSubscribe(subject, queue string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) PurgeStream(stream string, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) QueueSubscribe(subject, queue string, handler nats.MsgHandler, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) QueueSubscribeSync(subject, queue string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) SecureDeleteMsg(stream string, seq uint64, opts ...nats.JSOpt) error { + return nil +} + +func (m *MockJetStreamContext) StreamInfo(stream string, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) StreamNameBySubject(subject string, opts ...nats.JSOpt) (string, error) { + return "", nil +} + +func (m *MockJetStreamContext) StreamNames(opts ...nats.JSOpt) <-chan string { + return nil +} + +func (m *MockJetStreamContext) Streams(opts ...nats.JSOpt) <-chan *nats.StreamInfo { + return nil +} + +func (m *MockJetStreamContext) StreamsInfo(opts ...nats.JSOpt) <-chan *nats.StreamInfo { + return nil +} + +func (m *MockJetStreamContext) Subscribe(subject string, cb nats.MsgHandler, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) SubscribeSync(subject string, opts ...nats.SubOpt) (*nats.Subscription, error) { + return nil, nil +} + +func (m *MockJetStreamContext) UpdateConsumer(stream string, cfg *nats.ConsumerConfig, opts ...nats.JSOpt) (*nats.ConsumerInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) UpdateStream(cfg *nats.StreamConfig, opts ...nats.JSOpt) (*nats.StreamInfo, error) { + return nil, nil +} + +func (m *MockJetStreamContext) Publish(subj string, data []byte, opts ...nats.PubOpt) (*nats.PubAck, error) { + return nil, errors.New("mocked publish error") +} + +type MockResourceInterface struct{} + +func (m *MockResourceInterface) Create(ctx context.Context, obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) Update(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) UpdateStatus(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) Delete(ctx context.Context, name string, options metav1.DeleteOptions, subresources ...string) error { + return nil +} +func (m *MockResourceInterface) DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error { + return nil +} + +func (m *MockResourceInterface) Get(ctx context.Context, name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) { + return nil, nil +} +func (m *MockResourceInterface) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + return nil, nil +} +func (m *MockResourceInterface) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, options metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) Apply(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error) { + return nil, nil +} +func (m *MockResourceInterface) ApplyStatus(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions) (*unstructured.Unstructured, error) { + return nil, nil +} + +type MockNamespaceableResourceInterface struct{} + +func (m *MockNamespaceableResourceInterface) Namespace(s string) dynamic.ResourceInterface { + return &MockResourceInterface{} +} From cdb38922a333d65efdfe6aab8f1b8ba39f0e45b6 Mon Sep 17 00:00:00 2001 From: vijeyash Date: Mon, 13 May 2024 12:43:23 +0530 Subject: [PATCH 04/10] go upgrading --- go.mod | 4 +- go.sum | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index e666b12a..36c86660 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/intelops/kubviz -go 1.20 +go 1.22 require ( bou.ke/monkey v1.0.2 @@ -11,6 +11,7 @@ require ( github.com/blang/semver v3.5.1+incompatible github.com/corneliusweig/tabwriter v0.0.0-20190512204542-5f8a091e83b5 github.com/davecgh/go-spew v1.1.1 + github.com/docker/distribution v2.8.2+incompatible github.com/docker/docker v24.0.4+incompatible github.com/genuinetools/reg v0.16.1 github.com/getkin/kin-openapi v0.118.0 @@ -60,7 +61,6 @@ require ( github.com/bytedance/sonic v1.9.1 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect diff --git a/go.sum b/go.sum index e04eec7e..071cec4f 100644 --- a/go.sum +++ b/go.sum @@ -29,7 +29,9 @@ cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUM cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= @@ -47,8 +49,10 @@ cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/o cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1/go.mod h1:VzwV+t+dZ9j/H867F1M2ziD+yLHtB46oM35FxxMJ4d0= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= @@ -58,43 +62,62 @@ github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ClickHouse/ch-go v0.52.1 h1:nucdgfD1BDSHjbNaG3VNebonxJzD8fX8jbuBpfo5VY0= github.com/ClickHouse/ch-go v0.52.1/go.mod h1:B9htMJ0hii/zrC2hljUKdnagRBuLqtRG/GrU3jqCwRk= github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= +github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/ClickHouse/clickhouse-go/v2 v2.10.1 h1:WCnusqEeCO/9sLFVIv57le/O1ydUb+x9+SYYhJ11fsY= github.com/ClickHouse/clickhouse-go/v2 v2.10.1/go.mod h1:teXfZNM90iQ99Jnuht+dxQXCuhDZ8nvvMoTJOFrcmcg= github.com/CycloneDX/cyclonedx-go v0.7.2-0.20230625092137-07e2f29defc3 h1:NqeV+ZMqpcosu0Xg2VW14Ru9ayBs/toe2oihS7sN6Xo= github.com/CycloneDX/cyclonedx-go v0.7.2-0.20230625092137-07e2f29defc3/go.mod h1:fGXSp1lCDfMQ8KR1EjxT4ewc5HHhGczRF2pWhLSWohs= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= +github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= +github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= +github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/Pallinder/go-randomdata v1.1.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 h1:ZK3C5DtzV2nVAQTx5S5jQvMeDqWtD1By5mOoyY/xJek= +github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw= github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= +github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= +github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092 h1:aM1rlcoLz8y5B2r4tTLMiVTrMtpfY0O8EScKJxaSaEc= github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092/go.mod h1:rYqSE9HbjzpHTI74vwPvae4ZVYZd1lue2ta6xHPdblA= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= +github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986 h1:2a30xLN2sUZcMXl50hg+PJCIDdJgIvIbVcKqLJ/ZrtM= +github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986/go.mod h1:NT+jyeCzXk6vXR5MTkdn4z64TgGfE5HMLC8qfj5unl8= github.com/aquasecurity/defsec v0.90.3 h1:ZBPhzS5/+75SLGEZe6fWFyWEuNtibNc7CZZXl2yQhjw= +github.com/aquasecurity/defsec v0.90.3/go.mod h1:VPkgjZz3dx3znIIVLZgbtFhSzN9aZC2409s5V5Oqb7o= github.com/aquasecurity/go-dep-parser v0.0.0-20230626110909-e7ea5097483b h1:9Ju7hWzTS8H9K/z1CqkJdZi+yxw1pZQZE11gVICtmTE= github.com/aquasecurity/go-dep-parser v0.0.0-20230626110909-e7ea5097483b/go.mod h1:VjG2wX19QDny5yKN+he0v9wuZjF0k+00173mh0FJCVU= github.com/aquasecurity/table v1.8.0 h1:9ntpSwrUfjrM6/YviArlx/ZBGd6ix8W+MtojQcM7tv0= @@ -109,19 +132,27 @@ github.com/aquasecurity/trivy-kubernetes v0.5.7-0.20230628140707-dae3bdb6ee81 h1 github.com/aquasecurity/trivy-kubernetes v0.5.7-0.20230628140707-dae3bdb6ee81/go.mod h1:GCm7uq++jz7Ij8cA9mAorpKJ9/qSBCl7v6EKYA8DxJ8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.25.24/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.245 h1:KtY2s4q31/kn33AdV63R5t77mdxsI7rq3YT7Mgo805M= github.com/aws/aws-sdk-go v1.44.245/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= +github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar/v4 v4.6.0 h1:HTuxyug8GyFbRkrffIpzNCSK4luc0TY3wzXvzIZhEXc= +github.com/bmatcuk/doublestar/v4 v4.6.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M= +github.com/bradleyjkemp/cupaloy/v2 v2.8.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= +github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= @@ -130,7 +161,9 @@ github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqy github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= +github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= @@ -139,30 +172,38 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg= +github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/codingsince1985/checksum v1.1.0/go.mod h1:oOS5kmF4DPKaeMAT7CCXcvakSB7s08Om5FdZTwV/CEk= github.com/containerd/containerd v1.2.9/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/containerd v1.7.0 h1:G/ZQr3gMZs6ZT0qPUZ15znx5QSdQdASW11nXTLTM2Pg= +github.com/containerd/containerd v1.7.0/go.mod h1:QfR7Efgb/6X2BDpTPJRvPTYDE9rsF0FsXX9J8sIs/sc= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/typeurl v1.0.2 h1:Chlt8zIieDbzQFzXzAeBEF92KhExuE4p9p92/QmY7aY= +github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s= github.com/coreos/clair v2.0.1-0.20190910143208-94150ab1f4ac+incompatible/go.mod h1:uXhHPWAoRqw0jJc2f8RrPCwRhIo9otQ8OEWUFtpCiwA= github.com/corneliusweig/tabwriter v0.0.0-20190512204542-5f8a091e83b5 h1:iMoW6t5AIY35+zpZ5jURPu16L6favadPR1TuKaSdfnA= github.com/corneliusweig/tabwriter v0.0.0-20190512204542-5f8a091e83b5/go.mod h1:DUmQHbnCLSgxjPeNlGcqKS1P9W1s4OYOsY3qvwK1H6U= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= +github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/denverdino/aliyungo v0.0.0-20191023002520-dba750c0c223/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dhui/dktest v0.3.16 h1:i6gq2YQEtcrjKbeJpBkWjE8MmLZPYllcjOFbTZuPDnw= +github.com/dhui/dktest v0.3.16/go.mod h1:gYaA3LRmM8Z4vJl2MA0THIigJoZrwOansEOsp+kqxp0= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= +github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/docker/cli v0.0.0-20190913211141-95327f4e6241/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v23.0.5+incompatible h1:ufWmAOuD3Vmr7JP2G5K3cyuNC4YZWiAsuDEvFVVDafE= +github.com/docker/cli v23.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= @@ -171,9 +212,11 @@ github.com/docker/docker v24.0.4+incompatible h1:s/LVDftw9hjblvqIeTiGYXBCD95nOEE github.com/docker/docker v24.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= +github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= +github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= @@ -185,6 +228,7 @@ github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -196,6 +240,7 @@ github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= +github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e/go.mod h1:2H9hjfbpSMHwY503FclkV/lZTBh2YlOmLLSda12uL8c= @@ -224,12 +269,16 @@ github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6v github.com/go-faster/errors v0.6.1 h1:nNIPOBkprlKzkThvS/0YaX8Zs9KewLCOSFQS5BU06FI= github.com/go-faster/errors v0.6.1/go.mod h1:5MGV2/2T9yvlrbhe9pD9LO5Z/2zCSq2T8j+Jpi2LAyY= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= +github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= github.com/go-git/go-git/v5 v5.7.0 h1:t9AudWVLmqzlo+4bqdf7GY+46SUuRsx59SboFxkq2aE= +github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gorp/gorp/v3 v3.0.5 h1:PUjzYdYu3HBOh8LE+UUmRG2P0IRDak9XMeGNvaeq4Ow= +github.com/go-gorp/gorp/v3 v3.0.5/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw= github.com/go-ini/ini v1.49.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= @@ -254,6 +303,7 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -267,9 +317,11 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78 github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-yaml v1.8.1 h1:JuZRFlqLM5cWF6A+waL8AKVuCcqvKOuhJtUQI+L3ez0= +github.com/goccy/go-yaml v1.8.1/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y= github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355/go.mod h1:cY2AIrMgHm6oOHmR7jY+9TtjzSjQ3iG7tURJG3Y6XH0= github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -278,10 +330,12 @@ github.com/golang-migrate/migrate/v4 v4.16.2 h1:8coYbMKUyInrFk1lfGfRovTLAW7PhWp8 github.com/golang-migrate/migrate/v4 v4.16.2/go.mod h1:pfcJX4nPHaVdc5nmdCikFBWtm+UBpiZjRNNsyBbp0/o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -339,6 +393,7 @@ github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/licenseclassifier/v2 v2.0.0 h1:1Y57HHILNf4m0ABuMVb6xk4vAJYEUO0gDxNpog0pyeA= +github.com/google/licenseclassifier/v2 v2.0.0/go.mod h1:cOjbdH0kyC9R22sdQbYsFkto4NGCAc+ZSwbeThazEtM= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -354,8 +409,10 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= +github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -363,6 +420,7 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= @@ -376,6 +434,7 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= +github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.11.1/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -385,19 +444,25 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.7.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= +github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= +github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl/v2 v2.14.1 h1:x0BpjfZ+CYdbiz+8yZTQ+gdLO7IXvOut7Da+XJayx34= +github.com/hashicorp/hcl/v2 v2.14.1/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= +github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -412,12 +477,14 @@ github.com/intelops/go-common v1.0.19/go.mod h1:GDDr2xP2uqtjMgATC4BLDt29kC7W9R3E github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -431,6 +498,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -449,6 +517,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -457,13 +526,19 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kuberhealthy/kuberhealthy/v2 v2.7.1 h1:N7kVL1HbO2zEu+zkcMa5oXQDhij9De38ZYL+p959bgk= github.com/kuberhealthy/kuberhealthy/v2 v2.7.1/go.mod h1:NRbBdxZLgIf+cy8PUau9q74nOqPLeC9HWr5faYKd9G8= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/liamg/iamgo v0.0.9 h1:tADGm3xVotyRJmuKKaH4+zsBn7LOcvgdpuF3WsSKW3c= +github.com/liamg/iamgo v0.0.9/go.mod h1:Kk6ZxBF/GQqG9nnaUjIi6jf+WXNpeOTyhwc6gnguaZQ= github.com/liamg/jfather v0.0.7 h1:Xf78zS263yfT+xr2VSo6+kyAy4ROlCacRqJG7s5jt4k= +github.com/liamg/jfather v0.0.7/go.mod h1:xXBGiBoiZ6tmHhfy5Jzw8sugzajwYdi6VosIpB3/cPM= github.com/liamg/memoryfs v1.4.3 h1:+ChjcuPRYpjJSulD13PXDNR3JeJ5HUYKjLHyWVK0bqU= +github.com/liamg/memoryfs v1.4.3/go.mod h1:z7mfqXFQS8eSeBBsFjYLlxYRMRyiPktytvYCYTb3BSk= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -480,22 +555,33 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= +github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/buildkit v0.11.6 h1:VYNdoKk5TVxN7k4RvZgdeM4GOyRvIi4Z8MXOY7xvyUs= +github.com/moby/buildkit v0.11.6/go.mod h1:GCqKfHhz+pddzfgaR7WmHVEE3nKKZMMDPpK8mh3ZLv4= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= +github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -510,11 +596,13 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nats-io/jwt/v2 v2.4.1 h1:Y35W1dgbbz2SQUYDPCaclXcuqleVmpbRa7646Jf2EX4= +github.com/nats-io/jwt/v2 v2.4.1/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI= github.com/nats-io/nats-server/v2 v2.9.19 h1:OF9jSKZGo425C/FcVVIvNgpd36CUe7aVTTXEZRJk6kA= github.com/nats-io/nats-server/v2 v2.9.19/go.mod h1:aTb/xtLCGKhfTFLxP591CMWfkdgBmcUUSkiSOe5A3gw= github.com/nats-io/nats.go v1.27.1 h1:OuYnal9aKVSnOzLQIzf7554OXMCG7KbaTkCSBHRcSoo= @@ -527,6 +615,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -534,13 +623,16 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= +github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= github.com/open-policy-agent/opa v0.45.0 h1:P5nuhVRtR+e58fk3CMMbiqr6ZFyWQPNOC3otsorGsFs= +github.com/open-policy-agent/opa v0.45.0/go.mod h1:/OnsYljNEWJ6DXeFOOnoGn8CvwZGMUS4iRqzYdJvmBI= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -549,7 +641,9 @@ github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYB github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/owenrumney/go-sarif/v2 v2.2.0 h1:1DmZaijK0HBZCR1fgcDSGa7VzYkU9NDmbZ7qC2QfUjE= +github.com/owenrumney/go-sarif/v2 v2.2.0/go.mod h1:MSqMMx9WqlBSY7pXoOZWgEsVB4FDNfhcaXDA1j6Sr+w= github.com/owenrumney/squealer v1.1.1 h1:e+fg29IxdNARSc4s7CbYnqVSepm9eOqErLNNNR5XbAs= +github.com/owenrumney/squealer v1.1.1/go.mod h1:Q5ekVoyFSG2FlnCVIBGsyk/FSMA/ATv8PtwKIVX7t/o= github.com/package-url/packageurl-go v0.1.1 h1:KTRE0bK3sKbFKAk3yy63DpeskU7Cvs/x/Da5l+RtzyU= github.com/package-url/packageurl-go v0.1.1/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c= github.com/paulmach/orb v0.9.0 h1:MwA1DqOKtvCgm7u9RZ/pnYejTeDJPnr0+0oFajBbJqk= @@ -566,6 +660,7 @@ github.com/peterhellberg/link v1.0.0/go.mod h1:gtSlOT4jmkY8P47hbTc8PTgiDDWpdPbFY github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -574,11 +669,16 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= +github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -588,7 +688,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rubenv/sql-migrate v1.3.1 h1:Vx+n4Du8X8VTYuXbhNxdEUoh6wiJERA0GlWocR5FrbA= +github.com/rubenv/sql-migrate v1.3.1/go.mod h1:YzG/Vh82CwyhTFXy+Mf5ahAiiEOpAlHurg+23VEzcsk= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -609,6 +711,7 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.1.1 h1:MTk78x9FPgDFVFkDLTrsnnfCJl7g1C/nnKvePgrIngE= +github.com/skeema/knownhosts v1.1.1/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb/go.mod h1:uKWaldnbMnjsSAXRurWqqrdyZen1R7kxl8TkmWk2OyM= @@ -616,6 +719,7 @@ github.com/spdx/tools-golang v0.5.0 h1:/fqihV2Jna7fmow65dHpgKNsilgLK7ICpd2tkCnPE github.com/spdx/tools-golang v0.5.0/go.mod h1:kkGlrSXXfHwuSzHQZJRV3aKu9ZXCq/MSf2+xyiJH1lM= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -642,7 +746,9 @@ github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes= +github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k= github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo= +github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= @@ -651,16 +757,22 @@ github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95 github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= +github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk= github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= github.com/yashtewari/glob-intersection v0.1.0 h1:6gJvMYQlTDOL3dMsPF6J0+26vwX9MB8/1q3uAdhmTrg= +github.com/yashtewari/glob-intersection v0.1.0/go.mod h1:LK7pIC3piUjovexikBbJ26Yml7g8xa5bsjfx2v1fwok= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -669,7 +781,9 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= +github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-yaml v1.0.2 h1:dNyg4QLTrv2IfJpm7Wtxi55ed5gLGOlPrZ6kMd51hY0= +github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= github.com/zegl/kube-score v1.17.0 h1:vedzK0pm5yOb1ocm5gybMNYsJRG8iTAatbo3LFIWbUc= github.com/zegl/kube-score v1.17.0/go.mod h1:0pt4Lt36uTKPiCQbXQFow29eaAbgMLI9RoESjBoGSq0= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= @@ -683,9 +797,11 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.46.1 h1:mMv2jG58h6ZI5t5S9QCVGdzCmAsTakMa3oxVgpSD44g= go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.46.1/go.mod h1:oqRuNKG0upTaDPbLVCG8AD0G2ETrfDtmh7jViy7ox6M= go.opentelemetry.io/contrib/propagators/b3 v1.21.1 h1:WPYiUgmw3+b7b3sQ1bFBFAf0q+Di9dvNc3AtYfnT4RQ= +go.opentelemetry.io/contrib/propagators/b3 v1.21.1/go.mod h1:EmzokPoSqsYMBVK4nRnhsfm5mbn8J1eDuz/U1UaQaWg= go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= @@ -706,6 +822,7 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= @@ -766,6 +883,7 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -839,6 +957,7 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1062,6 +1181,7 @@ google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= +google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0= @@ -1110,6 +1230,7 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= +gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= @@ -1118,6 +1239,7 @@ gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1136,6 +1258,7 @@ gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81 gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= helm.sh/helm/v3 v3.12.1 h1:lzU7etZX24A6BTMXYQF3bFq0ECfD8s+fKlNBBL8AbEc= +helm.sh/helm/v3 v3.12.1/go.mod h1:qhmSY9kcX7yH1xebe+FDMZa7E5NAeZ+LvK5j1gSln48= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1147,16 +1270,19 @@ k8s.io/api v0.21.3/go.mod h1:hUgeYHUbBp23Ue4qdX9tR8/ANi/g3ehylAqDn9NWVOg= k8s.io/api v0.27.3 h1:yR6oQXXnUEBWEWcvPWS0jQL575KoAboQPfJAuKNrw5Y= k8s.io/api v0.27.3/go.mod h1:C4BNvZnQOF7JA/0Xed2S+aUyJSfTGkGFxLXz9MnpIpg= k8s.io/apiextensions-apiserver v0.27.2 h1:iwhyoeS4xj9Y7v8YExhUwbVuBhMr3Q4bd/laClBV6Bo= +k8s.io/apiextensions-apiserver v0.27.2/go.mod h1:Oz9UdvGguL3ULgRdY9QMUzL2RZImotgxvGjdWRq6ZXQ= k8s.io/apimachinery v0.21.3/go.mod h1:H/IM+5vH9kZRNJ4l3x/fXP/5bOPJaVP/guptnZPeCFI= k8s.io/apimachinery v0.27.3 h1:Ubye8oBufD04l9QnNtW05idcOe9Z3GQN8+7PqmuVcUM= k8s.io/apimachinery v0.27.3/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= k8s.io/apiserver v0.27.2 h1:p+tjwrcQEZDrEorCZV2/qE8osGTINPuS5ZNqWAvKm5E= +k8s.io/apiserver v0.27.2/go.mod h1:EsOf39d75rMivgvvwjJ3OW/u9n1/BmUMK5otEOJrb1Y= k8s.io/cli-runtime v0.27.3 h1:h592I+2eJfXj/4jVYM+tu9Rv8FEc/dyCoD80UJlMW2Y= k8s.io/cli-runtime v0.27.3/go.mod h1:LzXud3vFFuDFXn2LIrWnscPgUiEj7gQQcYZE2UPn9Kw= k8s.io/client-go v0.21.3/go.mod h1:+VPhCgTsaFmGILxR/7E1N0S+ryO010QBeNCv5JwRGYU= k8s.io/client-go v0.27.3 h1:7dnEGHZEJld3lYwxvLl7WoehK6lAq7GvgjxpA3nv1E8= k8s.io/client-go v0.27.3/go.mod h1:2MBEKuTo6V1lbKy3z1euEGnhPfGZLKTS9tiJ2xodM48= k8s.io/component-base v0.27.2 h1:neju+7s/r5O4x4/txeUONNTS9r1HsPbyoPBAtHsDCpo= +k8s.io/component-base v0.27.2/go.mod h1:5UPk7EjfgrfgRIuDBFtsEFAe4DAvP3U+M8RTzoSJkpo= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= @@ -1167,10 +1293,12 @@ k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iL k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= k8s.io/kubectl v0.27.2 h1:sSBM2j94MHBFRWfHIWtEXWCicViQzZsb177rNsKBhZg= +k8s.io/kubectl v0.27.2/go.mod h1:GCOODtxPcrjh+EC611MqREkU8RjYBh10ldQCQ6zpFKw= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= oras.land/oras-go v1.2.2 h1:0E9tOHUfrNH7TCDk5KU0jVBEzCqbfdyuVfGmJ7ZeRPE= +oras.land/oras-go v1.2.2/go.mod h1:Apa81sKoZPpP7CDciE006tSZ0x3Q3+dOoBcMZ/aNxvw= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= From c2d7135f2e6e1e8d1c87da413b50c7e3ee579136 Mon Sep 17 00:00:00 2001 From: vijeyash Date: Mon, 13 May 2024 12:50:15 +0530 Subject: [PATCH 05/10] go upgrading --- dockerfiles/agent/container/Dockerfile | 2 +- dockerfiles/agent/git/Dockerfile | 2 +- dockerfiles/agent/kubviz/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dockerfiles/agent/container/Dockerfile b/dockerfiles/agent/container/Dockerfile index 686e2d74..cc6431ee 100644 --- a/dockerfiles/agent/container/Dockerfile +++ b/dockerfiles/agent/container/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19 AS builder +FROM golang:1.22 AS builder WORKDIR / COPY ./ ./ diff --git a/dockerfiles/agent/git/Dockerfile b/dockerfiles/agent/git/Dockerfile index 30e39251..10644da6 100644 --- a/dockerfiles/agent/git/Dockerfile +++ b/dockerfiles/agent/git/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19 AS builder +FROM golang:1.22 AS builder WORKDIR / COPY ./ ./ diff --git a/dockerfiles/agent/kubviz/Dockerfile b/dockerfiles/agent/kubviz/Dockerfile index fcaf9aa2..f7edd817 100644 --- a/dockerfiles/agent/kubviz/Dockerfile +++ b/dockerfiles/agent/kubviz/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.20 as builder +FROM golang:1.22 as builder WORKDIR /workspace # Copy the Go Modules manifests From a43ec5f67b856c7cabae3bc6223d79a3a6624523 Mon Sep 17 00:00:00 2001 From: vijeyash Date: Mon, 13 May 2024 12:50:40 +0530 Subject: [PATCH 06/10] go upgrading --- dockerfiles/client/Dockerfile | 2 +- dockerfiles/migration/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfiles/client/Dockerfile b/dockerfiles/client/Dockerfile index fd9f5b18..fda1470f 100644 --- a/dockerfiles/client/Dockerfile +++ b/dockerfiles/client/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.20 as builder +FROM golang:1.22 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/dockerfiles/migration/Dockerfile b/dockerfiles/migration/Dockerfile index 6cc51b93..5299a5a9 100644 --- a/dockerfiles/migration/Dockerfile +++ b/dockerfiles/migration/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20 as builder +FROM golang:1.22 as builder WORKDIR /workspace COPY ./ ./ From 0ab7fd4ee314755886727eff7559725d0af17c66 Mon Sep 17 00:00:00 2001 From: alanjino Date: Mon, 13 May 2024 22:06:26 +0530 Subject: [PATCH 07/10] docker base image changes --- dockerfiles/agent/container/Dockerfile | 5 +++-- dockerfiles/agent/git/Dockerfile | 5 +++-- dockerfiles/client/Dockerfile | 4 ++-- dockerfiles/migration/Dockerfile | 5 ++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dockerfiles/agent/container/Dockerfile b/dockerfiles/agent/container/Dockerfile index cc6431ee..c8b31212 100644 --- a/dockerfiles/agent/container/Dockerfile +++ b/dockerfiles/agent/container/Dockerfile @@ -1,11 +1,12 @@ -FROM golang:1.22 AS builder +FROM cgr.dev/chainguard/go:latest AS builder + WORKDIR / COPY ./ ./ RUN go mod download RUN CGO_ENABLED=0 go build -o ./build/agent agent/container/main.go -FROM scratch +FROM cgr.dev/chainguard/static:latest COPY --from=builder ./build/agent agent USER 65532:65532 diff --git a/dockerfiles/agent/git/Dockerfile b/dockerfiles/agent/git/Dockerfile index 10644da6..5b8656f1 100644 --- a/dockerfiles/agent/git/Dockerfile +++ b/dockerfiles/agent/git/Dockerfile @@ -1,11 +1,12 @@ -FROM golang:1.22 AS builder +FROM cgr.dev/chainguard/go:latest AS builder + WORKDIR / COPY ./ ./ RUN go mod download RUN CGO_ENABLED=0 go build -o ./build/agent agent/git/main.go -FROM scratch +FROM cgr.dev/chainguard/static:latest COPY --from=builder ./build/agent agent USER 65532:65532 diff --git a/dockerfiles/client/Dockerfile b/dockerfiles/client/Dockerfile index fda1470f..a8e03478 100644 --- a/dockerfiles/client/Dockerfile +++ b/dockerfiles/client/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.22 as builder +FROM cgr.dev/chainguard/go:latest AS builder WORKDIR /workspace # Copy the Go Modules manifests @@ -11,7 +11,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o k8smetri # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM golang:alpine +FROM cgr.dev/chainguard/static:latest WORKDIR / COPY --from=builder /workspace/k8smetrics_client . USER 65532:65532 diff --git a/dockerfiles/migration/Dockerfile b/dockerfiles/migration/Dockerfile index 5299a5a9..af93a514 100644 --- a/dockerfiles/migration/Dockerfile +++ b/dockerfiles/migration/Dockerfile @@ -1,5 +1,4 @@ -FROM golang:1.22 as builder - +FROM cgr.dev/chainguard/go:latest AS builder WORKDIR /workspace COPY ./ ./ RUN go mod download @@ -10,7 +9,7 @@ RUN chmod +x /workspace/script/wait-for-clickhouse.sh # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM golang:alpine +FROM cgr.dev/chainguard/wolfi-base RUN apk add --no-cache netcat-openbsd WORKDIR / COPY --from=builder /workspace/migration . From 89337da694b1b5c615fb76f81c642ba77f1269a2 Mon Sep 17 00:00:00 2001 From: vijeyash Date: Tue, 14 May 2024 10:52:32 +0530 Subject: [PATCH 08/10] sdk --- sdk/example/main.go | 60 ++++++++++++++++++++++ sdk/pkg/clickhouse/client.go | 28 +++++++++++ sdk/pkg/clickhouse/config.go | 21 ++++++++ sdk/pkg/clickhouse/utils.go | 72 +++++++++++++++++++++++++++ sdk/pkg/nats/client.go | 36 ++++++++++++++ sdk/pkg/nats/config.go | 19 +++++++ sdk/pkg/nats/utils.go | 85 ++++++++++++++++++++++++++++++++ sdk/pkg/sdk/clickhouse_insert.go | 10 ++++ sdk/pkg/sdk/listdata.go | 10 ++++ sdk/pkg/sdk/nats_consumer.go | 10 ++++ sdk/pkg/sdk/nats_publisher.go | 9 ++++ sdk/pkg/sdk/nats_stream.go | 9 ++++ sdk/pkg/sdk/sdk.go | 38 ++++++++++++++ 13 files changed, 407 insertions(+) create mode 100644 sdk/example/main.go create mode 100644 sdk/pkg/clickhouse/client.go create mode 100644 sdk/pkg/clickhouse/config.go create mode 100644 sdk/pkg/clickhouse/utils.go create mode 100644 sdk/pkg/nats/client.go create mode 100644 sdk/pkg/nats/config.go create mode 100644 sdk/pkg/nats/utils.go create mode 100644 sdk/pkg/sdk/clickhouse_insert.go create mode 100644 sdk/pkg/sdk/listdata.go create mode 100644 sdk/pkg/sdk/nats_consumer.go create mode 100644 sdk/pkg/sdk/nats_publisher.go create mode 100644 sdk/pkg/sdk/nats_stream.go create mode 100644 sdk/pkg/sdk/sdk.go diff --git a/sdk/example/main.go b/sdk/example/main.go new file mode 100644 index 00000000..d8c9e6dc --- /dev/null +++ b/sdk/example/main.go @@ -0,0 +1,60 @@ +package main + +import ( + "fmt" + "log" + "time" + + "github.com/intelops/kubviz/sdk/pkg/clickhouse" + "github.com/intelops/kubviz/sdk/pkg/nats" + "github.com/intelops/kubviz/sdk/pkg/sdk" +) + +func main() { + natsConfig, err := nats.LoadConfig() + if err != nil { + log.Fatalf("Failed to load NATS config: %v", err) + } + + chConfig, err := clickhouse.LoadConfig() + if err != nil { + log.Fatalf("Failed to load ClickHouse config: %v", err) + } + + mySDK, err := sdk.New(natsConfig, chConfig) + if err != nil { + log.Fatalf("Failed to initialize SDK: %v", err) + } + streamName := "Simple" + streamSubjects := "Simple.*" + err = mySDK.CreateNatsStream(streamName, []string{streamSubjects}) + if err != nil { + fmt.Println("Error creating NATS Stream:", err) + return + } + + time.Sleep(2 * time.Second) + + data := map[string]interface{}{ + "key": "value", + "count": 42, + } + subject := "Simple.event" + err = mySDK.PublishToNats(subject, streamName, data) + if err != nil { + fmt.Println("Error publishing message to NATS:", err) + return + } + time.Sleep(2 * time.Second) + consumerName := "myConsumer" + err = mySDK.ConsumeNatsData(subject, consumerName) + if err != nil { + fmt.Println("Error creating NATS consumer:", err) + return + } + err = mySDK.ClickHouseInsertData("mytable", data) + if err != nil { + fmt.Println("Error while inserting data into nats:", err) + return + } +} diff --git a/sdk/pkg/clickhouse/client.go b/sdk/pkg/clickhouse/client.go new file mode 100644 index 00000000..c4edb29c --- /dev/null +++ b/sdk/pkg/clickhouse/client.go @@ -0,0 +1,28 @@ +// /pkg/clickhouse/client.go +package clickhouse + +import ( + "database/sql" + "fmt" + + _ "github.com/ClickHouse/clickhouse-go/v2" +) + +type Client struct { + db *sql.DB +} + +func NewClient(cfg *Config) (*Client, error) { + dataSourceName := fmt.Sprintf("tcp://%s:%d", cfg.DBAddress, cfg.DBPort) + + db, err := sql.Open("clickhouse", dataSourceName) + if err != nil { + return nil, err + } + + if err := db.Ping(); err != nil { + return nil, err + } + + return &Client{db: db}, nil +} diff --git a/sdk/pkg/clickhouse/config.go b/sdk/pkg/clickhouse/config.go new file mode 100644 index 00000000..a56baa91 --- /dev/null +++ b/sdk/pkg/clickhouse/config.go @@ -0,0 +1,21 @@ +package clickhouse + +import ( + "github.com/kelseyhightower/envconfig" +) + +type Config struct { + DBAddress string `envconfig:"DB_ADDRESS" default:"localhost"` + DBPort int `envconfig:"DB_PORT" default:"9000"` + Username string `envconfig:"CLICKHOUSE_USERNAME"` + Password string `envconfig:"CLICKHOUSE_PASSWORD"` +} + +func LoadConfig() (*Config, error) { + var cfg Config + err := envconfig.Process("", &cfg) + if err != nil { + return nil, err + } + return &cfg, nil +} diff --git a/sdk/pkg/clickhouse/utils.go b/sdk/pkg/clickhouse/utils.go new file mode 100644 index 00000000..2525d5e4 --- /dev/null +++ b/sdk/pkg/clickhouse/utils.go @@ -0,0 +1,72 @@ +package clickhouse + +import ( + "context" + "errors" + "strings" + "time" +) + +func (c *Client) InsertData(tableName string, data interface{}) error { + ctx := context.Background() + + tx, err := c.db.Begin() + if err != nil { + return err + } + defer tx.Rollback() + + dataMap, ok := data.(map[string]interface{}) + if !ok { + return errors.New("data is not in the expected format") + } + + columns := make([]string, 0, len(dataMap)) + values := make([]interface{}, 0, len(dataMap)) + placeholders := make([]string, 0, len(dataMap)) + + for column, value := range dataMap { + columns = append(columns, column) + values = append(values, value) + placeholders = append(placeholders, "?") + } + + stmt, err := tx.PrepareContext(ctx, "INSERT INTO "+tableName+" ("+strings.Join(columns, ",")+") VALUES ("+strings.Join(placeholders, ",")+")") + if err != nil { + return err + } + defer stmt.Close() + + values = append(values, time.Now().UTC()) + + _, err = stmt.ExecContext(ctx, values...) + if err != nil { + return err + } + + return tx.Commit() +} + +func (c *Client) List(input interface{}) ([]map[string]interface{}, error) { + var dataList []map[string]interface{} + + inputMap, ok := input.(map[string]interface{}) + if !ok { + return nil, errors.New("input is not a map[string]interface{}") + } + + var traverse func(m map[string]interface{}) + traverse = func(m map[string]interface{}) { + dataList = append(dataList, m) + + for _, v := range m { + if subMap, ok := v.(map[string]interface{}); ok { + traverse(subMap) + } + } + } + + traverse(inputMap) + + return dataList, nil +} diff --git a/sdk/pkg/nats/client.go b/sdk/pkg/nats/client.go new file mode 100644 index 00000000..b5c26a37 --- /dev/null +++ b/sdk/pkg/nats/client.go @@ -0,0 +1,36 @@ +// /pkg/nats/client.go +package nats + +import ( + "fmt" + "log" + "os" + + "github.com/nats-io/nats.go" +) + +type Client struct { + js nats.JetStreamContext + logger *log.Logger +} + +func NewClient(cfg *Config) (*Client, error) { + logger := log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile) + + opts := []nats.Option{nats.Token(cfg.Token)} + + conn, err := nats.Connect(cfg.Address, opts...) + if err != nil { + return nil, fmt.Errorf("error connecting to NATS: %v", err) + } + + js, err := conn.JetStream() + if err != nil { + return nil, fmt.Errorf("error obtaining JetStream context: %v", err) + } + + return &Client{ + js: js, + logger: logger, + }, nil +} diff --git a/sdk/pkg/nats/config.go b/sdk/pkg/nats/config.go new file mode 100644 index 00000000..0fddfa96 --- /dev/null +++ b/sdk/pkg/nats/config.go @@ -0,0 +1,19 @@ +package nats + +import ( + "github.com/kelseyhightower/envconfig" +) + +type Config struct { + Address string `envconfig:"NATS_ADDRESS" default:"nats://localhost:4222"` + Token string `envconfig:"NATS_TOKEN"` +} + +func LoadConfig() (*Config, error) { + var cfg Config + err := envconfig.Process("", &cfg) + if err != nil { + return nil, err + } + return &cfg, nil +} diff --git a/sdk/pkg/nats/utils.go b/sdk/pkg/nats/utils.go new file mode 100644 index 00000000..36e144fb --- /dev/null +++ b/sdk/pkg/nats/utils.go @@ -0,0 +1,85 @@ +package nats + +import ( + "encoding/json" + "fmt" + "log" + + "github.com/nats-io/nats.go" + "github.com/pkg/errors" +) + +func (client *Client) CreateStream(streamName string, streamSubjects []string) error { + js := client.js + + stream, err := js.StreamInfo(streamName) + if err != nil { + if err == nats.ErrStreamNotFound { + client.logger.Printf("Stream does not exist, creating: %s", streamName) + } else { + client.logger.Printf("Error getting stream: %s", err) + return err + } + } + + if stream != nil { + client.logger.Printf("Stream already exists: %s", fmt.Sprintf("%v", stream)) + return nil + } + client.logger.Printf("Creating stream %q with subjects %q", streamName, streamSubjects) + streamInfo, err := js.AddStream(&nats.StreamConfig{ + Name: streamName, + Subjects: streamSubjects, + }) + + if err != nil { + return errors.WithMessage(err, "Error creating stream") + } + fmt.Println(streamInfo) + return nil +} + +func (client *Client) Consumer(subject, consumerName string) (interface{}, error) { + js := client.js + var data interface{} + handler := func(msg *nats.Msg) { + msg.Ack() + err := json.Unmarshal(msg.Data, &data) + if err != nil { + log.Println("Error unmarshalling message data:", err) + return + } + log.Printf("Data Received: %#v,", data) + } + _, err := js.Subscribe(subject, handler, nats.Durable(consumerName), nats.ManualAck()) + if err != nil { + return nil, fmt.Errorf("error subscribing to stream %s: %w", subject, err) + } + return data, nil +} + +func (client *Client) Publish(subject string, streamName string, data interface{}) error { + js := client.js + + resultdata, err := json.Marshal(data) + if err != nil { + return errors.WithMessage(err, "Error marshaling data to JSON") + } + stream, err := js.StreamInfo(streamName) + if err != nil { + if err == nats.ErrStreamNotFound { + client.logger.Printf("Stream does not exist %s", subject) + } else { + client.logger.Printf("Error getting stream: %s", err) + return err + } + } + if stream == nil { + return errors.New("Stream does not exist") + } + _, err = js.Publish(subject, resultdata) + if err != nil { + return errors.WithMessage(err, "Error publishing message") + } + return nil +} diff --git a/sdk/pkg/sdk/clickhouse_insert.go b/sdk/pkg/sdk/clickhouse_insert.go new file mode 100644 index 00000000..7fb4a65d --- /dev/null +++ b/sdk/pkg/sdk/clickhouse_insert.go @@ -0,0 +1,10 @@ +package sdk + +func (sdk *SDK) ClickHouseInsertData(tableName string, data interface{}) error { + err := sdk.clickhouseClient.InsertData(tableName, data) + if err != nil { + return err + } + sdk.logger.Printf("insert into table successfully %v", data) + return nil +} diff --git a/sdk/pkg/sdk/listdata.go b/sdk/pkg/sdk/listdata.go new file mode 100644 index 00000000..59580a55 --- /dev/null +++ b/sdk/pkg/sdk/listdata.go @@ -0,0 +1,10 @@ +package sdk + +func (sdk *SDK) ListtData(data interface{}) error { + data, err := sdk.clickhouseClient.List(data) + if err != nil { + return err + } + sdk.logger.Printf("insert into table successfully %v", data) + return nil +} diff --git a/sdk/pkg/sdk/nats_consumer.go b/sdk/pkg/sdk/nats_consumer.go new file mode 100644 index 00000000..88cffa4e --- /dev/null +++ b/sdk/pkg/sdk/nats_consumer.go @@ -0,0 +1,10 @@ +package sdk + +func (sdk *SDK) ConsumeNatsData(subject, consumerName string) error { + data, err := sdk.natsClient.Consumer(subject, consumerName) + if err != nil { + return err + } + sdk.logger.Printf("Consumed successfully from stream %v", data) + return nil +} diff --git a/sdk/pkg/sdk/nats_publisher.go b/sdk/pkg/sdk/nats_publisher.go new file mode 100644 index 00000000..43f9476a --- /dev/null +++ b/sdk/pkg/sdk/nats_publisher.go @@ -0,0 +1,9 @@ +package sdk + +func (sdk *SDK) PublishToNats(subject string, streamName string, data interface{}) error { + if err := sdk.natsClient.Publish(subject, streamName, data); err != nil { + return err + } + sdk.logger.Printf("Message published successfully to stream %v", streamName) + return nil +} diff --git a/sdk/pkg/sdk/nats_stream.go b/sdk/pkg/sdk/nats_stream.go new file mode 100644 index 00000000..006b3932 --- /dev/null +++ b/sdk/pkg/sdk/nats_stream.go @@ -0,0 +1,9 @@ +package sdk + +func (sdk *SDK) CreateNatsStream(streamName string, streamSubjects []string) error { + if err := sdk.natsClient.CreateStream(streamName, streamSubjects); err != nil { + return err + } + sdk.logger.Printf("Stream created successfully for streamName %v, streamSubjects %v", streamName, streamSubjects) + return nil +} diff --git a/sdk/pkg/sdk/sdk.go b/sdk/pkg/sdk/sdk.go new file mode 100644 index 00000000..ade6a6c8 --- /dev/null +++ b/sdk/pkg/sdk/sdk.go @@ -0,0 +1,38 @@ +package sdk + +import ( + "log" + "os" + + "github.com/intelops/kubviz/sdk/pkg/clickhouse" + "github.com/intelops/kubviz/sdk/pkg/nats" +) + +type SDK struct { + natsClient *nats.Client + clickhouseClient *clickhouse.Client + logger *log.Logger +} + +func New(natsCfg *nats.Config, chCfg *clickhouse.Config) (*SDK, error) { + logger := log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile) + natsClient, err := nats.NewClient(natsCfg) + if err != nil { + return nil, err + } + + chClient, err := clickhouse.NewClient(chCfg) + if err != nil { + return nil, err + } + + return &SDK{ + natsClient: natsClient, + clickhouseClient: chClient, + logger: logger, + }, nil +} + +func (sdk *SDK) Start() error { + return nil +} From 16b709133f001cb5591dbbefbee45d419174465a Mon Sep 17 00:00:00 2001 From: alanjino Date: Tue, 14 May 2024 13:14:56 +0530 Subject: [PATCH 09/10] update: Added chainguard image as base image --- dockerfiles/agent/container/Dockerfile | 2 +- dockerfiles/agent/git/Dockerfile | 2 +- dockerfiles/client/Dockerfile | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dockerfiles/agent/container/Dockerfile b/dockerfiles/agent/container/Dockerfile index c8b31212..aa8c3955 100644 --- a/dockerfiles/agent/container/Dockerfile +++ b/dockerfiles/agent/container/Dockerfile @@ -6,7 +6,7 @@ COPY ./ ./ RUN go mod download RUN CGO_ENABLED=0 go build -o ./build/agent agent/container/main.go -FROM cgr.dev/chainguard/static:latest +FROM scratch COPY --from=builder ./build/agent agent USER 65532:65532 diff --git a/dockerfiles/agent/git/Dockerfile b/dockerfiles/agent/git/Dockerfile index 5b8656f1..b57e6586 100644 --- a/dockerfiles/agent/git/Dockerfile +++ b/dockerfiles/agent/git/Dockerfile @@ -6,7 +6,7 @@ COPY ./ ./ RUN go mod download RUN CGO_ENABLED=0 go build -o ./build/agent agent/git/main.go -FROM cgr.dev/chainguard/static:latest +FROM scratch COPY --from=builder ./build/agent agent USER 65532:65532 diff --git a/dockerfiles/client/Dockerfile b/dockerfiles/client/Dockerfile index a8e03478..6da67bae 100644 --- a/dockerfiles/client/Dockerfile +++ b/dockerfiles/client/Dockerfile @@ -1,6 +1,6 @@ # Build the manager binary FROM cgr.dev/chainguard/go:latest AS builder - +RUN apk update && apk add go-1.21 WORKDIR /workspace # Copy the Go Modules manifests COPY ./ ./ @@ -11,7 +11,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o k8smetri # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM cgr.dev/chainguard/static:latest +FROM scratch WORKDIR / COPY --from=builder /workspace/k8smetrics_client . USER 65532:65532 From 5f145499f3721ac6d3fc04d894a25658855b2dd7 Mon Sep 17 00:00:00 2001 From: alanjino Date: Tue, 14 May 2024 13:17:29 +0530 Subject: [PATCH 10/10] update: Added chainguard image as base image --- dockerfiles/client/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/client/Dockerfile b/dockerfiles/client/Dockerfile index 6da67bae..19436734 100644 --- a/dockerfiles/client/Dockerfile +++ b/dockerfiles/client/Dockerfile @@ -1,6 +1,6 @@ # Build the manager binary FROM cgr.dev/chainguard/go:latest AS builder -RUN apk update && apk add go-1.21 + WORKDIR /workspace # Copy the Go Modules manifests COPY ./ ./