Skip to content

Commit

Permalink
move types to pkg
Browse files Browse the repository at this point in the history
Signed-off-by: Maia Iyer <[email protected]>
  • Loading branch information
maia-iyer committed Oct 18, 2024
1 parent 46a695e commit 9e09eb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions api/agent/crd_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"net/http"
"strings"

trustdomain "github.com/spiffe/spire-api-sdk/proto/spire/api/server/trustdomain/v1"
// trustdomain "github.com/spiffe/spire-api-sdk/proto/spire/api/server/trustdomain/v1"
crdmanager "github.com/spiffe/tornjak/pkg/agent/spirecrd"
// "google.golang.org/protobuf/encoding/protojson"
)

Expand All @@ -19,7 +20,7 @@ func (s *Server) CRDFederationList(w http.ResponseWriter, r *http.Request) {
return
}
// if CRD management is configured
var input trustdomain.ListFederationRelationshipsRequest
var input crdmanager.ListFederationRelationshipsRequest
buf := new(strings.Builder)

n, err := io.Copy(buf, r.Body)
Expand All @@ -31,7 +32,7 @@ func (s *Server) CRDFederationList(w http.ResponseWriter, r *http.Request) {
data := buf.String()

if n == 0 {
input = trustdomain.ListFederationRelationshipsRequest{}
input = crdmanager.ListFederationRelationshipsRequest{}
} else {
err := json.Unmarshal([]byte(data), &input)
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions pkg/agent/spirecrd/crdmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type CRDManager interface {
// TODO add List/Create/Update/Delete functions for Federation CRD
// ListClusterFederatedTrustDomain has the same signature as spire api
ListClusterFederatedTrustDomains(trustdomain.ListFederationRelationshipsRequest) (trustdomain.ListFederationRelationshipsResponse, error)
ListClusterFederatedTrustDomains(ListFederationRelationshipsRequest) (ListFederationRelationshipsResponse, error)
}

type SPIRECRDManager struct {
Expand All @@ -23,7 +23,10 @@ func NewSPIRECRDManager(className string) (*SPIRECRDManager, error) {
}, nil
}

func (s *SPIRECRDManager) ListClusterFederatedTrustDomains(inp trustdomain.ListFederationRelationshipsRequest) (trustdomain.ListFederationRelationshipsResponse, error) { //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
type ListFederationRelationshipsRequest trustdomain.ListFederationRelationshipsRequest
type ListFederationRelationshipsResponse trustdomain.ListFederationRelationshipsResponse

func (s *SPIRECRDManager) ListClusterFederatedTrustDomains(inp ListFederationRelationshipsRequest) (ListFederationRelationshipsResponse, error) { //nolint:govet //Ignoring mutex (not being used) - sync.Mutex by value is unused for linter govet
fmt.Println("list crd federation endpoint hit")
return trustdomain.ListFederationRelationshipsResponse{}, nil
return ListFederationRelationshipsResponse{}, nil
}

0 comments on commit 9e09eb5

Please sign in to comment.