Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-timcu committed Dec 3, 2024
1 parent 6986a1d commit b2328e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/agent/cloud/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
)

func SendCloudRequest(endpoint string, route string, method string, payload interface{}) ([]byte, error) {
token := config.GetToken()
if token == "" {
return nil, fmt.Errorf("no token set")
}

apiEndpoint, err := url.JoinPath(endpoint, route)
if err != nil {
return nil, fmt.Errorf("failed to build API endpoint: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions lib/agent/grpc/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package grpc

import (
"main/cloud"
"main/globals"
"main/log"
)
Expand All @@ -11,6 +12,7 @@ func storeConfig(token, logLevel string, blocking, localhostAllowedByDefault, co

if globals.AikidoConfig.Token != "" || token == "" {
// Token is already set or the newly provided token via gRPC is invalid -> do not update the config in this case
log.Debugf("Aikido Config is already set. Returning early.")
return
}

Expand All @@ -21,4 +23,7 @@ func storeConfig(token, logLevel string, blocking, localhostAllowedByDefault, co
globals.AikidoConfig.CollectApiSchema = collectApiSchema

log.SetLogLevel(logLevel)
cloud.SendStartEvent()

log.Debugf("Updated Aikido Config with the one passed via gRPC!")
}
1 change: 0 additions & 1 deletion lib/agent/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type server struct {
}

func (s *server) OnConfig(ctx context.Context, req *protos.Config) (*emptypb.Empty, error) {
log.Debugf("Received config")
go storeConfig(req.GetToken(), req.GetLogLevel(), req.GetBlocking(), req.GetLocalhostAllowedByDefault(), req.GetCollectApiSchema())
return &emptypb.Empty{}, nil
}
Expand Down

0 comments on commit b2328e1

Please sign in to comment.