func New(cfg config.Config) (GarmDaemon, error) {
	token, err := service.NewTokenService(cfg.Token)
	if err != nil {
		return nil, errors.Wrap(err, "token service instantiate failed")
	}
	resolver := service.NewResolver(cfg.Mapping)
	cfg.Athenz.AuthZ.Mapper = service.NewResourceMapper(resolver)
	cfg.Athenz.AuthN.Mapper = service.NewUserMapper(resolver)
	cfg.Athenz.AuthZ.Token = token.GetToken
	athenz, err := service.NewAthenz(cfg.Athenz, service.NewLogger(cfg.Logger))
	if err != nil {
		return nil, errors.Wrap(err, "athenz service instantiate failed")
	}
	return &garm{
		cfg:    cfg,
		token:  token,
		athenz: athenz,
		server: service.NewServer(cfg.Server, router.New(cfg.Server, handler.New(athenz))),
	}, nil
}
New returns a Garm daemon, or error occurred.
The daemon contains a token service authentication and authorization server.
This function will also initialize the mapping rules for the authentication and authorization check.
package usecase
import (
	"context"
	"github.com/pkg/errors"
	"github.com/yahoojapan/garm/config"
	"github.com/yahoojapan/garm/handler"
	"github.com/yahoojapan/garm/router"
	"github.com/yahoojapan/garm/service"
)
type GarmDaemon interface {
	Start(ctx context.Context) chan []error
}
type garm struct {
	cfg    config.Config
	token  service.TokenService
	athenz service.Athenz
	server service.Server
}