Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore(api): revert bool to boolValue PR #13057

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
439 changes: 211 additions & 228 deletions api/mesh/v1alpha1/mesh.pb.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions api/mesh/v1alpha1/mesh.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ message Mesh {
repeated CertificateAuthorityBackend backends = 2;

// If enabled, skips CA validation.
google.protobuf.BoolValue skipValidation = 3;
bool skipValidation = 3;
}

// mTLS settings.
Expand Down Expand Up @@ -227,15 +227,15 @@ message DatadogTracingBackendConfig {
// `backend` service that communicates with a couple of databases, you would
// get service names like `backend_INBOUND`, `backend_OUTBOUND_db1`, and
// `backend_OUTBOUND_db2` in Datadog. Default: false
google.protobuf.BoolValue splitService = 3;
bool splitService = 3;
}

message ZipkinTracingBackendConfig {
// Address of Zipkin collector.
string url = 1;

// Generate 128bit traces. Default: false
google.protobuf.BoolValue traceId128bit = 2;
bool traceId128bit = 2;

// Version of the API. values: httpJson, httpJsonV1, httpProto. Default:
// httpJson see
Expand Down Expand Up @@ -290,13 +290,13 @@ message TcpLoggingBackendConfig {
// Routing defines configuration for the routing in the mesh
message Routing {
// Enable the Locality Aware Load Balancing
google.protobuf.BoolValue localityAwareLoadBalancing = 1;
bool localityAwareLoadBalancing = 1;

// Enable routing traffic to services in other zone or external services
// through ZoneEgress. Default: false
google.protobuf.BoolValue zoneEgress = 2;
bool zoneEgress = 2;

// If true, blocks traffic to MeshExternalServices.
// Default: false
google.protobuf.BoolValue defaultForbidMeshExternalServiceAccess = 3;
bool defaultForbidMeshExternalServiceAccess = 3;
}
5 changes: 2 additions & 3 deletions app/kumactl/cmd/get/table_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/kumahq/kuma/app/kumactl/pkg/output/table"
"github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
"github.com/kumahq/kuma/pkg/core/resources/model"
"github.com/kumahq/kuma/pkg/util/pointer"
)

// CustomTablePrinters are used to define different ways to print entities in table format.
Expand Down Expand Up @@ -55,11 +54,11 @@ var CustomTablePrinters = map[model.ResourceType]RowPrinter{
}

locality := "off"
if pointer.Deref(mesh.Spec.GetRouting().GetLocalityAwareLoadBalancing()).Value {
if mesh.Spec.GetRouting().GetLocalityAwareLoadBalancing() {
locality = "on"
}
zoneEgress := "off"
if pointer.Deref(mesh.Spec.GetRouting().GetZoneEgress()).Value {
if mesh.Spec.GetRouting().GetZoneEgress() {
zoneEgress = "on"
}
return []string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"description": "Port of datadog collector"
},
"splitService": {
"additionalProperties": true,
"type": "boolean",
"description": "Determines if datadog service name should be split based on traffic direction and destination. For example, with `splitService: true` and a `backend` service that communicates with a couple of databases, you would get service names like `backend_INBOUND`, `backend_OUTBOUND_db1`, and `backend_OUTBOUND_db2` in Datadog. Default: false"
}
Expand Down
4 changes: 0 additions & 4 deletions docs/generated/raw/protos/Mesh.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
"description": "List of available Certificate Authority backends"
},
"skipValidation": {
"additionalProperties": true,
"type": "boolean",
"description": "If enabled, skips CA validation."
}
Expand Down Expand Up @@ -361,17 +360,14 @@
"kuma.mesh.v1alpha1.Routing": {
"properties": {
"localityAwareLoadBalancing": {
"additionalProperties": true,
"type": "boolean",
"description": "Enable the Locality Aware Load Balancing"
},
"zoneEgress": {
"additionalProperties": true,
"type": "boolean",
"description": "Enable routing traffic to services in other zone or external services through ZoneEgress. Default: false"
},
"defaultForbidMeshExternalServiceAccess": {
"additionalProperties": true,
"type": "boolean",
"description": "If true, blocks traffic to MeshExternalServices. Default: false"
}
Expand Down
3 changes: 0 additions & 3 deletions docs/generated/raw/protos/Routing.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
"Routing": {
"properties": {
"localityAwareLoadBalancing": {
"additionalProperties": true,
"type": "boolean",
"description": "Enable the Locality Aware Load Balancing"
},
"zoneEgress": {
"additionalProperties": true,
"type": "boolean",
"description": "Enable routing traffic to services in other zone or external services through ZoneEgress. Default: false"
},
"defaultForbidMeshExternalServiceAccess": {
"additionalProperties": true,
"type": "boolean",
"description": "If true, blocks traffic to MeshExternalServices. Default: false"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"description": "Address of Zipkin collector."
},
"traceId128bit": {
"additionalProperties": true,
"type": "boolean",
"description": "Generate 128bit traces. Default: false"
},
Expand Down
3 changes: 1 addition & 2 deletions pkg/core/managers/apis/mesh/mesh_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
"github.com/kumahq/kuma/pkg/core/validators"
"github.com/kumahq/kuma/pkg/util/pointer"
)

type MeshValidator interface {
Expand Down Expand Up @@ -48,7 +47,7 @@ func ValidateMTLSBackends(ctx context.Context, caManagers core_ca.Managers, name
if !exist {
verr.AddViolationAt(path.Index(idx).Field("type"), "could not find installed plugin for this type")
return verr
} else if !pointer.Deref(resource.Spec.GetMtls().GetSkipValidation()).Value {
} else if !resource.Spec.GetMtls().GetSkipValidation() {
if err := caManager.ValidateBackend(ctx, name, backend); err != nil {
if configErr, ok := err.(*validators.ValidationError); ok {
verr.AddErrorAt(path.Index(idx).Field("conf"), *configErr)
Expand Down
5 changes: 2 additions & 3 deletions pkg/core/resources/apis/mesh/mesh_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/plugins/ca/provided/config"
"github.com/kumahq/kuma/pkg/util/pointer"
util_proto "github.com/kumahq/kuma/pkg/util/proto"
)

Expand Down Expand Up @@ -40,11 +39,11 @@ func (m *MeshResource) MTLSEnabled() bool {
// Configuration of mTLS is validated on Mesh configuration
// change and when zoneEgress is enabled.
func (m *MeshResource) ZoneEgressEnabled() bool {
return m != nil && pointer.Deref(m.Spec.GetRouting().GetZoneEgress()).Value
return m != nil && m.Spec.GetRouting().GetZoneEgress()
}

func (m *MeshResource) LocalityAwareLbEnabled() bool {
return m != nil && pointer.Deref(m.Spec.GetRouting().GetLocalityAwareLoadBalancing()).Value
return m != nil && m.Spec.GetRouting().GetLocalityAwareLoadBalancing()
}

func (m *MeshResource) GetLoggingBackend(name string) *mesh_proto.LoggingBackend {
Expand Down
3 changes: 1 addition & 2 deletions pkg/core/resources/apis/mesh/mesh_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/core/validators"
"github.com/kumahq/kuma/pkg/util/pointer"
"github.com/kumahq/kuma/pkg/util/proto"
)

Expand Down Expand Up @@ -286,7 +285,7 @@ func validateZoneEgress(routing *mesh_proto.Routing, mtls *mesh_proto.Mesh_Mtls)
if routing == nil {
return verr
}
if pointer.Deref(routing.ZoneEgress).Value {
if routing.ZoneEgress {
if mtls.GetEnabledBackend() == "" {
verr.AddViolation("mtls", "has to be set when zoneEgress enabled")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
policies_xds "github.com/kumahq/kuma/pkg/plugins/policies/core/xds"
api "github.com/kumahq/kuma/pkg/plugins/policies/meshtrafficpermission/api/v1alpha1"
v3 "github.com/kumahq/kuma/pkg/plugins/policies/meshtrafficpermission/xds"
"github.com/kumahq/kuma/pkg/util/pointer"
xds_context "github.com/kumahq/kuma/pkg/xds/context"
"github.com/kumahq/kuma/pkg/xds/envoy/names"
"github.com/kumahq/kuma/pkg/xds/generator"
Expand Down Expand Up @@ -186,7 +185,7 @@ func (p plugin) configureEgress(rs *core_xds.ResourceSet, proxy *core_xds.Proxy)

for _, mesName := range mesNames {
rule := p.allowRules()
if resource.Mesh.Spec.GetRouting() != nil && pointer.Deref(resource.Mesh.Spec.GetRouting().DefaultForbidMeshExternalServiceAccess).Value {
if resource.Mesh.Spec.GetRouting() != nil && resource.Mesh.Spec.GetRouting().DefaultForbidMeshExternalServiceAccess {
rule = p.denyRules()
}
rules := core_rules.FromRules{
Expand Down
7 changes: 3 additions & 4 deletions pkg/test/resources/builders/mesh_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package builders
import (
"context"

"google.golang.org/protobuf/types/known/wrapperspb"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -72,7 +71,7 @@ func (m *MeshBuilder) WithoutBackendValidation() *MeshBuilder {
if m.res.Spec.Mtls == nil {
m.res.Spec.Mtls = &mesh_proto.Mesh_Mtls{}
}
m.res.Spec.Mtls.SkipValidation = &wrapperspb.BoolValue{Value: true}
m.res.Spec.Mtls.SkipValidation = true
return m
}

Expand Down Expand Up @@ -103,15 +102,15 @@ func (m *MeshBuilder) WithEgressRoutingEnabled() *MeshBuilder {
if m.res.Spec.Routing == nil {
m.res.Spec.Routing = &mesh_proto.Routing{}
}
m.res.Spec.Routing.ZoneEgress = &wrapperspb.BoolValue{Value: true}
m.res.Spec.Routing.ZoneEgress = true
return m
}

func (m *MeshBuilder) WithMeshExternalServiceTrafficForbidden() *MeshBuilder {
if m.res.Spec.Routing == nil {
m.res.Spec.Routing = &mesh_proto.Routing{}
}
m.res.Spec.Routing.DefaultForbidMeshExternalServiceAccess = &wrapperspb.BoolValue{Value: true}
m.res.Spec.Routing.DefaultForbidMeshExternalServiceAccess = true
return m
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/xds/envoy/listeners/v3/tracing_configurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"google.golang.org/protobuf/types/known/wrapperspb"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/util/pointer"
"github.com/kumahq/kuma/pkg/util/proto"
envoy_common "github.com/kumahq/kuma/pkg/xds/envoy"
"github.com/kumahq/kuma/pkg/xds/envoy/names"
Expand Down Expand Up @@ -101,7 +100,7 @@ func zipkinConfig(cfgStr *structpb.Struct, backendName string) (*envoy_trace.Tra
zipkinConfig := envoy_trace.ZipkinConfig{
CollectorCluster: names.GetTracingClusterName(backendName),
CollectorEndpoint: url.Path,
TraceId_128Bit: pointer.Deref(cfg.TraceId128Bit).Value,
TraceId_128Bit: cfg.TraceId128Bit,
CollectorEndpointVersion: apiVersion(&cfg, url),
SharedSpanContext: cfg.SharedSpanContext,
CollectorHostname: url.Host,
Expand Down Expand Up @@ -136,7 +135,7 @@ func apiVersion(zipkin *mesh_proto.ZipkinTracingBackendConfig, url *net_url.URL)
}

func createDatadogServiceName(datadog *mesh_proto.DatadogTracingBackendConfig, serviceName string, direction envoy_common.TrafficDirection, destination string) string {
if pointer.Deref(datadog.SplitService).Value {
if datadog.SplitService {
var datadogServiceName []string
switch direction {
case envoy_common.TrafficDirectionInbound:
Expand Down
7 changes: 3 additions & 4 deletions pkg/xds/envoy/listeners/v3/tracing_configurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v3_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/types/known/wrapperspb"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/pkg/core/xds"
Expand Down Expand Up @@ -122,7 +121,7 @@ var _ = Describe("TracingConfigurer", func() {
Conf: util_proto.MustToStruct(&mesh_proto.DatadogTracingBackendConfig{
Address: "1.1.1.1",
Port: 1111,
SplitService: &wrapperspb.BoolValue{Value: true},
SplitService: true,
}),
},
expected: `
Expand Down Expand Up @@ -159,7 +158,7 @@ var _ = Describe("TracingConfigurer", func() {
Conf: util_proto.MustToStruct(&mesh_proto.DatadogTracingBackendConfig{
Address: "1.1.1.1",
Port: 1111,
SplitService: &wrapperspb.BoolValue{Value: true},
SplitService: true,
}),
},
direction: envoy_common.TrafficDirectionInbound,
Expand Down Expand Up @@ -197,7 +196,7 @@ var _ = Describe("TracingConfigurer", func() {
Conf: util_proto.MustToStruct(&mesh_proto.DatadogTracingBackendConfig{
Address: "1.1.1.1",
Port: 1111,
SplitService: &wrapperspb.BoolValue{Value: true},
SplitService: true,
}),
},
direction: envoy_common.TrafficDirectionOutbound,
Expand Down
3 changes: 1 addition & 2 deletions pkg/xds/server/v3/snapshot_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
envoy_cluster "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/types/known/wrapperspb"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
kuma_cp "github.com/kumahq/kuma/pkg/config/app/kuma-cp"
Expand Down Expand Up @@ -259,7 +258,7 @@ var _ = Describe("GenerateSnapshot", func() {
WithName("demo").
With(func(resource *core_mesh.MeshResource) {
resource.Spec.Routing = &mesh_proto.Routing{
LocalityAwareLoadBalancing: &wrapperspb.BoolValue{Value: true},
LocalityAwareLoadBalancing: true,
}
}).
Build(),
Expand Down
7 changes: 3 additions & 4 deletions pkg/xds/topology/outbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
tlsv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/types/known/wrapperspb"

common_api "github.com/kumahq/kuma/api/common/v1alpha1"
common_tls "github.com/kumahq/kuma/api/common/v1alpha1/tls"
Expand Down Expand Up @@ -50,7 +49,7 @@ var _ = Describe("TrafficRoute", func() {
EnabledBackend: "ca-1",
},
Routing: &mesh_proto.Routing{
ZoneEgress: &wrapperspb.BoolValue{Value: true},
ZoneEgress: true,
},
},
}
Expand All @@ -63,7 +62,7 @@ var _ = Describe("TrafficRoute", func() {
EnabledBackend: "ca-1",
},
Routing: &mesh_proto.Routing{
ZoneEgress: &wrapperspb.BoolValue{Value: false},
ZoneEgress: false,
},
},
}
Expand All @@ -83,7 +82,7 @@ var _ = Describe("TrafficRoute", func() {
},
Spec: &mesh_proto.Mesh{
Routing: &mesh_proto.Routing{
LocalityAwareLoadBalancing: &wrapperspb.BoolValue{Value: true},
LocalityAwareLoadBalancing: true,
},
},
}
Expand Down
Loading