Skip to content

Commit

Permalink
Initialize Package
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 11, 2024
1 parent 7ed4d01 commit 35cb430
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 8 additions & 2 deletions api/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/spiffe/tornjak/pkg/agent/authentication/authenticator"
"github.com/spiffe/tornjak/pkg/agent/authorization"
agentdb "github.com/spiffe/tornjak/pkg/agent/db"
"github.com/spiffe/tornjak/pkg/agent/spirecrd"
)

func stringFromToken(keyToken token.Token) (string, error) {
Expand Down Expand Up @@ -86,7 +87,7 @@ func NewAgentsDB(dbPlugin *ast.ObjectItem) (agentdb.AgentDB, error) {
}

// NewCRDManager returns ...
func NewCRDManager(crdPlugin *ast.ObjectItem) (string, error) {
func NewCRDManager(crdPlugin *ast.ObjectItem) (spirecrd.CRDManager, error) {
_, data, _ := getPluginConfig(crdPlugin)

// check if data is defined
Expand All @@ -101,7 +102,12 @@ func NewCRDManager(crdPlugin *ast.ObjectItem) (string, error) {

fmt.Println("CRD Controller configured. WARNING: This is currently a no-op")

return "CRD config string", nil
crdManager, err := spirecrd.NewSPIRECRDManager(config.Classname)
if err != nil {
return nil, errors.Errorf("Could not initialize CRD manager: %v", err)
}

return crdManager, nil
}

// NewAuthenticator returns a new Authenticator
Expand Down
3 changes: 2 additions & 1 deletion api/agent/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/spiffe/tornjak/pkg/agent/authentication/authenticator"
"github.com/spiffe/tornjak/pkg/agent/authorization"
agentdb "github.com/spiffe/tornjak/pkg/agent/db"
"github.com/spiffe/tornjak/pkg/agent/spirecrd"
)

type Server struct {
Expand All @@ -32,7 +33,7 @@ type Server struct {

// Plugins
Db agentdb.AgentDB
CRDManager string // TODO create plugin for this
CRDManager spirecrd.CRDManager
Authenticator authenticator.Authenticator
Authorizer authorization.Authorizer
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/agent/spirecrd/crdmanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package spirecrd

// CRDManager defines the interface for managing CRDs
type CRDManager interface {
// TODO add List/Create/Update/Delete functions for Federation CRD
}

type SPIRECRDManager struct {
className string
}

// NewSPIRECRDManager initializes new SPIRECRDManager
func NewSPIRECRDManager(className string) (*SPIRECRDManager, error) {
return &SPIRECRDManager{
className: className,
}, nil
}

0 comments on commit 35cb430

Please sign in to comment.