Skip to content

Commit

Permalink
Adds plugin support and a simple plugin as example.
Browse files Browse the repository at this point in the history
  • Loading branch information
JU4N98 committed Jun 26, 2023
1 parent 0a600d4 commit d58da49
Show file tree
Hide file tree
Showing 7 changed files with 441 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/stretchr/testify v1.8.4
golang.org/x/sys v0.8.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
)

require (
Expand All @@ -24,6 +25,5 @@ require (
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
209 changes: 209 additions & 0 deletions pkg/plugin/plugin.pb.go

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

109 changes: 109 additions & 0 deletions pkg/plugin/plugin_grpc.pb.go

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

41 changes: 41 additions & 0 deletions pkg/plugin/simple-example/simple-example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"context"
"fmt"
"log"
"net"

pb "github.com/spiffe/spiffe-helper/pkg/plugin"
"google.golang.org/grpc"
)

type simpleExampleServer struct {
pb.SpiffeHelperServer
}

func (s *simpleExampleServer) PostConfigs(ctx context.Context, request *pb.ConfigsRequest) (*pb.Empty, error) {
configs := request.Configs

fmt.Printf("From: %s\n", configs["from"])
fmt.Printf("To: %s\n", configs["to"])
fmt.Printf("Message: %s\n", configs["message"])

return new(pb.Empty), nil
}

func main() {
lis, err := net.Listen("tcp", "localhost:8081")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}

grpcServer := grpc.NewServer()
simpleExampleServer := &simpleExampleServer{}
pb.RegisterSpiffeHelperServer(grpcServer, simpleExampleServer)
log.Printf("server listening at %v", lis.Addr())

if err := grpcServer.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}
Loading

0 comments on commit d58da49

Please sign in to comment.