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

use getters #124

Merged
merged 1 commit into from
Oct 25, 2023
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
10 changes: 5 additions & 5 deletions pkg/configstore/configStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,15 @@ func (cs *ConfigStore) saveLastEndpoints(ctx context.Context) {

for clusterName, ep := range lbEndpoints {
for _, value1 := range ep {
for _, value2 := range value1.LbEndpoints {
address := value2.GetEndpoint().GetAddress().GetSocketAddress().Address
for _, value2 := range value1.GetLbEndpoints() {
address := value2.GetEndpoint().GetAddress().GetSocketAddress().GetAddress()

publishEpArray = append(publishEpArray, fmt.Sprintf(
"%s|%s|%d|%s|%d|%d",
clusterName,
value1.Locality.GetZone(),
value1.Priority,
value2.GetEndpoint().GetAddress().GetSocketAddress().Address,
value1.GetLocality().GetZone(),
value1.GetPriority(),
value2.GetEndpoint().GetAddress().GetSocketAddress().GetAddress(),
value2.GetEndpoint().GetAddress().GetSocketAddress().GetPortValue(),
value2.GetEndpoint().GetHealthCheckConfig().GetPortValue(),
))
Expand Down
24 changes: 12 additions & 12 deletions pkg/controlplane/accessLogService.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ func (svc *AccessLogService) StreamAccessLogs(stream accessloggrpc.AccessLogServ
return errors.Wrap(err, "error in stream.Recv()")
}

if msg.Identifier != nil {
logName = msg.Identifier.LogName
if msg.GetIdentifier() != nil {
logName = msg.GetIdentifier().GetLogName()
}

switch entries := msg.LogEntries.(type) {
switch entries := msg.GetLogEntries().(type) {
case *accessloggrpc.StreamAccessLogsMessage_HttpLogs:
for _, entry := range entries.HttpLogs.LogEntry {
for _, entry := range entries.HttpLogs.GetLogEntry() {
if entry != nil {
common := entry.CommonProperties
req := entry.Request
resp := entry.Response
common := entry.GetCommonProperties()
req := entry.GetRequest()
resp := entry.GetResponse()

if common == nil {
common = &alf.AccessLogCommon{}
Expand All @@ -60,20 +60,20 @@ func (svc *AccessLogService) StreamAccessLogs(stream accessloggrpc.AccessLogServ
}

log.Infof(fmt.Sprintf("[%s%s] %s %s %s %d %s %s",
logName, time.Now().Format(time.RFC3339), req.Authority, req.Path, req.Scheme,
resp.ResponseCode.GetValue(), req.RequestId, common.UpstreamCluster))
logName, time.Now().Format(time.RFC3339), req.GetAuthority(), req.GetPath(), req.GetScheme(),
resp.GetResponseCode().GetValue(), req.GetRequestId(), common.GetUpstreamCluster()))
}
}
case *accessloggrpc.StreamAccessLogsMessage_TcpLogs:
for _, entry := range entries.TcpLogs.LogEntry {
for _, entry := range entries.TcpLogs.GetLogEntry() {
if entry != nil {
common := entry.CommonProperties
common := entry.GetCommonProperties()
if common == nil {
common = &alf.AccessLogCommon{}
}

log.Infof(fmt.Sprintf("[%s%s] tcp %s %s",
logName, time.Now().Format(time.RFC3339), common.UpstreamLocalAddress, common.UpstreamCluster))
logName, time.Now().Format(time.RFC3339), common.GetUpstreamLocalAddress(), common.GetUpstreamCluster()))
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/controlplane/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (cb *callbacks) OnStreamClosed(streamID int64, node *core.Node) {
if *config.Get().LogAccess {
log.WithFields(log.Fields{
"streamID": streamID,
"nodeID": node.Id,
"nodeID": node.GetId(),
}).Info("OnStreamClosed")
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func (cb *callbacks) OnStreamResponse(_ context.Context, _ int64, r *discovery.D
discoveryRequest, _ := protojson.Marshal(r)
discoveryResponse, _ := protojson.Marshal(w)

fileNameResponce := path.Join(*config.Get().LogPath, fmt.Sprintf("OnStreamResponse.%s.log", r.Node.Id))
fileNameResponce := path.Join(*config.Get().LogPath, fmt.Sprintf("OnStreamResponse.%s.log", r.GetNode().GetId()))

fResponce, err := os.OpenFile(fileNameResponce, os.O_APPEND|os.O_CREATE|os.O_WRONLY, filePerm)
if err != nil {
Expand All @@ -98,7 +98,7 @@ func (cb *callbacks) OnStreamResponse(_ context.Context, _ int64, r *discovery.D

defer fResponce.Close()

fileNameRequest := path.Join(*config.Get().LogPath, fmt.Sprintf("OnStreamRequest.%s.log", r.Node.Id))
fileNameRequest := path.Join(*config.Get().LogPath, fmt.Sprintf("OnStreamRequest.%s.log", r.GetNode().GetId()))

fRequest, err := os.OpenFile(fileNameRequest, os.O_APPEND|os.O_CREATE|os.O_WRONLY, filePerm)
if err != nil {
Expand Down Expand Up @@ -126,7 +126,7 @@ func (cb *callbacks) OnFetchRequest(_ context.Context, req *discovery.DiscoveryR
metrics.GrpcOnFetchRequest.Inc()

if *config.Get().LogAccess {
log := log.WithField("node", req.Node.Id)
log := log.WithField("node", req.GetNode().GetId())

log.Info("OnFetchRequest")
}
Expand All @@ -147,7 +147,7 @@ func (cb *callbacks) OnFetchResponse(r *discovery.DiscoveryRequest, w *discovery
metrics.GrpcOnFetchResponse.Inc()

if *config.Get().LogAccess {
log := log.WithField("node", r.Node.Id)
log := log.WithField("node", r.GetNode().GetId())

discoveryRequest, _ := protojson.Marshal(r)
discoveryResponse, _ := protojson.Marshal(w)
Expand Down Expand Up @@ -213,7 +213,7 @@ func (cb *callbacks) OnDeltaStreamClosed(streamID int64, node *core.Node) {
if *config.Get().LogAccess {
log.WithFields(log.Fields{
"streamID": streamID,
"nodeID": node.Id,
"nodeID": node.GetId(),
}).Info("OnDeltaStreamClosed")
}
}
22 changes: 11 additions & 11 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func NewSecrets(dnsName string, validation interface{}) ([]tls.Secret, error) {
return nil, errors.Wrap(err, "protojson.Unmarshal(jsonObj)")
}

if validationContext.TrustedCa == nil {
if validationContext.GetTrustedCa() == nil {
validationContext.TrustedCa = &core.DataSource{
Specifier: &core.DataSource_InlineBytes{InlineBytes: certs.GetLoadedRootCertBytes()},
}
Expand All @@ -246,18 +246,18 @@ func filterCertificates(listiners []types.Resource) error {
return errUnknownClass
}

for _, filterChain := range c.FilterChains {
s := filterChain.TransportSocket
for _, filterChain := range c.GetFilterChains() {
s := filterChain.GetTransportSocket()
if s != nil {
if s.Name == "envoy.transport_sockets.tls" {
if s.GetName() == "envoy.transport_sockets.tls" {
r := tls.DownstreamTlsContext{}

err := s.GetTypedConfig().UnmarshalTo(&r)
if err != nil {
return err
}

if r.RequireClientCertificate != nil {
if r.GetRequireClientCertificate() != nil {
r.RequireClientCertificate.Value = false
}

Expand Down Expand Up @@ -304,17 +304,17 @@ func mutateWeightedRoutes(configType *config.ConfigType, routes []types.Resource
return errUnknownClass
}

for _, v := range r.VirtualHosts {
for _, vr := range v.Routes {
for _, v := range r.GetVirtualHosts() {
for _, vr := range v.GetRoutes() {
if wc := vr.GetRoute().GetWeightedClusters(); wc != nil {
for _, c := range wc.Clusters {
weight, err := configType.GetClusterWeight(c.Name)
for _, c := range wc.GetClusters() {
weight, err := configType.GetClusterWeight(c.GetName())
if err != nil {
return err
}

if weight != nil && c.Weight.Value != uint32(weight.Value) {
log.Debugf("mutateWeightedRoutes: %s, weight: %d -> %d", c.Name, c.Weight.Value, weight)
if weight != nil && c.GetWeight().GetValue() != uint32(weight.Value) {
log.Debugf("mutateWeightedRoutes: %s, weight: %d -> %d", c.GetName(), c.GetWeight().GetValue(), weight)

c.Weight = &wrappers.UInt32Value{Value: uint32(weight.Value)}
}
Expand Down
Loading