mirror of
https://github.com/int128/kubelogin.git
synced 2026-02-14 16:39:51 +00:00
39 lines
875 B
Go
39 lines
875 B
Go
package clean
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/google/wire"
|
|
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
|
"github.com/int128/kubelogin/pkg/tokencache"
|
|
"github.com/int128/kubelogin/pkg/tokencache/repository"
|
|
)
|
|
|
|
var Set = wire.NewSet(
|
|
wire.Struct(new(Clean), "*"),
|
|
wire.Bind(new(Interface), new(*Clean)),
|
|
)
|
|
|
|
type Interface interface {
|
|
Do(ctx context.Context, in Input) error
|
|
}
|
|
|
|
// Input represents an input of the Clean use-case.
|
|
type Input struct {
|
|
TokenCacheConfig tokencache.Config
|
|
}
|
|
|
|
type Clean struct {
|
|
TokenCacheRepository repository.Interface
|
|
Logger logger.Interface
|
|
}
|
|
|
|
func (u *Clean) Do(ctx context.Context, in Input) error {
|
|
u.Logger.V(1).Infof("Deleting the token cache")
|
|
if err := u.TokenCacheRepository.DeleteAll(in.TokenCacheConfig); err != nil {
|
|
return fmt.Errorf("delete the token cache: %w", err)
|
|
}
|
|
return nil
|
|
}
|