Skip to content

Commit

Permalink
feat(api) remove multiple rules for logging (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubdyszkiewicz authored Nov 13, 2019
1 parent 0dead41 commit c71ced8
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 289 deletions.
133 changes: 49 additions & 84 deletions api/mesh/v1alpha1/traffic_log.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions api/mesh/v1alpha1/traffic_log.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ option go_package = "v1alpha1";

import "mesh/v1alpha1/selector.proto";

// TrafficLog defines log for traffic between dataplanes.
message TrafficLog {
message Rule {

repeated Selector sources = 1;
repeated Selector destinations = 2;
// List of selectors to match dataplanes that are sources of traffic.
repeated Selector sources = 1;

message Conf { string backend = 1; }
// List of selectors to match services that are destinations of traffic.
repeated Selector destinations = 2;

Conf conf = 3;
// Configuration defines settings of the logging.
message Conf {
// Backend defined in the Mesh entity.
string backend = 1;
}

repeated Rule rules = 1;
// Configuration of the logging.
Conf conf = 3;
}
64 changes: 28 additions & 36 deletions app/kumactl/cmd/get/get_traffic_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,25 @@ var _ = Describe("kumactl get traffic-logs", func() {
trafficLoggingResources := []*mesh.TrafficLogResource{
{
Spec: v1alpha1.TrafficLog{
Rules: []*v1alpha1.TrafficLog_Rule{
Sources: []*v1alpha1.Selector{
{
Sources: []*v1alpha1.Selector{
{
Match: map[string]string{
"service": "web1",
"version": "1.0",
},
},
Match: map[string]string{
"service": "web1",
"version": "1.0",
},
Destinations: []*v1alpha1.Selector{
{
Match: map[string]string{
"service": "backend1",
"env": "dev",
},
},
},
Conf: &v1alpha1.TrafficLog_Rule_Conf{
Backend: "file",
},
},
Destinations: []*v1alpha1.Selector{
{
Match: map[string]string{
"service": "backend1",
"env": "dev",
},
},
},
Conf: &v1alpha1.TrafficLog_Conf{
Backend: "file",
},
},
Meta: &test_model.ResourceMeta{
Mesh: "default",
Expand All @@ -61,29 +57,25 @@ var _ = Describe("kumactl get traffic-logs", func() {
},
{
Spec: v1alpha1.TrafficLog{
Rules: []*v1alpha1.TrafficLog_Rule{
Sources: []*v1alpha1.Selector{
{
Sources: []*v1alpha1.Selector{
{
Match: map[string]string{
"service": "web2",
"version": "1.0",
},
},
Match: map[string]string{
"service": "web2",
"version": "1.0",
},
Destinations: []*v1alpha1.Selector{
{
Match: map[string]string{
"service": "backend2",
"env": "dev",
},
},
},
Conf: &v1alpha1.TrafficLog_Rule_Conf{
Backend: "logstash",
},
},
Destinations: []*v1alpha1.Selector{
{
Match: map[string]string{
"service": "backend2",
"env": "dev",
},
},
},
Conf: &v1alpha1.TrafficLog_Conf{
Backend: "logstash",
},
},
Meta: &test_model.ResourceMeta{
Mesh: "default",
Expand Down
68 changes: 30 additions & 38 deletions app/kumactl/cmd/get/testdata/get-traffic-logs.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,49 @@
{
"mesh": "default",
"name": "web1-to-backend1",
"rules": [
"sources": [
{
"sources": [
{
"match": {
"service": "web1",
"version": "1.0"
}
}
],
"destinations": [
{
"match": {
"service": "backend1",
"env": "dev"
}
}
],
"conf": {
"backend": "file"
"match": {
"service": "web1",
"version": "1.0"
}
}
],
"destinations": [
{
"match": {
"service": "backend1",
"env": "dev"
}
}
],
"conf": {
"backend": "file"
},
"type": "TrafficLog"
},
{
"mesh": "default",
"name": "web2-to-backend2",
"rules": [
"sources": [
{
"match": {
"service": "web2",
"version": "1.0"
}
}
],
"destinations": [
{
"sources": [
{
"match": {
"service": "web2",
"version": "1.0"
}
}
],
"destinations": [
{
"match": {
"service": "backend2",
"env": "dev"
}
}
],
"conf": {
"backend": "logstash"
"match": {
"service": "backend2",
"env": "dev"
}
}
],
"conf": {
"backend": "logstash"
},
"type": "TrafficLog"
}
]
Expand Down
Loading

0 comments on commit c71ced8

Please sign in to comment.