|
- package reqbuilder
-
- import (
- "strconv"
-
- "gitlink.org.cn/cloudream/jcs-pub/client/internal/publock/lockprovider"
- "gitlink.org.cn/cloudream/jcs-pub/client/internal/publock/types"
- jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
- )
-
- type PackageLockReqBuilder[T any] struct {
- *LockRequestBuilder[T]
- }
-
- func (b *LockRequestBuilder[T]) Package() *PackageLockReqBuilder[T] {
- return &PackageLockReqBuilder[T]{LockRequestBuilder: b}
- }
- func (b *PackageLockReqBuilder[T]) Buzy(pkgID jcstypes.PackageID) *PackageLockReqBuilder[T] {
- b.Locks = append(b.Locks, types.Lock{
- Path: b.makePath(pkgID),
- Name: lockprovider.PackageBuzyLock,
- Target: lockprovider.NewEmptyTarget(),
- })
- return b
- }
-
- func (b *PackageLockReqBuilder[T]) Pin(pkgID jcstypes.PackageID) *PackageLockReqBuilder[T] {
- b.Locks = append(b.Locks, types.Lock{
- Path: b.makePath(pkgID),
- Name: lockprovider.PackagePinLock,
- Target: lockprovider.NewEmptyTarget(),
- })
- return b
- }
-
- func (b *PackageLockReqBuilder[T]) makePath(pkgID jcstypes.PackageID) []string {
- return []string{lockprovider.PackageLockPathPrefix, strconv.FormatInt(int64(pkgID), 10)}
- }
|