clearcase/internal/setup/issue_handler.go

44 lines
1.2 KiB
Go
Raw Normal View History

2025-02-21 18:42:56 +01:00
package setup
import (
"context"
"forge.cadoles.com/wpetit/clearcase/internal/config"
2025-02-22 09:42:15 +01:00
"forge.cadoles.com/wpetit/clearcase/internal/core/model"
"forge.cadoles.com/wpetit/clearcase/internal/core/port"
"forge.cadoles.com/wpetit/clearcase/internal/core/service"
2025-02-21 18:42:56 +01:00
"forge.cadoles.com/wpetit/clearcase/internal/http/handler/webui/issue"
2025-02-22 09:42:15 +01:00
"github.com/pkg/errors"
2025-02-21 18:42:56 +01:00
)
func NewIssueHandlerFromConfig(ctx context.Context, conf *config.Config) (*issue.Handler, error) {
2025-02-22 09:42:15 +01:00
issueManager, err := NewIssueManagerFromConfig(ctx, conf)
if err != nil {
return nil, errors.WithStack(err)
}
return issue.NewHandler(issueManager), nil
}
type authProviderBasedForgeFactory struct {
provider string
create func(ctx context.Context, user *model.User) (port.Forge, error)
2025-02-21 18:42:56 +01:00
}
2025-02-22 09:42:15 +01:00
// Create implements service.ForgeFactory.
func (a *authProviderBasedForgeFactory) Create(ctx context.Context, user *model.User) (port.Forge, error) {
forge, err := a.create(ctx, user)
if err != nil {
return nil, errors.WithStack(err)
}
return forge, nil
}
// Match implements service.ForgeFactory.
func (a *authProviderBasedForgeFactory) Match(user *model.User) bool {
return user.Provider == a.provider
}
var _ service.ForgeFactory = &authProviderBasedForgeFactory{}